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:
2026-04-23 16:37:32 +02:00
co-authored by Claude Opus 4.6
parent bd00990e1d
commit 6dcb24144e
8 changed files with 66 additions and 173 deletions
+21 -14
View File
@@ -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;
}
}