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:
@@ -11,6 +11,7 @@ import 'dart:io';
|
||||
import 'package:clide/clide.dart';
|
||||
import 'package:clide/src/daemon/pane_commands.dart';
|
||||
import 'package:clide/src/panes/registry.dart';
|
||||
import 'package:clide/src/panes/view_pane.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
@@ -193,4 +194,53 @@ void main() {
|
||||
expect(unknown.error!.kind, 'not_found');
|
||||
});
|
||||
});
|
||||
|
||||
// T-219 / D-83: `pane list` reflects the GUI tabs the user sees, merged
|
||||
// with the PTY panes, via an injected view-pane source.
|
||||
group('pane.list view-pane merge (T-219)', () {
|
||||
late DaemonDispatcher dispatcher;
|
||||
late PaneRegistry registry;
|
||||
|
||||
setUp(() {
|
||||
registry = PaneRegistry(events: RecordingEventSink());
|
||||
dispatcher = DaemonDispatcher();
|
||||
registerPaneCommands(
|
||||
dispatcher,
|
||||
registry,
|
||||
viewPanes: () => const [
|
||||
ViewPane(id: 'claude', slot: 'workspace', title: 'Claude', active: true, visible: true),
|
||||
ViewPane(id: 'files', slot: 'sidebar', title: 'Files', active: false, visible: true),
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
tearDown(() => registry.shutdown());
|
||||
|
||||
Future<IpcResponse> call(String cmd, Map<String, Object?> args) => dispatcher.dispatch(IpcRequest(id: '1', cmd: cmd, args: args));
|
||||
|
||||
test('lists the live UI tabs with stable ids, slot, title, focus state', () async {
|
||||
final r = await call('pane.list', const {});
|
||||
final panes = (r.data['panes'] as List).cast<Map>();
|
||||
expect(panes, hasLength(2));
|
||||
final claude = panes.firstWhere((p) => p['id'] == 'claude');
|
||||
expect(claude['source'], 'ui');
|
||||
expect(claude['kind'], 'view');
|
||||
expect(claude['slot'], 'workspace');
|
||||
expect(claude['title'], 'Claude');
|
||||
expect(claude['active'], isTrue);
|
||||
expect(panes.firstWhere((p) => p['id'] == 'files')['active'], isFalse);
|
||||
});
|
||||
|
||||
test('merges PTY panes and UI tabs in one list', () async {
|
||||
await call('pane.spawn', {
|
||||
'argv': const ['/bin/cat']
|
||||
});
|
||||
final r = await call('pane.list', const {});
|
||||
final panes = (r.data['panes'] as List).cast<Map>();
|
||||
// one PTY pane (source absent) + two UI tabs (source: ui).
|
||||
expect(panes, hasLength(3));
|
||||
expect(panes.where((p) => p['source'] == 'ui'), hasLength(2));
|
||||
expect(panes.where((p) => p['id'].toString().startsWith('p_')), hasLength(1));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class KernelFixture {
|
||||
preloadNamespaces: preloadNamespaces ?? catalogs.keys.toList(),
|
||||
defaultLocale: defaultLocale,
|
||||
initialLocale: initialLocale,
|
||||
daemonClientFactory: (log, events, _) {
|
||||
daemonClientFactory: (log, events, _, __) {
|
||||
fake = FakeDaemonClient(log: log, events: events);
|
||||
return fake!;
|
||||
},
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/// Tests for [snapshotViewPanes] — the kernel→ViewPane bridge that lets
|
||||
/// `pane list` reflect the GUI tabs the user sees (T-219, D-83).
|
||||
library;
|
||||
|
||||
import 'package:clide/extension/extension.dart';
|
||||
import 'package:clide/kernel/kernel.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
TabContribution _tab(String id, SlotId slot) => TabContribution(
|
||||
id: id,
|
||||
slot: slot,
|
||||
title: id.toUpperCase(),
|
||||
build: (_) => const SizedBox.shrink(),
|
||||
);
|
||||
|
||||
void main() {
|
||||
group('snapshotViewPanes', () {
|
||||
late PanelRegistry panels;
|
||||
late LayoutArrangement arrangement;
|
||||
|
||||
setUp(() {
|
||||
panels = PanelRegistry();
|
||||
arrangement = LayoutArrangement();
|
||||
panels.registerSlot(const SlotDefinition(id: Slots.workspace, position: SlotPosition.center));
|
||||
panels.registerSlot(const SlotDefinition(id: Slots.sidebar, position: SlotPosition.left));
|
||||
});
|
||||
|
||||
test('one ViewPane per tab, tagged with slot, title and active state', () {
|
||||
panels.contribute(_tab('claude', Slots.workspace));
|
||||
panels.contribute(_tab('editor', Slots.workspace));
|
||||
panels.contribute(_tab('files', Slots.sidebar));
|
||||
|
||||
final panesById = {for (final v in snapshotViewPanes(panels, arrangement)) v.id: v};
|
||||
expect(panesById.keys, containsAll(['claude', 'editor', 'files']));
|
||||
expect(panesById['claude']!.slot, 'workspace');
|
||||
expect(panesById['claude']!.title, 'CLAUDE');
|
||||
// first tab in a slot is the active one
|
||||
expect(panesById['claude']!.active, isTrue);
|
||||
expect(panesById['editor']!.active, isFalse);
|
||||
expect(panesById['files']!.active, isTrue);
|
||||
});
|
||||
|
||||
test('active follows the kernel activeTab; visible follows the arrangement', () {
|
||||
arrangement.applyPreset(const LayoutPresetContribution(
|
||||
id: 'test',
|
||||
displayName: 'Test',
|
||||
slots: [LayoutSlot(slot: Slots.workspace, position: SlotPosition.center, visible: true)],
|
||||
));
|
||||
panels.contribute(_tab('claude', Slots.workspace));
|
||||
panels.contribute(_tab('editor', Slots.workspace));
|
||||
panels.activateTab(Slots.workspace, 'editor');
|
||||
|
||||
var panesById = {for (final v in snapshotViewPanes(panels, arrangement)) v.id: v};
|
||||
expect(panesById['editor']!.active, isTrue);
|
||||
expect(panesById['claude']!.active, isFalse);
|
||||
expect(panesById['editor']!.visible, isTrue);
|
||||
|
||||
// Hiding the slot is reflected on the next snapshot (read-at-request).
|
||||
arrangement.setVisible(Slots.workspace, false);
|
||||
panesById = {for (final v in snapshotViewPanes(panels, arrangement)) v.id: v};
|
||||
expect(panesById['editor']!.visible, isFalse);
|
||||
});
|
||||
|
||||
test('empty when no tabs are contributed', () {
|
||||
expect(snapshotViewPanes(panels, arrangement), isEmpty);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user