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/decisions_view.dart';
|
||||
import 'package:clide/extension/extension.dart';
|
||||
import 'package:clide/kernel/kernel.dart';
|
||||
import 'package:clide/kernel/src/events/message_bus.dart';
|
||||
|
||||
class DecisionsExtension extends ClideExtension {
|
||||
@override
|
||||
@@ -9,10 +12,14 @@ class DecisionsExtension extends ClideExtension {
|
||||
@override
|
||||
String get title => 'Decisions';
|
||||
@override
|
||||
String get version => '0.2.0';
|
||||
String get version => '0.3.0';
|
||||
@override
|
||||
List<String> get dependsOn => const [];
|
||||
|
||||
ClideExtensionContext? _ctx;
|
||||
StreamSubscription<Message>? _selectionSub;
|
||||
bool _detailSpawned = false;
|
||||
|
||||
@override
|
||||
List<ContributionPoint> get contributions => [
|
||||
TabContribution(
|
||||
@@ -24,12 +31,40 @@ class DecisionsExtension extends ClideExtension {
|
||||
priority: -20,
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user