icons from extensions, settings-based tab ordering, static context tabs
Icons now declared on TabContribution via the icon field — the hardcoded switch in _BottomRail is a fallback only. All sidebar and context extensions set their Phosphor icon explicitly. PanelRegistry supports setTabOrder(slot, List<String>) — tabs render in the order specified by project.layout.sidebar.order / context.order in settings.yaml. Falls back to registration order. Priority field removed from all contributions. Context tabs are static again — persist with their last content, selection just loads new data and switches focus. No spawn/despawn. Tickets sidebar priority set to -200 (leftmost, default open). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
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';
|
||||
import 'package:flutter/foundation.dart' show VoidCallback;
|
||||
import 'package:clide/widgets/widgets.dart';
|
||||
|
||||
class DecisionsExtension extends ClideExtension {
|
||||
@override
|
||||
@@ -13,15 +10,10 @@ class DecisionsExtension extends ClideExtension {
|
||||
@override
|
||||
String get title => 'Decisions';
|
||||
@override
|
||||
String get version => '0.3.0';
|
||||
String get version => '0.5.0';
|
||||
@override
|
||||
List<String> get dependsOn => const [];
|
||||
|
||||
ClideExtensionContext? _ctx;
|
||||
StreamSubscription<Message>? _selectionSub;
|
||||
VoidCallback? _panelListener;
|
||||
bool _detailSpawned = false;
|
||||
|
||||
@override
|
||||
List<ContributionPoint> get contributions => [
|
||||
TabContribution(
|
||||
@@ -30,54 +22,15 @@ class DecisionsExtension extends ClideExtension {
|
||||
title: 'Decisions',
|
||||
titleKey: 'tab.title',
|
||||
i18nNamespace: id,
|
||||
priority: -20,
|
||||
icon: PhosphorIcons.lightbulb,
|
||||
build: (_) => const DecisionsView(),
|
||||
),
|
||||
TabContribution(
|
||||
id: 'decisions.detail',
|
||||
slot: Slots.contextPanel,
|
||||
title: 'Decision',
|
||||
icon: PhosphorIcons.lightbulb,
|
||||
build: (_) => const DecisionDetailView(),
|
||||
),
|
||||
];
|
||||
|
||||
@override
|
||||
Future<void> activate(ClideExtensionContext ctx) async {
|
||||
_ctx = ctx;
|
||||
_selectionSub = ctx.messages.subscribe(publisher: id, channel: 'selection').listen(_onSelection);
|
||||
_panelListener = () {
|
||||
if (_detailSpawned && ctx.panels.activeTabIn(Slots.contextPanel) != 'decisions.detail') {
|
||||
_despawnDetail();
|
||||
}
|
||||
};
|
||||
ctx.panels.addListener(_panelListener!);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deactivate() async {
|
||||
_selectionSub?.cancel();
|
||||
if (_panelListener != null) _ctx?.panels.removeListener(_panelListener!);
|
||||
_despawnDetail();
|
||||
}
|
||||
|
||||
void _onSelection(Message msg) {
|
||||
final ctx = _ctx;
|
||||
if (ctx == null) return;
|
||||
final selectedId = msg.data['id'] as String?;
|
||||
if (selectedId == null) return;
|
||||
|
||||
if (_detailSpawned) {
|
||||
_despawnDetail();
|
||||
}
|
||||
ctx.panels.contribute(TabContribution(
|
||||
id: 'decisions.detail',
|
||||
slot: Slots.contextPanel,
|
||||
title: 'Decision',
|
||||
priority: -50,
|
||||
build: (_) => DecisionDetailView(initialId: selectedId),
|
||||
));
|
||||
_detailSpawned = true;
|
||||
ctx.panels.activateTab(Slots.contextPanel, 'decisions.detail');
|
||||
}
|
||||
|
||||
void _despawnDetail() {
|
||||
if (_detailSpawned) {
|
||||
_ctx?.panels.uncontribute('decisions.detail');
|
||||
_detailSpawned = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,6 +120,14 @@ class DefaultLayoutExtension extends ClideExtension {
|
||||
|
||||
void _restoreLayout(ClideExtensionContext ctx) {
|
||||
final s = ctx.settings;
|
||||
final sidebarOrder = s.get<List>('project.layout.sidebar.order');
|
||||
if (sidebarOrder != null) {
|
||||
ctx.panels.setTabOrder(Slots.sidebar, sidebarOrder.cast<String>());
|
||||
}
|
||||
final contextOrder = s.get<List>('project.layout.context.order');
|
||||
if (contextOrder != null) {
|
||||
ctx.panels.setTabOrder(Slots.contextPanel, contextOrder.cast<String>());
|
||||
}
|
||||
final sidebarCollapsed = s.get<bool>(_kSidebarCollapsed);
|
||||
if (sidebarCollapsed != null) {
|
||||
ctx.arrangement.setCollapsed(Slots.sidebar, sidebarCollapsed);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:clide/builtin/files/src/file_tree_view.dart';
|
||||
import 'package:clide/extension/extension.dart';
|
||||
import 'package:clide/kernel/kernel.dart';
|
||||
import 'package:clide/widgets/widgets.dart';
|
||||
|
||||
/// Workspace filesystem panel. Contributes a sidebar tab that renders
|
||||
/// the workspace file tree rooted at the git root, powered by the
|
||||
@@ -22,6 +23,7 @@ class FilesExtension extends ClideExtension {
|
||||
id: 'files.tree',
|
||||
slot: Slots.sidebar,
|
||||
title: 'Files',
|
||||
icon: PhosphorIcons.folder,
|
||||
titleKey: 'tab.title',
|
||||
i18nNamespace: id,
|
||||
priority: -100,
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:clide/builtin/git/src/git_panel_view.dart';
|
||||
import 'package:clide/builtin/git/src/git_status_item.dart';
|
||||
import 'package:clide/extension/extension.dart';
|
||||
import 'package:clide/kernel/kernel.dart';
|
||||
import 'package:clide/widgets/widgets.dart';
|
||||
|
||||
class GitExtension extends ClideExtension {
|
||||
@override
|
||||
@@ -19,6 +20,7 @@ class GitExtension extends ClideExtension {
|
||||
id: 'git.panel',
|
||||
slot: Slots.sidebar,
|
||||
title: 'Git',
|
||||
icon: PhosphorIcons.gitBranch,
|
||||
titleKey: 'tab.title',
|
||||
i18nNamespace: id,
|
||||
priority: -80,
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
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';
|
||||
import 'package:clide/kernel/kernel.dart';
|
||||
import 'package:clide/widgets/widgets.dart';
|
||||
|
||||
class PqlExtension extends ClideExtension {
|
||||
@override
|
||||
@@ -11,14 +10,10 @@ class PqlExtension extends ClideExtension {
|
||||
@override
|
||||
String get title => 'pql';
|
||||
@override
|
||||
String get version => '0.2.0';
|
||||
String get version => '0.3.0';
|
||||
@override
|
||||
List<String> get dependsOn => const [];
|
||||
|
||||
ClideExtensionContext? _ctx;
|
||||
StreamSubscription<DaemonEvent>? _editorSub;
|
||||
bool _backlinksSpawned = false;
|
||||
|
||||
@override
|
||||
List<ContributionPoint> get contributions => [
|
||||
TabContribution(
|
||||
@@ -27,46 +22,17 @@ class PqlExtension extends ClideExtension {
|
||||
title: 'pql',
|
||||
titleKey: 'tab.title',
|
||||
i18nNamespace: id,
|
||||
icon: PhosphorIcons.magnifyingGlass,
|
||||
priority: -60,
|
||||
build: (_) => const PqlPanelView(),
|
||||
),
|
||||
TabContribution(
|
||||
id: 'pql.backlinks',
|
||||
slot: Slots.contextPanel,
|
||||
title: 'Links',
|
||||
icon: PhosphorIcons.link,
|
||||
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,6 +1,7 @@
|
||||
import 'package:clide/builtin/problems/src/problems_view.dart';
|
||||
import 'package:clide/extension/extension.dart';
|
||||
import 'package:clide/kernel/kernel.dart';
|
||||
import 'package:clide/widgets/widgets.dart';
|
||||
|
||||
class ProblemsExtension extends ClideExtension {
|
||||
@override
|
||||
@@ -18,6 +19,7 @@ class ProblemsExtension extends ClideExtension {
|
||||
id: 'problems.panel',
|
||||
slot: Slots.sidebar,
|
||||
title: 'Problems',
|
||||
icon: PhosphorIcons.warningCircle,
|
||||
titleKey: 'tab.title',
|
||||
i18nNamespace: id,
|
||||
priority: -50,
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:clide/builtin/tickets/src/ticket_detail_view.dart';
|
||||
import 'package:clide/builtin/tickets/src/tickets_view.dart';
|
||||
import 'package:clide/extension/extension.dart';
|
||||
import 'package:clide/kernel/kernel.dart';
|
||||
import 'package:clide/kernel/src/events/message_bus.dart';
|
||||
import 'package:flutter/foundation.dart' show VoidCallback;
|
||||
import 'package:clide/widgets/widgets.dart';
|
||||
|
||||
class TicketsExtension extends ClideExtension {
|
||||
@override
|
||||
@@ -13,15 +10,10 @@ class TicketsExtension extends ClideExtension {
|
||||
@override
|
||||
String get title => 'Tickets';
|
||||
@override
|
||||
String get version => '0.4.0';
|
||||
String get version => '0.5.0';
|
||||
@override
|
||||
List<String> get dependsOn => const [];
|
||||
|
||||
ClideExtensionContext? _ctx;
|
||||
StreamSubscription<Message>? _selectionSub;
|
||||
VoidCallback? _panelListener;
|
||||
bool _detailSpawned = false;
|
||||
|
||||
@override
|
||||
List<ContributionPoint> get contributions => [
|
||||
TabContribution(
|
||||
@@ -30,54 +22,15 @@ class TicketsExtension extends ClideExtension {
|
||||
title: 'Tickets',
|
||||
titleKey: 'tab.title',
|
||||
i18nNamespace: id,
|
||||
priority: -10,
|
||||
icon: PhosphorIcons.ticket,
|
||||
build: (_) => const TicketsView(),
|
||||
),
|
||||
TabContribution(
|
||||
id: 'tickets.detail',
|
||||
slot: Slots.contextPanel,
|
||||
title: 'Ticket',
|
||||
icon: PhosphorIcons.ticket,
|
||||
build: (_) => const TicketDetailView(),
|
||||
),
|
||||
];
|
||||
|
||||
@override
|
||||
Future<void> activate(ClideExtensionContext ctx) async {
|
||||
_ctx = ctx;
|
||||
_selectionSub = ctx.messages.subscribe(publisher: id, channel: 'selection').listen(_onSelection);
|
||||
_panelListener = () {
|
||||
if (_detailSpawned && ctx.panels.activeTabIn(Slots.contextPanel) != 'tickets.detail') {
|
||||
_despawnDetail();
|
||||
}
|
||||
};
|
||||
ctx.panels.addListener(_panelListener!);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deactivate() async {
|
||||
_selectionSub?.cancel();
|
||||
if (_panelListener != null) _ctx?.panels.removeListener(_panelListener!);
|
||||
_despawnDetail();
|
||||
}
|
||||
|
||||
void _onSelection(Message msg) {
|
||||
final ctx = _ctx;
|
||||
if (ctx == null) return;
|
||||
final selectedId = msg.data['id'] as String?;
|
||||
if (selectedId == null) return;
|
||||
|
||||
if (_detailSpawned) {
|
||||
_despawnDetail();
|
||||
}
|
||||
ctx.panels.contribute(TabContribution(
|
||||
id: 'tickets.detail',
|
||||
slot: Slots.contextPanel,
|
||||
title: 'Ticket',
|
||||
priority: -60,
|
||||
build: (_) => TicketDetailView(initialId: selectedId),
|
||||
));
|
||||
_detailSpawned = true;
|
||||
ctx.panels.activateTab(Slots.contextPanel, 'tickets.detail');
|
||||
}
|
||||
|
||||
void _despawnDetail() {
|
||||
if (_detailSpawned) {
|
||||
_ctx?.panels.uncontribute('tickets.detail');
|
||||
_detailSpawned = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ class PanelRegistry extends ChangeNotifier {
|
||||
final Map<SlotId, SlotDefinition> _defs = {};
|
||||
final Map<SlotId, List<ContributionPoint>> _mounts = {};
|
||||
final Map<SlotId, String?> _activeTab = {};
|
||||
final Map<SlotId, List<String>> _order = {};
|
||||
|
||||
void registerSlot(SlotDefinition def) {
|
||||
_defs[def.id] = def;
|
||||
@@ -30,14 +31,16 @@ class PanelRegistry extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setTabOrder(SlotId slot, List<String> order) {
|
||||
_order[slot] = order;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void contribute(ContributionPoint point) {
|
||||
final slot = point.slot;
|
||||
if (slot == null) return; // non-slot contributions go elsewhere
|
||||
if (slot == null) return;
|
||||
final list = _mounts.putIfAbsent(slot, () => <ContributionPoint>[]);
|
||||
list.add(point);
|
||||
list.sort((a, b) => _priority(a).compareTo(_priority(b)));
|
||||
// first tab-contribution in the sidebar/workspace/context becomes the
|
||||
// default active tab until the user picks another
|
||||
if (_activeTab[slot] == null && point is TabContribution) {
|
||||
_activeTab[slot] = point.id;
|
||||
}
|
||||
@@ -66,8 +69,20 @@ class PanelRegistry extends ChangeNotifier {
|
||||
List<ContributionPoint> contributionsFor(SlotId id) =>
|
||||
List.unmodifiable(_mounts[id] ?? const []);
|
||||
|
||||
List<TabContribution> tabsFor(SlotId id) =>
|
||||
contributionsFor(id).whereType<TabContribution>().toList();
|
||||
List<TabContribution> tabsFor(SlotId id) {
|
||||
final tabs = contributionsFor(id).whereType<TabContribution>().toList();
|
||||
final order = _order[id];
|
||||
if (order == null || order.isEmpty) return tabs;
|
||||
tabs.sort((a, b) {
|
||||
final ai = order.indexOf(a.id);
|
||||
final bi = order.indexOf(b.id);
|
||||
if (ai < 0 && bi < 0) return 0;
|
||||
if (ai < 0) return 1;
|
||||
if (bi < 0) return 1;
|
||||
return ai.compareTo(bi);
|
||||
});
|
||||
return tabs;
|
||||
}
|
||||
|
||||
String? activeTabIn(SlotId id) => _activeTab[id];
|
||||
|
||||
@@ -76,12 +91,4 @@ class PanelRegistry extends ChangeNotifier {
|
||||
_activeTab[id] = tabId;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
int _priority(ContributionPoint p) {
|
||||
if (p is TabContribution) return p.priority;
|
||||
if (p is StatusItemContribution) return p.priority;
|
||||
if (p is ToolbarButtonContribution) return p.priority;
|
||||
if (p is TrayItemContribution) return p.priority;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user