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:
2026-04-23 16:14:11 +02:00
co-authored by Claude Opus 4.6
parent b8eb212cf5
commit 8ebc566b06
5 changed files with 177 additions and 51 deletions
+45 -12
View File
@@ -1,3 +1,5 @@
import 'dart:async';
import 'package:clide/builtin/markdown/src/markdown_viewer.dart';
import 'package:clide/extension/extension.dart';
import 'package:clide/kernel/kernel.dart';
@@ -8,20 +10,51 @@ class MarkdownExtension extends ClideExtension {
@override
String get title => 'Markdown';
@override
String get version => '0.1.0';
String get version => '0.2.0';
@override
List<String> get dependsOn => const ['builtin.editor'];
ClideExtensionContext? _ctx;
StreamSubscription<DaemonEvent>? _editorSub;
bool _viewerSpawned = false;
@override
List<ContributionPoint> get contributions => [
TabContribution(
id: 'markdown.viewer',
slot: Slots.contextPanel,
title: 'Viewer',
titleKey: 'tab.viewer',
i18nNamespace: id,
priority: -100,
build: (_) => const MarkdownViewer(),
),
];
List<ContributionPoint> get contributions => const [];
@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') {
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');
}
}