Files
clide/lib/kernel/src/panels/view_pane_snapshot.dart
T
jpmschweitzerandClaude Opus 4.8 be06b94754 register live GUI panes into clide pane list (T-219)
Per D-6 parity / D-83, make the kernel tabs the user sees (Claude,
Files, Editor, viewers) visible to the CLI. The PTY-backed PaneRegistry
can't model widget panes, so rather than mirror state (and risk drift),
pane.list snapshots the kernel PanelRegistry + LayoutArrangement at
request time via an injected view-pane source.

New Flutter-free ViewPane value type + snapshotViewPanes kernel bridge;
the daemonClientFactory now passes the PanelRegistry through so the
dispatcher can read it. pane.list merges PTY panes (source absent) with
UI tabs (source: ui, with slot/title/active/visible).

Acceptance (GUI-open: pane list enumerates live panes) needs a running
app to confirm end-to-end; unit-tested at the snapshot + dispatch level.

Closes T-219 (under T-218 / T-208 'Give Claude hands').

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-03 12:49:57 +02:00

34 lines
1.3 KiB
Dart

/// Snapshots the kernel's live tabs into [ViewPane]s so `pane list` reflects
/// the panes the user actually sees in the GUI (T-219, D-6 parity / D-83).
///
/// Read-at-request-time: no state is mirrored into the IPC [PaneRegistry], so
/// nothing can drift from the live UI. Lives in the kernel (not `lib/src/panes/`)
/// because it reads Flutter-coupled kernel state; it produces the Flutter-free
/// [ViewPane] the pane command serialises.
library;
import 'package:clide/kernel/src/panels/arrangement.dart';
import 'package:clide/kernel/src/panels/registry.dart';
import 'package:clide/src/panes/view_pane.dart';
/// Build a [ViewPane] for every tab in every slot the [panels] registry knows,
/// tagging the active tab per slot and whether its slot is currently visible
/// (read from [arrangement]).
List<ViewPane> snapshotViewPanes(PanelRegistry panels, LayoutArrangement arrangement) {
final out = <ViewPane>[];
for (final slot in panels.slots) {
final activeId = panels.activeTabIn(slot.id);
final visible = arrangement.isVisible(slot.id);
for (final tab in panels.tabsFor(slot.id)) {
out.add(ViewPane(
id: tab.id,
slot: slot.id.value,
title: tab.title,
active: tab.id == activeId,
visible: visible,
));
}
}
return out;
}