dynamic context panel tabs — spawn on demand, no empty placeholders
Context panel tabs are no longer static. Extensions spawn them dynamically when relevant and despawn on deactivate: - Tickets: detail tab spawns on builtin.tickets/selection - Decisions: detail tab spawns on builtin.decisions/selection - Backlinks: spawns when editor opens a file - Markdown viewer: spawns when editor opens a .md file - Graph: removed from static context (will be command-spawnable) The icon rail only shows what's active — no empty tabs sitting there waiting for content. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:clide/builtin/decisions/src/decision_detail_view.dart';
|
import 'package:clide/builtin/decisions/src/decision_detail_view.dart';
|
||||||
import 'package:clide/builtin/decisions/src/decisions_view.dart';
|
import 'package:clide/builtin/decisions/src/decisions_view.dart';
|
||||||
import 'package:clide/extension/extension.dart';
|
import 'package:clide/extension/extension.dart';
|
||||||
import 'package:clide/kernel/kernel.dart';
|
import 'package:clide/kernel/kernel.dart';
|
||||||
|
import 'package:clide/kernel/src/events/message_bus.dart';
|
||||||
|
|
||||||
class DecisionsExtension extends ClideExtension {
|
class DecisionsExtension extends ClideExtension {
|
||||||
@override
|
@override
|
||||||
@@ -9,10 +12,14 @@ class DecisionsExtension extends ClideExtension {
|
|||||||
@override
|
@override
|
||||||
String get title => 'Decisions';
|
String get title => 'Decisions';
|
||||||
@override
|
@override
|
||||||
String get version => '0.2.0';
|
String get version => '0.3.0';
|
||||||
@override
|
@override
|
||||||
List<String> get dependsOn => const [];
|
List<String> get dependsOn => const [];
|
||||||
|
|
||||||
|
ClideExtensionContext? _ctx;
|
||||||
|
StreamSubscription<Message>? _selectionSub;
|
||||||
|
bool _detailSpawned = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<ContributionPoint> get contributions => [
|
List<ContributionPoint> get contributions => [
|
||||||
TabContribution(
|
TabContribution(
|
||||||
@@ -24,12 +31,40 @@ class DecisionsExtension extends ClideExtension {
|
|||||||
priority: -20,
|
priority: -20,
|
||||||
build: (_) => const DecisionsView(),
|
build: (_) => const DecisionsView(),
|
||||||
),
|
),
|
||||||
TabContribution(
|
|
||||||
id: 'decisions.detail',
|
|
||||||
slot: Slots.contextPanel,
|
|
||||||
title: 'Decision',
|
|
||||||
priority: -50,
|
|
||||||
build: (_) => const DecisionDetailView(),
|
|
||||||
),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> activate(ClideExtensionContext ctx) async {
|
||||||
|
_ctx = ctx;
|
||||||
|
_selectionSub = ctx.messages.subscribe(publisher: id, channel: 'selection').listen(_onSelection);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> deactivate() async {
|
||||||
|
_selectionSub?.cancel();
|
||||||
|
_despawnDetail();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onSelection(Message msg) {
|
||||||
|
final ctx = _ctx;
|
||||||
|
if (ctx == null) return;
|
||||||
|
if (!_detailSpawned) {
|
||||||
|
ctx.panels.contribute(TabContribution(
|
||||||
|
id: 'decisions.detail',
|
||||||
|
slot: Slots.contextPanel,
|
||||||
|
title: 'Decision',
|
||||||
|
priority: -50,
|
||||||
|
build: (_) => const DecisionDetailView(),
|
||||||
|
));
|
||||||
|
_detailSpawned = true;
|
||||||
|
}
|
||||||
|
ctx.panels.activateTab(Slots.contextPanel, 'decisions.detail');
|
||||||
|
}
|
||||||
|
|
||||||
|
void _despawnDetail() {
|
||||||
|
if (_detailSpawned) {
|
||||||
|
_ctx?.panels.uncontribute('decisions.detail');
|
||||||
|
_detailSpawned = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import 'package:clide/builtin/graph/src/graph_view.dart';
|
|
||||||
import 'package:clide/extension/extension.dart';
|
import 'package:clide/extension/extension.dart';
|
||||||
import 'package:clide/kernel/kernel.dart';
|
|
||||||
|
|
||||||
class GraphExtension extends ClideExtension {
|
class GraphExtension extends ClideExtension {
|
||||||
@override
|
@override
|
||||||
@@ -13,15 +11,5 @@ class GraphExtension extends ClideExtension {
|
|||||||
List<String> get dependsOn => const ['builtin.pql'];
|
List<String> get dependsOn => const ['builtin.pql'];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<ContributionPoint> get contributions => [
|
List<ContributionPoint> get contributions => const [];
|
||||||
TabContribution(
|
|
||||||
id: 'graph.view',
|
|
||||||
slot: Slots.contextPanel,
|
|
||||||
title: 'Graph',
|
|
||||||
titleKey: 'tab.graph',
|
|
||||||
i18nNamespace: id,
|
|
||||||
priority: -80,
|
|
||||||
build: (_) => const GraphView(),
|
|
||||||
),
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:clide/builtin/markdown/src/markdown_viewer.dart';
|
import 'package:clide/builtin/markdown/src/markdown_viewer.dart';
|
||||||
import 'package:clide/extension/extension.dart';
|
import 'package:clide/extension/extension.dart';
|
||||||
import 'package:clide/kernel/kernel.dart';
|
import 'package:clide/kernel/kernel.dart';
|
||||||
@@ -8,20 +10,51 @@ class MarkdownExtension extends ClideExtension {
|
|||||||
@override
|
@override
|
||||||
String get title => 'Markdown';
|
String get title => 'Markdown';
|
||||||
@override
|
@override
|
||||||
String get version => '0.1.0';
|
String get version => '0.2.0';
|
||||||
@override
|
@override
|
||||||
List<String> get dependsOn => const ['builtin.editor'];
|
List<String> get dependsOn => const ['builtin.editor'];
|
||||||
|
|
||||||
|
ClideExtensionContext? _ctx;
|
||||||
|
StreamSubscription<DaemonEvent>? _editorSub;
|
||||||
|
bool _viewerSpawned = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<ContributionPoint> get contributions => [
|
List<ContributionPoint> get contributions => const [];
|
||||||
TabContribution(
|
|
||||||
id: 'markdown.viewer',
|
@override
|
||||||
slot: Slots.contextPanel,
|
Future<void> activate(ClideExtensionContext ctx) async {
|
||||||
title: 'Viewer',
|
_ctx = ctx;
|
||||||
titleKey: 'tab.viewer',
|
_editorSub = ctx.events.on<DaemonEvent>().listen((e) {
|
||||||
i18nNamespace: id,
|
if (e.subsystem != 'editor') return;
|
||||||
priority: -100,
|
if (e.kind == 'editor.active-changed' || e.kind == 'editor.opened') {
|
||||||
build: (_) => const MarkdownViewer(),
|
final path = e.data['path'] as String?;
|
||||||
),
|
if (path != null && path.endsWith('.md')) {
|
||||||
];
|
_spawnViewer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> deactivate() async {
|
||||||
|
_editorSub?.cancel();
|
||||||
|
if (_viewerSpawned) {
|
||||||
|
_ctx?.panels.uncontribute('markdown.viewer');
|
||||||
|
_viewerSpawned = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _spawnViewer() {
|
||||||
|
final ctx = _ctx;
|
||||||
|
if (ctx == null || _viewerSpawned) return;
|
||||||
|
ctx.panels.contribute(TabContribution(
|
||||||
|
id: 'markdown.viewer',
|
||||||
|
slot: Slots.contextPanel,
|
||||||
|
title: 'Viewer',
|
||||||
|
priority: -100,
|
||||||
|
build: (_) => const MarkdownViewer(),
|
||||||
|
));
|
||||||
|
_viewerSpawned = true;
|
||||||
|
ctx.panels.activateTab(Slots.contextPanel, 'markdown.viewer');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:clide/builtin/pql/src/backlinks_view.dart';
|
import 'package:clide/builtin/pql/src/backlinks_view.dart';
|
||||||
import 'package:clide/builtin/pql/src/pql_panel_view.dart';
|
import 'package:clide/builtin/pql/src/pql_panel_view.dart';
|
||||||
import 'package:clide/extension/extension.dart';
|
import 'package:clide/extension/extension.dart';
|
||||||
@@ -9,10 +11,14 @@ class PqlExtension extends ClideExtension {
|
|||||||
@override
|
@override
|
||||||
String get title => 'pql';
|
String get title => 'pql';
|
||||||
@override
|
@override
|
||||||
String get version => '0.1.0';
|
String get version => '0.2.0';
|
||||||
@override
|
@override
|
||||||
List<String> get dependsOn => const [];
|
List<String> get dependsOn => const [];
|
||||||
|
|
||||||
|
ClideExtensionContext? _ctx;
|
||||||
|
StreamSubscription<DaemonEvent>? _editorSub;
|
||||||
|
bool _backlinksSpawned = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<ContributionPoint> get contributions => [
|
List<ContributionPoint> get contributions => [
|
||||||
TabContribution(
|
TabContribution(
|
||||||
@@ -24,14 +30,43 @@ class PqlExtension extends ClideExtension {
|
|||||||
priority: -60,
|
priority: -60,
|
||||||
build: (_) => const PqlPanelView(),
|
build: (_) => const PqlPanelView(),
|
||||||
),
|
),
|
||||||
TabContribution(
|
|
||||||
id: 'pql.backlinks',
|
|
||||||
slot: Slots.contextPanel,
|
|
||||||
title: 'Links',
|
|
||||||
titleKey: 'tab.links',
|
|
||||||
i18nNamespace: id,
|
|
||||||
priority: -80,
|
|
||||||
build: (_) => const BacklinksView(),
|
|
||||||
),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> activate(ClideExtensionContext ctx) async {
|
||||||
|
_ctx = ctx;
|
||||||
|
_editorSub = ctx.events.on<DaemonEvent>().listen((e) {
|
||||||
|
if (e.subsystem != 'editor') return;
|
||||||
|
if (e.kind == 'editor.active-changed' || e.kind == 'editor.opened') {
|
||||||
|
_spawnBacklinks();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> deactivate() async {
|
||||||
|
_editorSub?.cancel();
|
||||||
|
_despawnBacklinks();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _spawnBacklinks() {
|
||||||
|
final ctx = _ctx;
|
||||||
|
if (ctx == null || _backlinksSpawned) return;
|
||||||
|
ctx.panels.contribute(TabContribution(
|
||||||
|
id: 'pql.backlinks',
|
||||||
|
slot: Slots.contextPanel,
|
||||||
|
title: 'Links',
|
||||||
|
priority: -80,
|
||||||
|
build: (_) => const BacklinksView(),
|
||||||
|
));
|
||||||
|
_backlinksSpawned = true;
|
||||||
|
ctx.panels.activateTab(Slots.contextPanel, 'pql.backlinks');
|
||||||
|
}
|
||||||
|
|
||||||
|
void _despawnBacklinks() {
|
||||||
|
if (_backlinksSpawned) {
|
||||||
|
_ctx?.panels.uncontribute('pql.backlinks');
|
||||||
|
_backlinksSpawned = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:clide/builtin/tickets/src/ticket_detail_view.dart';
|
import 'package:clide/builtin/tickets/src/ticket_detail_view.dart';
|
||||||
import 'package:clide/builtin/tickets/src/tickets_view.dart';
|
import 'package:clide/builtin/tickets/src/tickets_view.dart';
|
||||||
import 'package:clide/extension/extension.dart';
|
import 'package:clide/extension/extension.dart';
|
||||||
import 'package:clide/kernel/kernel.dart';
|
import 'package:clide/kernel/kernel.dart';
|
||||||
|
import 'package:clide/kernel/src/events/message_bus.dart';
|
||||||
|
|
||||||
class TicketsExtension extends ClideExtension {
|
class TicketsExtension extends ClideExtension {
|
||||||
@override
|
@override
|
||||||
@@ -9,10 +12,14 @@ class TicketsExtension extends ClideExtension {
|
|||||||
@override
|
@override
|
||||||
String get title => 'Tickets';
|
String get title => 'Tickets';
|
||||||
@override
|
@override
|
||||||
String get version => '0.2.0';
|
String get version => '0.3.0';
|
||||||
@override
|
@override
|
||||||
List<String> get dependsOn => const [];
|
List<String> get dependsOn => const [];
|
||||||
|
|
||||||
|
ClideExtensionContext? _ctx;
|
||||||
|
StreamSubscription<Message>? _selectionSub;
|
||||||
|
bool _detailSpawned = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<ContributionPoint> get contributions => [
|
List<ContributionPoint> get contributions => [
|
||||||
TabContribution(
|
TabContribution(
|
||||||
@@ -24,12 +31,40 @@ class TicketsExtension extends ClideExtension {
|
|||||||
priority: -10,
|
priority: -10,
|
||||||
build: (_) => const TicketsView(),
|
build: (_) => const TicketsView(),
|
||||||
),
|
),
|
||||||
TabContribution(
|
|
||||||
id: 'tickets.detail',
|
|
||||||
slot: Slots.contextPanel,
|
|
||||||
title: 'Ticket',
|
|
||||||
priority: -60,
|
|
||||||
build: (_) => const TicketDetailView(),
|
|
||||||
),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> activate(ClideExtensionContext ctx) async {
|
||||||
|
_ctx = ctx;
|
||||||
|
_selectionSub = ctx.messages.subscribe(publisher: id, channel: 'selection').listen(_onSelection);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> deactivate() async {
|
||||||
|
_selectionSub?.cancel();
|
||||||
|
_despawnDetail();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onSelection(Message msg) {
|
||||||
|
final ctx = _ctx;
|
||||||
|
if (ctx == null) return;
|
||||||
|
if (!_detailSpawned) {
|
||||||
|
ctx.panels.contribute(TabContribution(
|
||||||
|
id: 'tickets.detail',
|
||||||
|
slot: Slots.contextPanel,
|
||||||
|
title: 'Ticket',
|
||||||
|
priority: -60,
|
||||||
|
build: (_) => const TicketDetailView(),
|
||||||
|
));
|
||||||
|
_detailSpawned = true;
|
||||||
|
}
|
||||||
|
ctx.panels.activateTab(Slots.contextPanel, 'tickets.detail');
|
||||||
|
}
|
||||||
|
|
||||||
|
void _despawnDetail() {
|
||||||
|
if (_detailSpawned) {
|
||||||
|
_ctx?.panels.uncontribute('tickets.detail');
|
||||||
|
_detailSpawned = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user