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>
This commit is contained in:
@@ -52,6 +52,7 @@ export 'src/panels/drag_resize.dart';
|
||||
export 'src/panels/layout_preset.dart';
|
||||
export 'src/panels/registry.dart';
|
||||
export 'src/panels/slot_id.dart';
|
||||
export 'src/panels/view_pane_snapshot.dart';
|
||||
export 'src/theme/contrast.dart';
|
||||
export 'src/theme/controller.dart';
|
||||
export 'src/theme/loader.dart';
|
||||
|
||||
@@ -115,7 +115,7 @@ class KernelServices {
|
||||
Locale? initialLocale,
|
||||
List<Locale> availableLocales = const [Locale('en', 'US')],
|
||||
String? socketPath,
|
||||
DaemonClient Function(Logger, DaemonBus, LayoutArrangement)? daemonClientFactory,
|
||||
DaemonClient Function(Logger, DaemonBus, LayoutArrangement, PanelRegistry)? daemonClientFactory,
|
||||
DaemonClient? isolateClient,
|
||||
bool autoStartDaemonClient = true,
|
||||
Toolchain? toolchain,
|
||||
@@ -176,7 +176,7 @@ class KernelServices {
|
||||
);
|
||||
final ipc = isolateClient ??
|
||||
(daemonClientFactory != null
|
||||
? daemonClientFactory(log, events, arrangement)
|
||||
? daemonClientFactory(log, events, arrangement, panels)
|
||||
: DaemonClient(
|
||||
// Legacy socket-client fallback — kept until T-127
|
||||
// replaces it with the in-process socket loopback.
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/// 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;
|
||||
}
|
||||
+16
-5
@@ -87,6 +87,7 @@ Future<void> main() async {
|
||||
DaemonClient? ipcClient;
|
||||
DaemonBus? daemonBus;
|
||||
LayoutArrangement? kernelArrangement;
|
||||
PanelRegistry? kernelPanels;
|
||||
// IPC socket server (T-99 / T-124, per D-70/71/72). One server per
|
||||
// workspace; restarted when the active project switches because the
|
||||
// socket path is workspace-derived. The local DaemonClient connects
|
||||
@@ -162,11 +163,19 @@ Future<void> main() async {
|
||||
Toolchain tc,
|
||||
Directory workRoot,
|
||||
LayoutArrangement arrangement,
|
||||
PanelRegistry panels,
|
||||
) {
|
||||
final dispatcher = DaemonDispatcher();
|
||||
final eventSink = _BusEventSink(events);
|
||||
final paneRegistry = PaneRegistry(events: eventSink);
|
||||
registerPaneCommands(dispatcher, paneRegistry);
|
||||
// D-6 parity (T-219, D-83): make the tabs the user sees in the GUI
|
||||
// visible to `pane list` by snapshotting the kernel PanelRegistry +
|
||||
// LayoutArrangement at request time — no mirrored state to drift.
|
||||
registerPaneCommands(
|
||||
dispatcher,
|
||||
paneRegistry,
|
||||
viewPanes: () => snapshotViewPanes(panels, arrangement),
|
||||
);
|
||||
// Trusted read-only roots beyond the workspace: the global Claude
|
||||
// config dir (~/.claude), so the reader can open user-scope skill /
|
||||
// agent / command markdown the Config tab surfaces (D-80, T-195).
|
||||
@@ -207,11 +216,12 @@ Future<void> main() async {
|
||||
toolchain: toolchain,
|
||||
daemonClientFactory: kIsWeb
|
||||
? null
|
||||
: (log, events, arrangement) {
|
||||
: (log, events, arrangement, panels) {
|
||||
daemonBus = events;
|
||||
kernelArrangement = arrangement;
|
||||
kernelPanels = panels;
|
||||
final workRoot = FilesService.atCwd(events: _BusEventSink(events)).root;
|
||||
final dispatcher = buildDispatcher(events, toolchain, workRoot, arrangement);
|
||||
final dispatcher = buildDispatcher(events, toolchain, workRoot, arrangement, panels);
|
||||
// Build the client at the workspace's socket path. The
|
||||
// server is started below (swapIpcServer) which the
|
||||
// client will then auto-connect to via its reconnect
|
||||
@@ -238,8 +248,9 @@ Future<void> main() async {
|
||||
: (path) async {
|
||||
final bus = daemonBus;
|
||||
final arrangement = kernelArrangement;
|
||||
if (bus == null || arrangement == null) return;
|
||||
final dispatcher = buildDispatcher(bus, toolchain, Directory(path), arrangement);
|
||||
final panels = kernelPanels;
|
||||
if (bus == null || arrangement == null || panels == null) return;
|
||||
final dispatcher = buildDispatcher(bus, toolchain, Directory(path), arrangement, panels);
|
||||
await swapIpcServer(dispatcher, Directory(path));
|
||||
},
|
||||
);
|
||||
|
||||
@@ -16,12 +16,19 @@ import '../ipc/errno_mapping.dart';
|
||||
import '../ipc/schema_v1.dart';
|
||||
import '../panes/pane.dart';
|
||||
import '../panes/registry.dart';
|
||||
import '../panes/view_pane.dart';
|
||||
import '../pty/errors.dart';
|
||||
import 'dispatcher.dart';
|
||||
|
||||
void registerPaneCommands(DaemonDispatcher d, PaneRegistry registry) {
|
||||
/// Snapshots the non-PTY panes the user sees in the GUI (kernel tabs) at
|
||||
/// request time — see [ViewPane]. Null in headless contexts (tests, the
|
||||
/// CLI-only path) where there is no live UI; then `pane.list` reports only
|
||||
/// PTY panes, exactly as before (T-219, D-6 parity / D-83).
|
||||
typedef ViewPaneSource = List<ViewPane> Function();
|
||||
|
||||
void registerPaneCommands(DaemonDispatcher d, PaneRegistry registry, {ViewPaneSource? viewPanes}) {
|
||||
d.register('pane.spawn', (req) => _spawn(req, registry));
|
||||
d.register('pane.list', (req) => _list(req, registry));
|
||||
d.register('pane.list', (req) => _list(req, registry, viewPanes));
|
||||
d.register('pane.close', (req) => _close(req, registry));
|
||||
d.register('pane.write', (req) => _write(req, registry));
|
||||
d.register('pane.resize', (req) => _resize(req, registry));
|
||||
@@ -118,11 +125,15 @@ Future<IpcResponse> _spawn(IpcRequest req, PaneRegistry registry) async {
|
||||
}
|
||||
}
|
||||
|
||||
Future<IpcResponse> _list(IpcRequest req, PaneRegistry registry) async {
|
||||
Future<IpcResponse> _list(IpcRequest req, PaneRegistry registry, ViewPaneSource? viewPanes) async {
|
||||
return IpcResponse.ok(
|
||||
id: req.id,
|
||||
data: {
|
||||
'panes': [for (final p in registry.panes) p.toJson()]
|
||||
'panes': [
|
||||
for (final p in registry.panes) p.toJson(),
|
||||
if (viewPanes != null)
|
||||
for (final v in viewPanes()) v.toJson(),
|
||||
]
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/// A non-PTY pane the user sees in the GUI — a kernel tab (Claude, Files,
|
||||
/// Editor, a viewer) surfaced so `pane list` reflects the live workspace,
|
||||
/// not only PTY-spawned panes (T-219, D-6 parity / D-83).
|
||||
///
|
||||
/// The PTY-backed [Pane] can't represent these: a tab has no child process.
|
||||
/// Rather than mirror state into [PaneRegistry] (and risk it drifting from
|
||||
/// the live UI), the kernel snapshots its `PanelRegistry` into these value
|
||||
/// objects at request time — `pane.list` reads them through an injected
|
||||
/// source. Pure data, Flutter-free, so it serialises on the IPC wire and
|
||||
/// stays usable from `dart test`.
|
||||
library;
|
||||
|
||||
class ViewPane {
|
||||
const ViewPane({
|
||||
required this.id,
|
||||
required this.slot,
|
||||
required this.title,
|
||||
required this.active,
|
||||
required this.visible,
|
||||
});
|
||||
|
||||
/// Stable contribution id (e.g. `claude`, `files`, `editor`) — the same id
|
||||
/// `pane.focus` would target.
|
||||
final String id;
|
||||
|
||||
/// The slot the tab lives in (`sidebar` / `workspace` / `context`).
|
||||
final String slot;
|
||||
|
||||
/// Display title the user sees on the tab.
|
||||
final String title;
|
||||
|
||||
/// Whether this is the active (front) tab in its slot — the focus state
|
||||
/// the acceptance asks for.
|
||||
final bool active;
|
||||
|
||||
/// Whether the tab's slot is currently visible (not collapsed/hidden).
|
||||
final bool visible;
|
||||
|
||||
Map<String, Object?> toJson() => {
|
||||
'id': id,
|
||||
'kind': 'view',
|
||||
'slot': slot,
|
||||
'title': title,
|
||||
'active': active,
|
||||
'visible': visible,
|
||||
'source': 'ui',
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user