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,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:clide/builtin/pql/src/backlinks_view.dart';
|
||||
import 'package:clide/builtin/pql/src/pql_panel_view.dart';
|
||||
import 'package:clide/extension/extension.dart';
|
||||
@@ -9,10 +11,14 @@ class PqlExtension extends ClideExtension {
|
||||
@override
|
||||
String get title => 'pql';
|
||||
@override
|
||||
String get version => '0.1.0';
|
||||
String get version => '0.2.0';
|
||||
@override
|
||||
List<String> get dependsOn => const [];
|
||||
|
||||
ClideExtensionContext? _ctx;
|
||||
StreamSubscription<DaemonEvent>? _editorSub;
|
||||
bool _backlinksSpawned = false;
|
||||
|
||||
@override
|
||||
List<ContributionPoint> get contributions => [
|
||||
TabContribution(
|
||||
@@ -24,14 +30,43 @@ class PqlExtension extends ClideExtension {
|
||||
priority: -60,
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user