From 0a51add9586a26513b043dfce2b92cf497a77b12 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Fri, 13 Nov 2026 12:14:16 +0000 Subject: [PATCH 1/5] Add New chat to compact sidebar Expose the existing chat creation flow from the compact rail so users can start chats without expanding the session list. Add focused callback coverage and document the verified behavior. --- .../features/chat/chat_screen_workspace.dart | 6 +++++ app/lib/features/chat/screen.dart | 1 + .../ui/sessions/chat_compact_sidebar.dart | 3 +++ .../ui/sessions/chat_sessions_screen.dart | 7 ++++-- app/notes/chat-compact-new-chat.md | 23 +++++++++++++++++++ .../sessions/chat_state_legibility_test.dart | 2 ++ .../sessions/chat_visibility_marker_test.dart | 5 ++++ 7 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 app/notes/chat-compact-new-chat.md diff --git a/app/lib/features/chat/chat_screen_workspace.dart b/app/lib/features/chat/chat_screen_workspace.dart index 9e537bf4..accc1f5c 100644 --- a/app/lib/features/chat/chat_screen_workspace.dart +++ b/app/lib/features/chat/chat_screen_workspace.dart @@ -2,6 +2,8 @@ part of 'screen.dart'; /// Pane layout, focus and route publication for one Chat destination visit. mixin _ChatScreenWorkspace on State { + final _sessionsKey = GlobalKey(); + Map get _openedSessions; ChatComposerFocusRequests get _composerFocus; ChatPaneCommands get _paneCommands; @@ -46,6 +48,10 @@ mixin _ChatScreenWorkspace on State { activeSessionId: selected, visibleSessionIds: _visibleSidebarSessions, onOpen: _openSidebarSession, + onNewChat: () { + final state = _sessionsKey.currentState; + if (state != null) unawaited(state.newChat()); + }, onExpand: () => _setSidebarMode(ChatSidebarMode.expanded), ), ], diff --git a/app/lib/features/chat/screen.dart b/app/lib/features/chat/screen.dart index dadd1888..9f8d91d3 100644 --- a/app/lib/features/chat/screen.dart +++ b/app/lib/features/chat/screen.dart @@ -485,6 +485,7 @@ class _ChatScreenState extends State // The session list pads its first row by the bar's height itself, so it // scrolls behind the shell's floating bar like the other lists. final sessions = ChatSessionsScreen( + key: _sessionsKey, gateway: widget.gateway, embedded: true, syncToken: widget.syncToken, diff --git a/app/lib/features/chat/ui/sessions/chat_compact_sidebar.dart b/app/lib/features/chat/ui/sessions/chat_compact_sidebar.dart index 587e205c..0fcefb8b 100644 --- a/app/lib/features/chat/ui/sessions/chat_compact_sidebar.dart +++ b/app/lib/features/chat/ui/sessions/chat_compact_sidebar.dart @@ -23,6 +23,7 @@ class ChatCompactSidebar extends StatelessWidget { required this.activeSessionId, this.visibleSessionIds = const {}, required this.onOpen, + required this.onNewChat, required this.onExpand, this.navigation, }); @@ -31,6 +32,7 @@ class ChatCompactSidebar extends StatelessWidget { final String? activeSessionId; final Set visibleSessionIds; final ValueChanged onOpen; + final VoidCallback onNewChat; final VoidCallback onExpand; final Widget? navigation; static const width = 72.0; @@ -135,6 +137,7 @@ class ChatCompactSidebar extends StatelessWidget { width: width, child: Column( children: [ + _button(context, 'New chat', const Icon(Icons.add), onNewChat), _button( context, 'Expand chat list', diff --git a/app/lib/features/chat/ui/sessions/chat_sessions_screen.dart b/app/lib/features/chat/ui/sessions/chat_sessions_screen.dart index d789d670..3238a49f 100644 --- a/app/lib/features/chat/ui/sessions/chat_sessions_screen.dart +++ b/app/lib/features/chat/ui/sessions/chat_sessions_screen.dart @@ -98,10 +98,10 @@ class ChatSessionsScreen extends StatefulWidget { final ChatSectionFolds? folds; @override - State createState() => _ChatSessionsScreenState(); + ChatSessionsScreenState createState() => ChatSessionsScreenState(); } -class _ChatSessionsScreenState extends State { +class ChatSessionsScreenState extends State { late final ChatSessionsController _controller = (widget.controller ?? ChatSessionsController( @@ -233,6 +233,9 @@ class _ChatSessionsScreenState extends State { if (session != null && mounted) widget.onOpen(session); } + /// Starts the same machine picker and create dialog used by the list action. + Future newChat() => _newChat(); + void _markOpened(JsonMap session) => unawaited(_controller.markOpened(session)); diff --git a/app/notes/chat-compact-new-chat.md b/app/notes/chat-compact-new-chat.md new file mode 100644 index 00000000..54f0f0ea --- /dev/null +++ b/app/notes/chat-compact-new-chat.md @@ -0,0 +1,23 @@ +# Compact sidebar New chat + +The compact chat rail now keeps a Material `+` action above its scrolling +session list. Its callback reaches the mounted `ChatSessionsScreenState` and +invokes the existing `_newChat` flow, so machine selection, harness discovery, +and the create dialog remain shared with the expanded list action. + +## Regression coverage + +- `test/features/chat/ui/sessions/chat_visibility_marker_test.dart`: the rail + exposes the `New chat` tooltip and invokes its callback. +- `test/features/chat/ui/sessions/chat_machine_creation_test.dart`: the + existing expanded-list flow still selects a machine before harness discovery. +- `test/features/chat/ui/sessions/chat_sessions_floating_bar_test.dart`: the + expanded list still has exactly one New chat action in its bar. + +## Verification + +- `tool/memwatch/full.sh 'test/features/chat/ui/sessions/chat_visibility_marker_test.dart test/features/chat/ui/sessions/chat_state_legibility_test.dart test/features/chat/ui/sessions/chat_machine_creation_test.dart test/features/chat/ui/sessions/chat_sessions_floating_bar_test.dart'`: 10 passed. +- `tool/analyze.sh`: clean. +- Browser captures: desktop 1600x1000 compact rail in light and dark themes, + including the New chat tooltip, are in the shared artifact + `public/chat-compact-sidebar/`. diff --git a/app/test/features/chat/ui/sessions/chat_state_legibility_test.dart b/app/test/features/chat/ui/sessions/chat_state_legibility_test.dart index d6855d17..6540c66c 100644 --- a/app/test/features/chat/ui/sessions/chat_state_legibility_test.dart +++ b/app/test/features/chat/ui/sessions/chat_state_legibility_test.dart @@ -85,6 +85,7 @@ void main() { activeSessionId: null, visibleSessionIds: const {'a'}, onOpen: (_) {}, + onNewChat: () {}, onExpand: () {}, navigation: const Text('Destinations'), ), @@ -139,6 +140,7 @@ void main() { activeSessionId: 'a', visibleSessionIds: const {'a', 'b'}, onOpen: (_) {}, + onNewChat: () {}, onExpand: () {}, ), ), diff --git a/app/test/features/chat/ui/sessions/chat_visibility_marker_test.dart b/app/test/features/chat/ui/sessions/chat_visibility_marker_test.dart index 7642e111..ab8b569b 100644 --- a/app/test/features/chat/ui/sessions/chat_visibility_marker_test.dart +++ b/app/test/features/chat/ui/sessions/chat_visibility_marker_test.dart @@ -107,6 +107,7 @@ void main() { await controller.refresh(); final folds = ChatSectionFolds(); addTearDown(folds.dispose); + var newChatPressed = false; await tester.pumpWidget( MaterialApp( home: Scaffold( @@ -116,12 +117,16 @@ void main() { activeSessionId: 'a', visibleSessionIds: const {'a', 'b'}, onOpen: (_) {}, + onNewChat: () => newChatPressed = true, onExpand: () {}, ), ), ), ); await tester.pumpAndSettle(); + expect(find.byTooltip('New chat'), findsOneWidget); + await tester.tap(find.byTooltip('New chat')); + expect(newChatPressed, isTrue); expect(find.byTooltip('Expand chat list'), findsOneWidget); expect(edge(tester, 'a').width, 10); expect(edge(tester, 'b').width, 3); From b4d67d6ba801daec51938c11bfa497834152055a Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Fri, 13 Nov 2026 12:23:52 +0000 Subject: [PATCH 2/5] Cycle Ctrl-Tab through available chats When a tiled workspace has one chat pane, navigate the sidebar chat order while preserving pane state and composer focus. Keep pane and floating-window cycling behavior for their existing layouts, and update shortcut documentation and coverage. --- .../features/chat/chat_screen_workspace.dart | 58 ++++++++++++++---- .../workspace/chat_workspace_controller.dart | 17 ++++++ .../settings/keyboard_shortcuts_registry.dart | 4 +- app/notes/chat-floating-pane.md | 48 ++++++++------- .../features/chat/chat_control_tab_test.dart | 59 +++++++++++++++---- .../chat/chat_floating_pane_test.dart | 18 +++--- .../chat/chat_keyboard_focus_test.dart | 29 ++++----- .../keyboard_shortcuts_cheatsheet_test.dart | 2 +- 8 files changed, 158 insertions(+), 77 deletions(-) diff --git a/app/lib/features/chat/chat_screen_workspace.dart b/app/lib/features/chat/chat_screen_workspace.dart index 9e537bf4..827051fd 100644 --- a/app/lib/features/chat/chat_screen_workspace.dart +++ b/app/lib/features/chat/chat_screen_workspace.dart @@ -278,14 +278,12 @@ mixin _ChatScreenWorkspace on State { String? _publishedWorkspaceSession; String _workspaceSignature = ''; - /// Ctrl+Tab cycles the floating chat windows while any is shown, from the - /// tiling as well (see [ChatWindows]). With none shown it cycles the - /// retained panes, even when the sidebar or toolbar owns focus, and over a - /// single pane it does nothing: it never brings up a chat that is not - /// visible in the tiling. Command+Tab stays with the operating system's - /// application switcher. While the app's terminal is shown, Ctrl+Tab moves - /// between its tabs instead. A floating window that is not a chat, or any - /// other window holding the keyboard, keeps the key. + /// Ctrl+Tab cycles a single tiled pane through the open chats in sidebar + /// order. The pane is replaced in place so its retained view keeps the + /// transcript and draft. With multiple panes it cycles those panes. A + /// focused floating chat window handles the key itself (see [ChatWindows]). + /// Command+Tab stays with the operating system's application switcher, and + /// the terminal keeps Ctrl+Tab for its own tabs. bool _cycleChatKey(KeyEvent event) { final keyboard = HardwareKeyboard.instance; if (event is! KeyDownEvent || @@ -298,8 +296,48 @@ mixin _ChatScreenWorkspace on State { !_chatOwnsKeyboard()) { return false; } - if (widget.windows?.raiseTopFromTiling() ?? false) return true; - if (!_workspaceVisible || _workspace.paneCount < 2) return false; + if (!_workspaceVisible || _workspace.paneCount == 0) return false; + if (_workspace.paneCount == 1) { + final pane = _workspace.activePane; + if (pane == null) return false; + final floating = widget.windows?.floatingSessionIds.toSet() ?? const {}; + final sessions = chatSessionsShown( + _sessionsForSidebar.sessions + .where( + (row) => + row['closed_at'] == null && + row['closed'] != true && + !floating.contains('${row['id'] ?? ''}'), + ) + .toList(), + query: '', + // Cycling is independent of a collapsed section: the sidebar's + // ordering is still used, but every open-chat row remains reachable. + isOpen: (_) => true, + ); + final active = sessions.indexWhere( + (row) => '${row['id'] ?? ''}' == pane.sessionId, + ); + if (sessions.length < 2 || active < 0) return false; + final direction = keyboard.isShiftPressed ? -1 : 1; + final target = sessions[(active + direction) % sessions.length]; + final targetId = '${target['id'] ?? ''}'; + if (targetId.isEmpty) return false; + _workspace.replacePaneSession(pane.id, targetId); + WidgetsBinding.instance.addPostFrameCallback((_) { + if (!mounted || + !_workspaceVisible || + _workspace.activePane?.sessionId != targetId) { + return; + } + final destination = ShellBarScope.maybeOf(context)?.registry.focus; + if (destination == null || destination == AppDestination.chat) { + _composerFocus.request(targetId); + } + }); + WidgetsBinding.instance.ensureVisualUpdate(); + return true; + } final panes = _workspace.panes; final active = panes.indexWhere( (pane) => pane.id == _workspace.activePaneId, diff --git a/app/lib/features/chat/workspace/chat_workspace_controller.dart b/app/lib/features/chat/workspace/chat_workspace_controller.dart index fdc825a5..0d197866 100644 --- a/app/lib/features/chat/workspace/chat_workspace_controller.dart +++ b/app/lib/features/chat/workspace/chat_workspace_controller.dart @@ -237,6 +237,23 @@ class ChatWorkspaceController extends ChangeNotifier { _changed(); } + /// Replaces a pane after its caller has already validated [newId]. Unlike + /// [replaceSession], this does not ask the window host to show a floating + /// chat; keyboard cycling filters those chats before calling this method. + void replacePaneSession(String paneId, String newId) { + if (newId.isEmpty) return; + final pane = panes.where((p) => p.id == paneId).firstOrNull; + if (pane == null) return; + final existing = panes.where((p) => p.sessionId == newId).firstOrNull; + if (existing != null) { + close(pane.id); + activate(existing.id); + return; + } + _root = _replace(_root!, pane.id, ChatWorkspacePane(pane.id, newId)); + _changed(); + } + ChatWorkspaceNode _replace( ChatWorkspaceNode node, String id, diff --git a/app/lib/features/settings/keyboard_shortcuts_registry.dart b/app/lib/features/settings/keyboard_shortcuts_registry.dart index 4f2014b3..e2d50aad 100644 --- a/app/lib/features/settings/keyboard_shortcuts_registry.dart +++ b/app/lib/features/settings/keyboard_shortcuts_registry.dart @@ -156,10 +156,10 @@ class KeyboardShortcutRegistry { if (!web) const KeyboardShortcutEntry( group: KeyboardShortcutGroup.chat, - action: 'Cycle chat panes and floating chats', + action: 'Cycle chats and floating chat panes', keys: 'Ctrl+Tab, Ctrl+Shift+Tab', caveat: - 'While the terminal is shown, Ctrl+Tab moves between its tabs instead.', + 'With one tiled pane, cycles open sidebar chats (excluding closed, hidden and floating chats); with multiple panes, cycles panes. While the terminal is shown, Ctrl+Tab moves between its tabs instead.', ), const KeyboardShortcutEntry( group: KeyboardShortcutGroup.chat, diff --git a/app/notes/chat-floating-pane.md b/app/notes/chat-floating-pane.md index 684f0da1..075fcdcb 100644 --- a/app/notes/chat-floating-pane.md +++ b/app/notes/chat-floating-pane.md @@ -41,10 +41,11 @@ every destination and come back at app start without Chat being opened. takes the keyboard. Open order is the order the windows were opened (a restored window keeps its saved place), so a raise does not change the cycle; the stacking order does change on a raise. - - **With no chat window shown**, Ctrl+Tab cycles the tiled panes only and - the keys focus the chosen pane's composer. With one tiled pane it does - nothing. A chat shown before, or a minimised or floating chat, is never - swapped in. + - **With no chat window focused**, Ctrl+Tab cycles the tiled panes and the + keys focus the chosen pane's composer. With exactly one tiled pane it + cycles all open chats in sidebar order, replacing that pane while keeping + its transcript and draft; closed, hidden-on-this-device and floating + chats are skipped. With two or more panes it cycles the panes only. - Command+Tab stays with the system. While the terminal claims tab keys (shown) Ctrl+Tab switches terminal tabs. A keyboard held by another window (a run, terminal) is left to that window. Alt+` (`windowCycleShortcut`) @@ -80,36 +81,33 @@ every destination and come back at app start without Chat being opened. ## Checks -- Focused, 2026-11-12, `tool/memwatch/full.sh` over +- Focused, 2026-11-13, `tool/memwatch/full.sh` over `test/features/chat/chat_floating_pane_test.dart`, `test/features/chat/chat_keyboard_focus_test.dart`, `test/features/chat/chat_control_tab_test.dart`, - `test/features/chat/windows/chat_windows_test.dart` and - `test/features/terminal/terminal_chat_tab_test.dart`: 38 passed, 0 failed. - Related Ctrl+Tab users, `tool/memwatch/full.sh` over + `test/features/chat/windows/chat_windows_test.dart`, + `test/features/terminal/terminal_chat_tab_test.dart`, the keyboard + shortcuts registry test and related Ctrl+Tab users: 70 passed, 0 failed. + This included `tool/memwatch/full.sh` over `test/shell/destination_shortcuts_test.dart`, `test/shell/tab_history_back_test.dart`, `test/shell/search_escape_test.dart` and `test/features/chat/shell/chat_shell_terminal_test.dart`: 26 passed, 0 failed. -- New in the first file: Ctrl+Tab and Ctrl+Shift+Tab over three floating chats - cycle in open order, not stacking order (order, wrap, composer focus, - Command+Tab ignored). With the tiling focused Ctrl+Tab goes to the top-most - shown window and leaves the panes alone; with one shown window it does - nothing; with the window minimised the panes cycle and the window stays - hidden. With one tiled pane and a minimised chat, Ctrl+Tab does nothing and - shows nothing. A terminal that claims tab keys keeps Ctrl+Tab over a focused - chat window. -- Removed: the single-pane recent-chat swap (the chat shown before, opened - back into the pane), with its tests in `chat_keyboard_focus_test.dart`. A - single pane with no shown window now does nothing on Ctrl+Tab, so - `chat_control_tab_test.dart` no longer expects the composer to take focus - from the sidebar. +- Floating-window Ctrl+Tab and Ctrl+Shift+Tab over three floating chats cycle + in open order, not stacking order (order, wrap, composer focus, Command+Tab + ignored). With the tiling focused, a single tiled pane cycles the open, + device-visible sidebar chats and skips closed, hidden and floating chats; + multiple tiled panes cycle panes. A terminal that claims tab keys keeps + Ctrl+Tab over a focused chat window. +- Changed: a single tiled pane now cycles the open, device-visible sidebar + chats in list order, skips closed, hidden-on-this-device and floating chats, + wraps in both directions, and focuses the replacement composer. Multiple + panes and focused floating windows retain their existing cycles. - `tool/analyze.sh` on `lib/features/chat` and the three chat test files: clean. -- Affected states: two or more floating chats; one floating chat shown; - floating chat minimised with one tiled pane; tiling focused with windows - shown and with none; a window focused; the terminal shown (claimed); - Command+Tab. +- Affected states: a single tiled pane with open chats; shown or minimised + floating chats; two or more tiled panes; a focused floating window; the + terminal shown (claimed); Command+Tab. - Not covered: the terminal's own tab switching (the test app has no terminal surface), real browser or device keys, and captures (ui-review's). - Observed, not changed: in the widget harness, floating from a pane's More diff --git a/app/test/features/chat/chat_control_tab_test.dart b/app/test/features/chat/chat_control_tab_test.dart index 2c110416..e81c2d1e 100644 --- a/app/test/features/chat/chat_control_tab_test.dart +++ b/app/test/features/chat/chat_control_tab_test.dart @@ -12,12 +12,17 @@ import 'package:pipelines_app/shell/destination.dart'; import 'conversation/chat_thread_fixtures.dart'; class _Gateway extends FakeChatGateway { + _Gateway({this.rows = const ['a', 'b', 'c']}); + + final List rows; + @override Future call(String type, [JsonMap fields = const {}]) { if (type == 'chat_sessions') { return Future.value({ 'chat_sessions': [ - for (final id in ['a', 'b', 'c']) {'id': id, 'title': 'Chat $id'}, + for (final id in rows) + {'id': id, 'title': 'Chat $id', if (id == 'closed') 'closed_at': 1}, ], }); } @@ -57,12 +62,16 @@ Future _chord( await tester.pumpAndSettle(); } -Future _setup(WidgetTester tester, {bool open = true}) async { +Future _setup( + WidgetTester tester, { + bool open = true, + List rows = const ['a', 'b', 'c'], +}) async { SharedPreferences.setMockInitialValues({}); tester.view.physicalSize = const Size(1800, 1000); tester.view.devicePixelRatio = 1; addTearDown(tester.view.reset); - final gateway = _Gateway()..history = (_) async => chatPage([]); + final gateway = _Gateway(rows: rows)..history = (_) async => chatPage([]); addTearDown(gateway.close); await tester.pumpWidget( MaterialApp( @@ -133,20 +142,44 @@ void main() { await tester.pumpWidget(const SizedBox.shrink()); }); - testWidgets('single pane with no shown window does nothing; empty workspace ' - 'does not consume', (tester) async { - await _setup(tester, open: false); - await _chord(tester); - expect(find.byType(ChatWorkspace), findsNothing); + testWidgets( + 'single pane cycles list chats; empty workspace does not consume', + (tester) async { + await _setup(tester, open: false); + await _chord(tester); + expect(find.byType(ChatWorkspace), findsNothing); + await tester.tap(find.byKey(const Key('chat-row-a'))); + await tester.pumpAndSettle(); + _focusSidebar(tester); + await tester.pumpAndSettle(); + await _chord(tester); + expect(find.byType(ChatWorkspace), findsOneWidget); + expect(_workspace(tester).paneCount, 1); + expect(_workspace(tester).activePane?.sessionId, 'b'); + expect(_editable(tester, 'b').focusNode.hasPrimaryFocus, isTrue); + await tester.pumpWidget(const SizedBox.shrink()); + }, + ); + + testWidgets('single pane skips closed and hidden-on-this-device chats', ( + tester, + ) async { + await _setup(tester, open: false, rows: ['a', 'hidden', 'c', 'closed']); + await tester.tap(_actions('hidden')); + await tester.pumpAndSettle(); + await tester.tap(find.text('Hide on this device')); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('chat-row-a'))); await tester.pumpAndSettle(); _focusSidebar(tester); - await tester.pumpAndSettle(); await _chord(tester); - expect(find.byType(ChatWorkspace), findsOneWidget); - expect(_workspace(tester).paneCount, 1); - expect(_editable(tester, 'a').focusNode.hasPrimaryFocus, isFalse); - expect(_editable(tester, 'a').controller.text, isEmpty); + expect(_workspace(tester).activePane?.sessionId, 'c'); + await _chord(tester); + expect(_workspace(tester).activePane?.sessionId, 'a'); + + await _chord(tester, reverse: true); + expect(_workspace(tester).activePane?.sessionId, 'c'); await tester.pumpWidget(const SizedBox.shrink()); }); diff --git a/app/test/features/chat/chat_floating_pane_test.dart b/app/test/features/chat/chat_floating_pane_test.dart index 3be68061..971465fc 100644 --- a/app/test/features/chat/chat_floating_pane_test.dart +++ b/app/test/features/chat/chat_floating_pane_test.dart @@ -592,10 +592,8 @@ void main() { await app.stop(tester); }); - testWidgets('with the tiling focused Ctrl+Tab goes to the top-most shown ' - 'window, and cycles the panes only when no window is shown', ( - tester, - ) async { + testWidgets('with the tiling focused Ctrl+Tab cycles the single pane chat ' + 'list and cycles panes when there are multiple panes', (tester) async { await _saved('a', 'b', 'c'); final app = _App(_Store()); await app.start(tester); @@ -603,20 +601,20 @@ void main() { expect(app.floating, ['c']); final controller = _workspace(tester); - // A window is shown: from the tiling, Ctrl+Tab takes the keyboard to it - // and the panes stay where they are. + // A shown floating chat is skipped while the single tiled pane cycles the + // remaining open chats. await tester.tapAt(tester.getCenter(_input('a'))); await tester.pump(); expect(controller.activePane?.sessionId, 'a'); await _tab(tester); - expect(controller.activePane?.sessionId, 'a'); - expect(_composerFocused(tester, 'c'), isTrue); + expect(controller.activePane?.sessionId, 'b'); + expect(_composerFocused(tester, 'b'), isTrue); expect(app.floating, ['c']); - // A single shown window has nothing to cycle to. + // It wraps back to the other non-floating chat. await _tab(tester); expect(controller.activePane?.sessionId, 'a'); - expect(_composerFocused(tester, 'c'), isTrue); + expect(_composerFocused(tester, 'a'), isTrue); expect(app.floating, ['c']); // No window shown: the panes cycle and the hidden window stays hidden. diff --git a/app/test/features/chat/chat_keyboard_focus_test.dart b/app/test/features/chat/chat_keyboard_focus_test.dart index 653f42d5..6a8a3ef0 100644 --- a/app/test/features/chat/chat_keyboard_focus_test.dart +++ b/app/test/features/chat/chat_keyboard_focus_test.dart @@ -150,28 +150,25 @@ void main() { await tester.pumpWidget(const SizedBox.shrink()); }); - testWidgets('Control Tab over one pane does nothing: it never brings up ' - 'another chat', (tester) async { + testWidgets('Control Tab over one pane cycles the sidebar chats in both ' + 'directions', (tester) async { await _setup(tester); await _openRow(tester, 'a'); final workspace = _workspace(tester); - await _controlTab(tester); - expect(workspace.activePane?.sessionId, 'a'); - expect(_editable(tester, 'a').focusNode.hasPrimaryFocus, isFalse); - - // Opening b replaces the lone pane; a is no longer shown anywhere. - await _openRow(tester, 'b'); - await tester.enterText(_input('b'), 'Draft B'); await _focusSidebar(tester); - for (final shift in [false, true]) { - await _controlTab(tester, shift: shift); - expect(workspace.paneCount, 1); - expect(workspace.activePane?.sessionId, 'b'); - expect(_editable(tester, 'b').focusNode.hasPrimaryFocus, isFalse); - expect(_editable(tester, 'b').controller.text, 'Draft B'); + for (final id in ['b', 'c', 'a']) { + await _controlTab(tester); + expect(workspace.activePane?.sessionId, id); + expect(_editable(tester, id).focusNode.hasPrimaryFocus, isTrue); + } + await _focusSidebar(tester); + for (final id in ['c', 'b', 'a']) { + await _controlTab(tester, shift: true); + expect(workspace.activePane?.sessionId, id); + expect(_editable(tester, id).focusNode.hasPrimaryFocus, isTrue); } - // Two panes cycle the panes, not the history. + // Two panes still cycle panes, not the chat list. await _openRow(tester, 'c'); await tester.tap(_actions('a')); await tester.pumpAndSettle(); diff --git a/app/test/features/settings/keyboard_shortcuts_cheatsheet_test.dart b/app/test/features/settings/keyboard_shortcuts_cheatsheet_test.dart index 7456edfc..cddb5df7 100644 --- a/app/test/features/settings/keyboard_shortcuts_cheatsheet_test.dart +++ b/app/test/features/settings/keyboard_shortcuts_cheatsheet_test.dart @@ -18,7 +18,7 @@ const _implemented = [ 'Stop a running chat', 'Focus the neighbouring chat pane', 'Move the active chat pane', - 'Cycle chat panes and floating chats', + 'Cycle chats and floating chat panes', 'Resize panes with a focused divider', 'Scroll a wide transcript block', 'Show or hide floating chats', From e5403ae257bf0c3fbf332fcc0608f81511f054f0 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Fri, 13 Nov 2026 12:38:27 +0000 Subject: [PATCH 3/5] Open a run or pipeline in a new chat The run and pipeline More menus offer Open in chat: a new chat in the run's (or the pipeline's latest run's) workspace opens on the Chat tab with a draft naming the run or pipeline and how to inspect or change it. --- app/lib/application/open_in_chat.dart | 74 +++++ app/lib/application/pipelines_app.dart | 66 +++- .../application/pipelines_destination.dart | 9 + app/lib/application/runs_destination.dart | 4 + app/lib/features/chat/chat_pane_content.dart | 1 + app/lib/features/chat/chat_runtime.dart | 4 + .../chat/conversation/chat_thread_view.dart | 7 + .../features/pipelines/pipeline_models.dart | 3 + app/lib/features/pipelines/screen.dart | 17 +- .../widgets/pipeline_archive_action.dart | 29 +- .../widgets/pipeline_detail_panel.dart | 16 +- .../widgets/pipeline_list_panel.dart | 25 +- app/lib/features/runs/screen.dart | 4 + app/lib/features/runs/ui/run_detail_view.dart | 3 + app/lib/features/runs/ui/run_list_row.dart | 9 +- app/lib/features/runs/ui/run_more_menu.dart | 23 +- app/lib/features/runs/ui/runs_list.dart | 6 +- app/notes/open-in-chat.md | 21 ++ app/test/application/open_in_chat_test.dart | 296 ++++++++++++++++++ app/tool/search_selection_probe_entry.dart | 78 +++++ 20 files changed, 680 insertions(+), 15 deletions(-) create mode 100644 app/lib/application/open_in_chat.dart create mode 100644 app/notes/open-in-chat.md create mode 100644 app/test/application/open_in_chat_test.dart diff --git a/app/lib/application/open_in_chat.dart b/app/lib/application/open_in_chat.dart new file mode 100644 index 00000000..5d82c846 --- /dev/null +++ b/app/lib/application/open_in_chat.dart @@ -0,0 +1,74 @@ +import 'package:flutter/material.dart'; + +import '../core/api_gateway.dart'; +import '../features/chat/chat_runtime.dart'; +import '../features/chat/ui/sessions/chat_create_fields.dart'; +import '../features/settings/settings_store.dart'; + +typedef OpenInChat = Future Function(BuildContext context); + +String runChatReference(JsonMap run) { + final id = run['id']; + // A run summary names its pipeline in `name`; `title` is the run's own + // title, empty for an untitled run. + final title = '${run['title'] ?? ''}'.trim(); + final pipeline = + '${run['pipeline_name'] ?? run['pipeline'] ?? run['name'] ?? ''}'.trim(); + final version = '${run['pipeline_version'] ?? run['version'] ?? ''}'.trim(); + final status = '${run['status'] ?? ''}'.trim(); + return 'About Pipelines run #$id "${title.isEmpty ? 'Run $id' : title}" ' + '(pipeline "${pipeline.isEmpty ? 'unknown' : pipeline}" ' + 'v${version.isEmpty ? '?' : version}, status $status). ' + 'Inspect it with `pipelines inspect $id`.'; +} + +String pipelineChatReference(int id, String name, int version) => + 'About pipeline "$name" (id $id, version $version). ' + 'Show it with `pipelines show "$name"`; to change it, draft with ' + '`pipelines edit` and publish with `pipelines submit`.'; + +/// Creates and opens a chat without showing the general-purpose create dialog. +/// The caller supplies the already-resolved directory so run and pipeline +/// screens can apply their own workspace provenance rules. +Future openReferenceInChat({ + required BuildContext context, + required ChatRuntime runtime, + required ValueChanged selectChat, + required String directory, + required String title, + required String draft, +}) async { + try { + // Match the New chat dialog: prefer OpenCode when it is available, but + // use the first server-advertised harness on installations where it is + // not. Do not invent a backend when the catalog cannot be read. + final backends = await runtime.sessions.repository.backends(); + final backend = backends.contains('opencode') ? 'opencode' : backends.first; + final session = await runtime.sessions.createOrThrow( + title: title, + directory: directory.trim().isEmpty ? chatHomeDirectory : directory, + backend: backend, + instructions: '', + operationId: 'open-in-chat-${DateTime.now().microsecondsSinceEpoch}', + ); + final id = '${session['id'] ?? ''}'; + if (id.isEmpty) throw StateError('The new chat has no id.'); + runtime.opened[id] = session; + runtime.pendingDrafts[id] = draft; + selectChat(id); + runtime.composerFocus.request(id); + } catch (error) { + if (context.mounted) { + ScaffoldMessenger.of( + context, + ).showSnackBar(SnackBar(content: Text('Could not open in chat: $error'))); + } + } +} + +Future settingsWorkspace(String serverId) async { + final values = await SharedPreferencesSettingsStore( + serverId: serverId, + ).load(); + return values.workspace.trim(); +} diff --git a/app/lib/application/pipelines_app.dart b/app/lib/application/pipelines_app.dart index 9be09ded..0dc0f545 100644 --- a/app/lib/application/pipelines_app.dart +++ b/app/lib/application/pipelines_app.dart @@ -7,7 +7,7 @@ import '../features/runs/domain/run_tab_counts.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/scheduler.dart'; -import 'package:flutter/widgets.dart'; +import 'package:flutter/material.dart'; import '../core/api_gateway.dart'; import '../core/servers/server_scope.dart'; @@ -48,6 +48,8 @@ import '../shell/windows/window_store.dart'; import 'app_terminals.dart'; import '../features/chat/chat_runtime.dart'; import '../features/chat/windows/chat_windows.dart'; +import 'open_in_chat.dart'; +import '../features/pipelines/pipeline_models.dart'; import '../features/chat/workspace/chat_float_store.dart'; import '../features/terminal/terminal_layout.dart'; import 'app_route.dart'; @@ -144,6 +146,63 @@ class PipelinesApp extends StatefulWidget { class _PipelinesAppState extends State with WidgetsBindingObserver { + Future _openRunInChat(BuildContext context, JsonMap run) async { + try { + final directory = '${run['workspace'] ?? run['directory'] ?? ''}'.trim(); + final fallback = directory.isEmpty + ? await settingsWorkspace(serverIdentity(_session.gateway) ?? '') + : directory; + if (!context.mounted) return; + await openReferenceInChat( + context: context, + runtime: _chatRuntime, + selectChat: (id) => _delegate.goTo(AppRoute.chatSession(id)), + directory: fallback, + title: + 'Run #${run['id']}: ${'${run['title'] ?? run['name'] ?? ''}'.trim()}', + draft: runChatReference(run), + ); + } catch (error) { + if (context.mounted) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('Could not open in chat: $error')), + ); + } + } + } + + Future _openPipelineInChat( + BuildContext context, + PipelineSummary pipeline, + PipelineRun? latestRun, + ) async { + try { + final directory = latestRun?.workspace.trim() ?? ''; + final fallback = directory.isEmpty + ? await settingsWorkspace(serverIdentity(_session.gateway) ?? '') + : directory; + if (!context.mounted) return; + await openReferenceInChat( + context: context, + runtime: _chatRuntime, + selectChat: (id) => _delegate.goTo(AppRoute.chatSession(id)), + directory: fallback, + title: 'Pipeline: ${pipeline.displayName}', + draft: pipelineChatReference( + pipeline.id, + pipeline.displayName, + pipeline.version, + ), + ); + } catch (error) { + if (context.mounted) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('Could not open in chat: $error')), + ); + } + } + } + late final AppSession _session; late final AppRouterDelegate _delegate; late final ElevationPrompt _elevationPrompt = elevationDialogPrompt( @@ -941,6 +1000,10 @@ class _PipelinesAppState extends State _delegate.goTo(AppRoute.runsForPipeline(id)), onOpenSchedules: _delegate.openSchedules, onOpenSettings: () => _delegate.goTo(AppRoute.settings), + onOpenInChat: (context, detail, run) => + _openPipelineInChat(context, detail, run), + onOpenPipelineInChat: (context, summary, run) => + _openPipelineInChat(context, summary, run), // The open pipeline is part of the route, so Back steps out of it. onSelectionChanged: (id) { final current = _delegate.route; @@ -983,6 +1046,7 @@ class _PipelinesAppState extends State ), onOpenPipeline: (id, version) => _delegate.goTo(AppRoute.pipeline(id, version: version)), + onOpenInChat: _openRunInChat, ), ), AppDestination.chat: (_) => ChatDestination( diff --git a/app/lib/application/pipelines_destination.dart b/app/lib/application/pipelines_destination.dart index 52dc3774..004c5777 100644 --- a/app/lib/application/pipelines_destination.dart +++ b/app/lib/application/pipelines_destination.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import '../features/pipelines/screen.dart'; +import '../features/pipelines/pipeline_models.dart'; import '../ui/adaptive/top_bar_notices.dart'; import 'app_session.dart'; import 'connection_status.dart'; @@ -29,6 +30,8 @@ class PipelinesDestination extends StatelessWidget { this.initialVersion = 0, this.initialStageKey, this.legacyPendingEndpoints = const [], + this.onOpenInChat, + this.onOpenPipelineInChat, }); final AppSession session; @@ -58,6 +61,10 @@ class PipelinesDestination extends StatelessWidget { /// The definition stage a deep link names, or null for no stage request. final String? initialStageKey; final List legacyPendingEndpoints; + final Future Function(BuildContext, PipelineDetail, PipelineRun?)? + onOpenInChat; + final Future Function(BuildContext, PipelineSummary, PipelineRun?)? + onOpenPipelineInChat; @override Widget build(BuildContext context) => AnimatedBuilder( @@ -91,6 +98,8 @@ class PipelinesDestination extends StatelessWidget { onOpenSchedules: onOpenSchedules, onOpenSettings: onOpenSettings, onSelectionChanged: onSelectionChanged, + onOpenInChat: onOpenInChat, + onOpenPipelineInChat: onOpenPipelineInChat, initialPipelineId: initialPipelineId, initialVersion: initialVersion, initialStageKey: initialStageKey, diff --git a/app/lib/application/runs_destination.dart b/app/lib/application/runs_destination.dart index afde6946..a66271c2 100644 --- a/app/lib/application/runs_destination.dart +++ b/app/lib/application/runs_destination.dart @@ -10,6 +10,7 @@ import 'app_session.dart'; import 'connection_status.dart'; import 'pending_run_scope.dart'; import 'server_endpoint.dart'; +import '../core/api_gateway.dart'; /// The Runs destination: the loaded screen plus an honest connection status. /// @@ -34,6 +35,7 @@ class RunsDestination extends StatelessWidget { this.listRefreshToken = 0, this.notifications, this.attention, + this.onOpenInChat, }); final AppSession session; @@ -65,6 +67,7 @@ class RunsDestination extends StatelessWidget { /// The app-level attention controller the shell's Runs tab badge reads. final AttentionController? attention; + final Future Function(BuildContext, JsonMap)? onOpenInChat; @override Widget build(BuildContext context) => AnimatedBuilder( @@ -109,5 +112,6 @@ class RunsDestination extends StatelessWidget { onBack: onBack, onPipelineFilterChanged: onPipelineFilterChanged, onOpenPipeline: onOpenPipeline, + onOpenInChat: onOpenInChat, ); } diff --git a/app/lib/features/chat/chat_pane_content.dart b/app/lib/features/chat/chat_pane_content.dart index ee3486ca..86d06e4a 100644 --- a/app/lib/features/chat/chat_pane_content.dart +++ b/app/lib/features/chat/chat_pane_content.dart @@ -91,6 +91,7 @@ Widget buildChatPaneContent({ sessionId: sessionId, title: '${row?['title'] ?? ''}'.trim(), session: row, + initialDraft: runtime.pendingDrafts.remove(sessionId), syncToken: placement.syncToken, scrollPositions: runtime.scrollPositions, transcripts: runtime.transcripts, diff --git a/app/lib/features/chat/chat_runtime.dart b/app/lib/features/chat/chat_runtime.dart index 3c71cdc5..8b8585f2 100644 --- a/app/lib/features/chat/chat_runtime.dart +++ b/app/lib/features/chat/chat_runtime.dart @@ -96,6 +96,10 @@ class ChatRuntime extends ChangeNotifier { /// link) resolves the same row without a second list request. final Map opened = {}; + /// Drafts seeded by an external action such as Open in chat. They are + /// consumed by the first composer for that session. + final Map pendingDrafts = {}; + /// Each row as the list last reported it (without its live `running`), so /// [adoptRows] adopts only what a re-read changed. final Map _listed = {}; diff --git a/app/lib/features/chat/conversation/chat_thread_view.dart b/app/lib/features/chat/conversation/chat_thread_view.dart index d5420a5a..9c923312 100644 --- a/app/lib/features/chat/conversation/chat_thread_view.dart +++ b/app/lib/features/chat/conversation/chat_thread_view.dart @@ -114,6 +114,7 @@ class ChatThreadView extends StatefulWidget { this.scrollPositions, this.transcripts, this.initialNotice, + this.initialDraft, this.onNewSession, this.onSessionRenamed, this.onSessionClosed, @@ -157,6 +158,9 @@ class ChatThreadView extends StatefulWidget { /// the `/new` notice for a session it just created and opened. final String? initialNotice; + /// A draft supplied by an external deep action; it is never sent. + final String? initialDraft; + /// `/new` moved this chat to a fresh native session; the destination swaps /// the row in place, opens the new id with the notice and refreshes the /// list. Without a destination the notice shows here instead. @@ -528,6 +532,9 @@ class _ChatThreadViewState extends State { onAccepted: (send, queued) => _controller.promptAccepted(send.operationId, queued: queued), ); + if (widget.initialDraft != null) { + unawaited(composer.setDraft(widget.initialDraft!)); + } // A message a previous visit sent but never saw accepted comes back as // "Not sent" unless the history read shows the server has it. unawaited( diff --git a/app/lib/features/pipelines/pipeline_models.dart b/app/lib/features/pipelines/pipeline_models.dart index ad0d2b49..09c97847 100644 --- a/app/lib/features/pipelines/pipeline_models.dart +++ b/app/lib/features/pipelines/pipeline_models.dart @@ -224,6 +224,7 @@ class PipelineRun { required this.createdAt, required this.finishedAt, required this.executing, + this.workspace = '', }); factory PipelineRun.fromJson(PipelineJson json) => PipelineRun( @@ -233,6 +234,7 @@ class PipelineRun { createdAt: _string(json['created_at']), finishedAt: _string(json['finished_at']), executing: json['executing'] == true, + workspace: '${json['workspace'] ?? ''}', ); final int id; @@ -241,6 +243,7 @@ class PipelineRun { final String createdAt; final String finishedAt; final bool executing; + final String workspace; } /// Timestamps decide recency; a higher run id breaks an exact tie or two bad diff --git a/app/lib/features/pipelines/screen.dart b/app/lib/features/pipelines/screen.dart index 55188ee9..523ae975 100644 --- a/app/lib/features/pipelines/screen.dart +++ b/app/lib/features/pipelines/screen.dart @@ -41,6 +41,8 @@ class PipelinesScreen extends StatefulWidget { this.initialPipelineId, this.initialVersion = 0, this.initialStageKey, + this.onOpenInChat, + this.onOpenPipelineInChat, }); final ApiGateway gateway; @@ -87,6 +89,10 @@ class PipelinesScreen extends StatefulWidget { /// pane; a key the pinned version does not declare opens the Graph tab with /// nothing selected. Null keeps the ordinary default tab. final String? initialStageKey; + final Future Function(BuildContext, PipelineDetail, PipelineRun?)? + onOpenInChat; + final Future Function(BuildContext, PipelineSummary, PipelineRun?)? + onOpenPipelineInChat; @override State createState() => _PipelinesScreenState(); @@ -235,6 +241,7 @@ class _PipelinesScreenState extends State { showBack: false, onRunStarted: widget.onRunStarted, onViewPipelineRuns: widget.onViewPipelineRuns, + onOpenInChat: widget.onOpenInChat, stageKey: stageKey, stagePipelineId: widget.initialPipelineId, stageVersion: widget.initialVersion, @@ -252,12 +259,18 @@ class _PipelinesScreenState extends State { ); if (!wide) { return ContentWidth( - child: PipelineListPanel(controller: _controller), + child: PipelineListPanel( + controller: _controller, + onOpenInChat: widget.onOpenPipelineInChat, + ), ); } return ListDetailPanes( list: ContentWidth( - child: PipelineListPanel(controller: _controller), + child: PipelineListPanel( + controller: _controller, + onOpenInChat: widget.onOpenPipelineInChat, + ), ), detailIdentity: _controller.selectedId, detail: _controller.hasSelection diff --git a/app/lib/features/pipelines/widgets/pipeline_archive_action.dart b/app/lib/features/pipelines/widgets/pipeline_archive_action.dart index 59919ad2..18e7e06f 100644 --- a/app/lib/features/pipelines/widgets/pipeline_archive_action.dart +++ b/app/lib/features/pipelines/widgets/pipeline_archive_action.dart @@ -18,17 +18,29 @@ String archiveConfirmation(String name) => Widget pipelineActionsMenu( BuildContext context, PipelinesController controller, - PipelineDetail detail, -) { + PipelineDetail detail, { + Future Function(BuildContext, PipelineDetail, PipelineRun?)? + onOpenInChat, +}) { final archived = detail.archived; final label = archived ? 'Unarchive' : 'Archive…'; void run(BuildContext context) => archiveOrUnarchive(context, controller, detail); return SegmentedOverflowAction( overflowEntry: SegmentedOverflowEntry( - label: archived ? 'Unarchive pipeline' : 'Archive pipeline…', + label: 'Pipeline actions', icon: Icons.archive_outlined, - onPressed: () => run(context), + choices: [ + SegmentedMenuChoice( + label: archived ? 'Unarchive pipeline' : 'Archive pipeline…', + onSelected: () => run(context), + ), + if (onOpenInChat != null) + SegmentedMenuChoice( + label: 'Open in chat', + onSelected: () => onOpenInChat(context, detail, null), + ), + ], ), child: AppOverflowMenu( key: const Key('pipeline-actions-menu'), @@ -40,8 +52,15 @@ Widget pipelineActionsMenu( value: true, label: label, ), + if (onOpenInChat != null) + const AppMenuAction( + value: false, + label: 'Open in chat', + icon: Icons.chat_bubble_outline, + ), ], - onSelected: (context, _) => run(context), + onSelected: (context, value) => + value ? run(context) : onOpenInChat!(context, detail, null), ), ); } diff --git a/app/lib/features/pipelines/widgets/pipeline_detail_panel.dart b/app/lib/features/pipelines/widgets/pipeline_detail_panel.dart index 9a26ecc0..d4b5ec37 100644 --- a/app/lib/features/pipelines/widgets/pipeline_detail_panel.dart +++ b/app/lib/features/pipelines/widgets/pipeline_detail_panel.dart @@ -45,6 +45,7 @@ class PipelineDetailPanel extends StatefulWidget { this.stagePipelineId, this.stageVersion = 0, this.stageRequest = 0, + this.onOpenInChat, }) : assert( stageKey == null || stagePipelineId != null, 'a routed stage names the pipeline it belongs to', @@ -77,6 +78,8 @@ class PipelineDetailPanel extends StatefulWidget { /// definition pane even though the pinned detail may be re-read in place. A /// later version switch from this screen is not a new route request. final int stageRequest; + final Future Function(BuildContext, PipelineDetail, PipelineRun?)? + onOpenInChat; @override State createState() => _PipelineDetailPanelState(); @@ -420,7 +423,18 @@ class _PipelineDetailPanelState extends State { onRunStarted: widget.onRunStarted, inBar: true, ), - pipelineActionsMenu(context, _controller, detail), + pipelineActionsMenu( + context, + _controller, + detail, + onOpenInChat: widget.onOpenInChat == null + ? null + : (context, detail, _) => widget.onOpenInChat!( + context, + detail, + _controller.latestRuns[detail.id], + ), + ), ]; Widget _source(BuildContext context, PipelineDetail detail) { diff --git a/app/lib/features/pipelines/widgets/pipeline_list_panel.dart b/app/lib/features/pipelines/widgets/pipeline_list_panel.dart index 20cb037d..95d0896a 100644 --- a/app/lib/features/pipelines/widgets/pipeline_list_panel.dart +++ b/app/lib/features/pipelines/widgets/pipeline_list_panel.dart @@ -14,6 +14,7 @@ import '../pipelines_controller.dart'; import 'pipeline_controls.dart'; import 'pipeline_filter_page.dart'; import 'pipeline_scope_control.dart'; +import '../../../ui/layout/app_overflow_menu.dart'; /// The list's horizontal rhythm, matching the web's toolbar and row inset /// (`var(--space-s)`: 12px). The detail pane keeps its own content padding. @@ -21,9 +22,15 @@ const double kPipelineListInset = 12; /// The left/top pane: filter and sort controls, then the truthful list states. class PipelineListPanel extends StatelessWidget { - const PipelineListPanel({super.key, required this.controller}); + const PipelineListPanel({ + super.key, + required this.controller, + this.onOpenInChat, + }); final PipelinesController controller; + final Future Function(BuildContext, PipelineSummary, PipelineRun?)? + onOpenInChat; @override Widget build(BuildContext context) { @@ -264,6 +271,22 @@ class PipelineListPanel extends StatelessWidget { : Text( ServerContext.metadata(context, runStateLabel(badge.state)), ), + menu: onOpenInChat == null + ? null + : AppOverflowMenu( + key: Key('pipeline-row-more-menu-${pipeline.id}'), + label: 'Pipeline actions', + sheetTitle: pipeline.displayName, + actions: const [ + AppMenuAction( + value: true, + label: 'Open in chat', + icon: Icons.chat_bubble_outline, + ), + ], + onSelected: (context, _) => + onOpenInChat!(context, pipeline, run), + ), ); }, ); diff --git a/app/lib/features/runs/screen.dart b/app/lib/features/runs/screen.dart index e3dbcde1..bd2f3229 100644 --- a/app/lib/features/runs/screen.dart +++ b/app/lib/features/runs/screen.dart @@ -53,6 +53,7 @@ class RunsScreen extends StatefulWidget { this.attention, this.sortStore = const SharedPreferencesRunsSortStore(), this.pendingRunStore = const SharedPreferencesPendingRunStore(''), + this.onOpenInChat, }); final ApiGateway gateway; @@ -103,6 +104,7 @@ class RunsScreen extends StatefulWidget { /// Where a New run's pending launch intent persists, under the same endpoint /// scope the Pipelines tab uses. Tests inject a memory store. final PendingRunStore pendingRunStore; + final Future Function(BuildContext, JsonMap)? onOpenInChat; @override State createState() => _RunsScreenState(); @@ -300,6 +302,7 @@ class _RunsScreenState extends State { onBack: onBack, onRunOpened: _select, onOpenPipeline: widget.onOpenPipeline, + onOpenInChat: widget.onOpenInChat, initialStageKey: widget.initialStageKey, initialVisit: widget.initialVisit, ); @@ -354,6 +357,7 @@ class _RunsScreenState extends State { attentionNow: widget.attentionNow, notifications: widget.notifications, attention: widget.attention, + onOpenInChat: widget.onOpenInChat, ), ), ); diff --git a/app/lib/features/runs/ui/run_detail_view.dart b/app/lib/features/runs/ui/run_detail_view.dart index 7bb0fa11..305e2ab8 100644 --- a/app/lib/features/runs/ui/run_detail_view.dart +++ b/app/lib/features/runs/ui/run_detail_view.dart @@ -24,6 +24,7 @@ class RunDetailView extends StatefulWidget { this.onOpenPipeline, this.initialStageKey, this.initialVisit, + this.onOpenInChat, }); final RunsController controller; @@ -44,6 +45,7 @@ class RunDetailView extends StatefulWidget { /// plain detail. final String? initialStageKey; final int? initialVisit; + final Future Function(BuildContext, JsonMap)? onOpenInChat; @override State createState() => _RunDetailViewState(); @@ -114,6 +116,7 @@ class _RunDetailViewState extends State { onRunChanged: widget.controller.acceptRunDetail, onRunOpened: widget.onRunOpened, onDeleted: widget.controller.applyDeletion, + onOpenInChat: widget.onOpenInChat, ); if (inShellBar) { return ShellBar( diff --git a/app/lib/features/runs/ui/run_list_row.dart b/app/lib/features/runs/ui/run_list_row.dart index a7f50114..1d23e96e 100644 --- a/app/lib/features/runs/ui/run_list_row.dart +++ b/app/lib/features/runs/ui/run_list_row.dart @@ -35,6 +35,7 @@ class RunListRow extends StatelessWidget { this.checked = false, this.onToggle, this.onLongPress, + this.onOpenInChat, }); final JsonMap run; @@ -56,6 +57,7 @@ class RunListRow extends StatelessWidget { /// Enters select mode from a touch long-press. final VoidCallback? onLongPress; + final Future Function(BuildContext, JsonMap)? onOpenInChat; @override Widget build(BuildContext context) { @@ -140,13 +142,18 @@ class RunListRow extends StatelessWidget { !selecting && gateway != null && onRunChanged != null && - showRunMoreMenu(run, deletable: onDeleted != null) + showRunMoreMenu( + run, + deletable: onDeleted != null, + canOpenInChat: onOpenInChat != null, + ) ? RunMoreMenu( run: run, gateway: gateway!, onRunChanged: onRunChanged!, onRunOpened: onRunOpened, onDeleted: onDeleted, + onOpenInChat: onOpenInChat, menuKey: ValueKey('run-list-more-menu-$id'), ) : null, diff --git a/app/lib/features/runs/ui/run_more_menu.dart b/app/lib/features/runs/ui/run_more_menu.dart index 7c7f9a1e..b312161b 100644 --- a/app/lib/features/runs/ui/run_more_menu.dart +++ b/app/lib/features/runs/ui/run_more_menu.dart @@ -16,14 +16,21 @@ import '../domain/run_models.dart' show runIdentity; const runMoreMenuKey = ValueKey('run-more-menu'); const deleteRunActionKey = ValueKey('run-delete-action'); const deleteRunActionLabel = 'Delete run'; +const openRunInChatActionKey = ValueKey('run-open-in-chat-action'); +const openRunInChatActionLabel = 'Open in chat'; /// Whether the run has anything for its more menu. [deletable] says the host /// can apply a deletion, so a finished run offers Delete run. -bool showRunMoreMenu(JsonMap run, {bool deletable = false}) => +bool showRunMoreMenu( + JsonMap run, { + bool deletable = false, + bool canOpenInChat = false, +}) => runTitleId(run) != null || canScheduleRun(run) || _canRetry(run) || - (deletable && runIsDeletable(run)); + (deletable && runIsDeletable(run)) || + canOpenInChat; /// The run's own name for its action sheet: its title or pipeline, else /// `Run `, as its list row shows it. @@ -34,7 +41,7 @@ String runMoreMenuTitle(JsonMap run) { bool _canRetry(JsonMap run) => retryRunId(run) != null && canRetryRun(run); -enum _RunMoreItem { retry, rename, schedule, delete } +enum _RunMoreItem { retry, rename, schedule, delete, openInChat } /// Each item keeps the key its standalone button had. Key _keyOf(_RunMoreItem item) => switch (item) { @@ -42,6 +49,7 @@ Key _keyOf(_RunMoreItem item) => switch (item) { _RunMoreItem.rename => runTitleActionKey, _RunMoreItem.schedule => scheduleRunActionKey, _RunMoreItem.delete => deleteRunActionKey, + _RunMoreItem.openInChat => openRunInChatActionKey, }; /// The run detail's more menu: Retry (failed runs only), Rename and Schedule @@ -56,6 +64,7 @@ class RunMoreMenu extends StatefulWidget { required this.onRunChanged, this.onRunOpened, this.onDeleted, + this.onOpenInChat, this.menuKey = runMoreMenuKey, }); @@ -68,6 +77,7 @@ class RunMoreMenu extends StatefulWidget { /// Applies an answered deletion; without it the menu offers no Delete run. final ValueChanged? onDeleted; + final Future Function(BuildContext, JsonMap)? onOpenInChat; /// Detail menus retain the shared key; list rows supply a per-run key. final Key menuKey; @@ -86,6 +96,8 @@ class _RunMoreMenuState extends State { if (canScheduleRun(run)) (_RunMoreItem.schedule, scheduleRunActionLabel), if (widget.onDeleted != null && runIsDeletable(run)) (_RunMoreItem.delete, deleteRunActionLabel), + if (widget.onOpenInChat != null) + (_RunMoreItem.openInChat, openRunInChatActionLabel), ]; void _pick(BuildContext context, _RunMoreItem item) { @@ -117,6 +129,8 @@ class _RunMoreMenuState extends State { gateway: widget.gateway, onDeleted: widget.onDeleted!, ); + case _RunMoreItem.openInChat: + widget.onOpenInChat!(context, run); } } @@ -131,6 +145,9 @@ class _RunMoreMenuState extends State { key: _keyOf(item), value: item, label: label, + icon: item == _RunMoreItem.openInChat + ? Icons.chat_bubble_outline + : null, destructive: item == _RunMoreItem.delete, ), ], diff --git a/app/lib/features/runs/ui/runs_list.dart b/app/lib/features/runs/ui/runs_list.dart index 00817b55..65223fab 100644 --- a/app/lib/features/runs/ui/runs_list.dart +++ b/app/lib/features/runs/ui/runs_list.dart @@ -32,10 +32,12 @@ class RunsList extends StatelessWidget { this.notifications, this.attention, this.active = true, + this.onOpenInChat, }); /// False while a run detail covers the list; the bar is then the run's. final bool active; + final Future Function(BuildContext, JsonMap)? onOpenInChat; final RunsController controller; final ValueChanged onSelected; @@ -166,7 +168,8 @@ class RunsList extends StatelessWidget { // A server with no runs at all is not a filter problem: say what the list // is for and where its first run comes from. A free-text query counts as // a filter too, so a search on an empty server reads as "nothing found". - final noRunsAtAll = controller.runs.isEmpty && + final noRunsAtAll = + controller.runs.isEmpty && controller.activeFilterCount == 0 && controller.query.trim().isEmpty; return BelowTopBar( @@ -340,6 +343,7 @@ class RunsList extends StatelessWidget { gateway: controller.repository.gateway, onRunChanged: controller.acceptRunDetail, onRunOpened: onSelected, + onOpenInChat: onOpenInChat, ); } } diff --git a/app/notes/open-in-chat.md b/app/notes/open-in-chat.md new file mode 100644 index 00000000..6b14e713 --- /dev/null +++ b/app/notes/open-in-chat.md @@ -0,0 +1,21 @@ +# Open in chat + +Runs and pipelines expose **Open in chat** in their overflow menus. The action +creates a chat using the New chat backend catalog rule (OpenCode when +available, otherwise the first advertised harness) in the run/latest-run +workspace, or the saved Settings workspace and finally `~`, then routes to the +Chat tab. The generated reference is seeded as an unsent composer draft and +requests composer focus. Settings and create failures show an error without +changing chat state. On narrow pipeline detail layouts, the segmented More +sheet includes both Archive/Unarchive and Open in chat. Settings fallback reads +the workspace for the active server identity rather than an unscoped preference. + +Focused regression coverage is in `test/application/open_in_chat_test.dart`: +run list desktop menu, run detail phone sheet, pipeline list row menu, and +pipeline detail phone overflow all assert selection reaches the callback with +the expected entity and latest run. The existing schedule/menu and pipeline +destination tests also pass. The full-app browser probe now supports stateful +`chat_create`, catalog, session, and transcript replies, so a rendered menu +selection can show the created chat and seeded composer rather than stopping at +an unsupported-request error. Browser and phone/desktop captures were not run +in this implementation stage. diff --git a/app/test/application/open_in_chat_test.dart b/app/test/application/open_in_chat_test.dart new file mode 100644 index 00000000..1b46a293 --- /dev/null +++ b/app/test/application/open_in_chat_test.dart @@ -0,0 +1,296 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:pipelines_app/core/api_gateway.dart'; +import 'package:pipelines_app/application/open_in_chat.dart'; +import 'package:pipelines_app/features/chat/chat_runtime.dart'; +import 'package:pipelines_app/features/chat/ui/sessions/chat_create_fields.dart'; +import 'package:pipelines_app/features/pipelines/pipeline_models.dart'; +import 'package:pipelines_app/features/pipelines/pipeline_repository.dart'; +import 'package:pipelines_app/features/pipelines/pipelines_controller.dart'; +import 'package:pipelines_app/features/pipelines/widgets/pipeline_archive_action.dart'; +import 'package:pipelines_app/features/pipelines/widgets/pipeline_list_panel.dart'; +import 'package:pipelines_app/features/runs/ui/run_list_row.dart'; +import 'package:pipelines_app/features/runs/ui/run_more_menu.dart'; + +import '../features/chat/ui/sessions/fake_chat_gateway.dart'; +import '../features/pipelines/fixtures.dart'; +import '../features/pipelines/test_helpers.dart'; + +void main() { + test('a run summary names its pipeline in name', () { + final draft = runChatReference({ + 'id': 7, + 'name': 'release', + 'title': 'Ship notes', + 'version': 3, + 'status': 'failed', + }); + expect( + draft, + 'About Pipelines run #7 "Ship notes" (pipeline "release" v3, ' + 'status failed). Inspect it with `pipelines inspect 7`.', + ); + final untitled = runChatReference({ + 'id': 8, + 'name': 'release', + 'version': 3, + 'status': 'succeeded', + }); + expect(untitled, contains('run #8 "Run 8" (pipeline "release" v3')); + }); + + test('run references contain the exact inspect command', () { + expect( + runChatReference({ + 'id': 42, + 'title': 'Nightly build', + 'pipeline_name': 'Deploy', + 'pipeline_version': 3, + 'status': 'failed', + }), + 'About Pipelines run #42 "Nightly build" (pipeline "Deploy" v3, ' + 'status failed). Inspect it with `pipelines inspect 42`.', + ); + }); + + test('pipeline references contain show and edit guidance', () { + expect( + pipelineChatReference(7, 'Deploy', 4), + 'About pipeline "Deploy" (id 7, version 4). Show it with ' + '`pipelines show "Deploy"`; to change it, draft with `pipelines edit` ' + 'and publish with `pipelines submit`.', + ); + }); + + test('open in chat keeps the more menu available', () { + expect(showRunMoreMenu({'id': 42}, canOpenInChat: true), isTrue); + }); + + test('pipeline latest run retains its workspace', () { + final run = PipelineRun.fromJson({ + 'id': 9, + 'pipeline_id': 7, + 'workspace': '/work/deploy', + }); + expect(run.workspace, '/work/deploy'); + }); + + testWidgets( + 'open in chat uses the catalog backend, draft, route, and focus', + (tester) async { + final gateway = FakeChatGateway() + ..backendsHandler = () async => const { + 'chat_backends': ['codex', 'claude'], + }; + final runtime = ChatRuntime(gateway: gateway); + String? selected; + + await tester.pumpWidget(const MaterialApp(home: Scaffold())); + await openReferenceInChat( + context: tester.element(find.byType(Scaffold)), + runtime: runtime, + selectChat: (id) => selected = id, + directory: '/work/run', + title: 'Run #42: Build', + draft: 'About Pipelines run #42.', + ); + + final create = gateway.lastFields('chat_create')!['chat_create'] as Map; + expect(create['backend'], 'codex'); + expect(create['directory'], '/work/run'); + expect(selected, 'created'); + expect(runtime.pendingDrafts['created'], 'About Pipelines run #42.'); + expect(runtime.composerFocus.take('created'), isTrue); + runtime.dispose(); + }, + ); + + testWidgets('open in chat falls back to the default folder', (tester) async { + final gateway = FakeChatGateway(); + final runtime = ChatRuntime(gateway: gateway); + + await tester.pumpWidget(const MaterialApp(home: Scaffold())); + await openReferenceInChat( + context: tester.element(find.byType(Scaffold)), + runtime: runtime, + selectChat: (_) {}, + directory: '', + title: 'Pipeline: Deploy', + draft: 'About pipeline "Deploy".', + ); + + final create = gateway.lastFields('chat_create')!['chat_create'] as Map; + expect(create['directory'], chatHomeDirectory); + runtime.dispose(); + }); + + testWidgets('create failure leaves navigation and chat state unchanged', ( + tester, + ) async { + final gateway = FakeChatGateway()..failures['chat_create'] = 'refused'; + final runtime = ChatRuntime(gateway: gateway); + String? selected; + + await tester.pumpWidget(const MaterialApp(home: Scaffold())); + await openReferenceInChat( + context: tester.element(find.byType(Scaffold)), + runtime: runtime, + selectChat: (id) => selected = id, + directory: '/work/run', + title: 'Run #42: Build', + draft: 'About Pipelines run #42.', + ); + await tester.pump(); + + expect(selected, isNull); + expect(runtime.opened, isEmpty); + expect(find.textContaining('Could not open in chat'), findsOneWidget); + runtime.dispose(); + }); + + testWidgets('run list More selects Open in chat on desktop', (tester) async { + final run = { + 'id': 42, + 'title': 'Build', + 'status': 'failed', + 'created_at': '2026-10-17T19:00:00', + }; + JsonMap? selected; + final gateway = FakeChatGateway(); + + tester.view.physicalSize = const Size(900, 700); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: RunListRow( + run: run, + now: DateTime(2026, 10, 18), + gateway: gateway, + onRunChanged: (_) {}, + onOpenInChat: (context, value) async => selected = value, + ), + ), + ), + ); + + await tester.tap(find.byKey(const Key('run-list-more-menu-42'))); + await tester.pumpAndSettle(); + expect(find.text('Open in chat'), findsOneWidget); + await tester.tap(find.text('Open in chat')); + expect(selected, same(run)); + }); + + testWidgets('run detail More selects Open in chat from the phone sheet', ( + tester, + ) async { + final run = {'id': 42, 'title': 'Build'}; + JsonMap? selected; + final gateway = FakeChatGateway(); + + tester.view.physicalSize = const Size(390, 844); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + appBar: AppBar( + actions: [ + RunMoreMenu( + run: run, + gateway: gateway, + onRunChanged: (_) {}, + onOpenInChat: (context, value) async => selected = value, + ), + ], + ), + ), + ), + ); + + await tester.tap(find.byTooltip('More actions')); + await tester.pumpAndSettle(); + expect(find.text('Open in chat'), findsOneWidget); + await tester.tap(find.text('Open in chat')); + expect(selected, same(run)); + }); + + testWidgets('pipeline list row More selects Open in chat with latest run', ( + tester, + ) async { + final fixture = PipelineFixture(); + final gateway = gatewayFor(fixture); + final controller = PipelinesController(PipelinesRepository(gateway)); + addTearDown(controller.dispose); + await controller.load(); + PipelineSummary? selected; + PipelineRun? selectedRun; + + tester.view.physicalSize = const Size(900, 700); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: PipelineListPanel( + controller: controller, + onOpenInChat: (context, pipeline, run) async { + selected = pipeline; + selectedRun = run; + }, + ), + ), + ), + ); + await tester.pumpAndSettle(); + + await tester.tap(find.byKey(const Key('pipeline-row-more-menu-1'))); + await tester.pumpAndSettle(); + expect(find.text('Open in chat'), findsOneWidget); + await tester.tap(find.text('Open in chat')); + expect(selected?.id, 1); + expect(selectedRun?.id, 42); + }); + + testWidgets( + 'pipeline detail actions select Open in chat from phone overflow', + (tester) async { + final fixture = PipelineFixture(); + final gateway = gatewayFor(fixture); + final controller = PipelinesController(PipelinesRepository(gateway)); + addTearDown(controller.dispose); + final detail = PipelineDetail.fromJson(fixture.details.first); + PipelineDetail? selected; + + tester.view.physicalSize = const Size(390, 844); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: Builder( + builder: (context) => pipelineActionsMenu( + context, + controller, + detail, + onOpenInChat: (context, value, run) async => selected = value, + ), + ), + ), + ), + ); + + await tester.tap(find.byTooltip('Pipeline actions')); + await tester.pumpAndSettle(); + expect(find.text('Open in chat'), findsOneWidget); + await tester.tap(find.text('Open in chat')); + expect(selected?.id, detail.id); + }, + ); +} diff --git a/app/tool/search_selection_probe_entry.dart b/app/tool/search_selection_probe_entry.dart index b25a7e7a..d08f7441 100644 --- a/app/tool/search_selection_probe_entry.dart +++ b/app/tool/search_selection_probe_entry.dart @@ -170,6 +170,12 @@ bool _warnings = false; /// visit (group `debug`) to run 7's build visit, so the Artifacts tab's hidden /// Debugging files group can be reviewed. bool _turnFiles = false; + +/// Chats created during a rendered probe. Keeping these in the fixture makes +/// the real Open in chat flow observable instead of turning the create request +/// into the same "unsupported request" error as an incomplete server. +final _probeChats = {}; +int _probeChatSequence = 0; const List _turnFileNames = [ 'input.md', 'memory.md', @@ -549,6 +555,78 @@ JsonMap? probeReply(JsonMap request) { 'type': 'pipeline', 'detail': probePipelineDetail(pipelineId, version is int ? version : 0), }; + case 'chat_backends': + return { + 'id': id, + 'type': 'chat_backends', + 'chat_backends': ['opencode'], + }; + case 'chat_directories': + return { + 'id': id, + 'type': 'chat_directories', + 'chat_directories': ['/Users/fixture/workspace'], + }; + case 'chat_sessions': + return { + 'id': id, + 'type': 'chat_sessions', + 'chat_sessions': _probeChats.values.toList(), + }; + case 'chat_create': + final body = request['chat_create']; + if (body is! Map) { + return error('Fixture refused a malformed chat create.'); + } + final chatId = 'probe-chat-${++_probeChatSequence}'; + final session = { + 'id': chatId, + 'title': '${body['title'] ?? ''}', + 'directory': '${body['directory'] ?? ''}', + 'backend': '${body['backend'] ?? 'opencode'}', + 'model': 'fixture-model', + 'created_at': '2026-10-20T09:00:00Z', + 'closed_at': null, + }; + _probeChats[chatId] = session; + return {'id': id, 'type': 'chat_created', 'chat_session': session}; + case 'chat_models': + return { + 'id': id, + 'type': 'chat_models', + 'chat_models': [ + {'provider': 'fixture', 'model': 'fixture-model'}, + ], + }; + case 'chat_modes': + return { + 'id': id, + 'type': 'chat_modes', + 'chat_modes': const [ + {'mode': 'default', 'name': 'Default'}, + ], + 'chat_mode': const {'mode': 'default'}, + }; + case 'chat_messages': + return { + 'id': id, + 'type': 'chat_messages', + 'chat_history': const { + 'messages': [], + 'next_cursor': '', + 'has_more': false, + }, + }; + case 'chat_subscribe': + return {'id': id, 'type': 'chat_subscribed'}; + case 'chat_shells': + return {'id': id, 'type': 'chat_shells', 'chat_shells': const []}; + case 'chat_automations': + return { + 'id': id, + 'type': 'chat_automations', + 'chat_automations': const [], + }; case 'archive_pipeline': case 'unarchive_pipeline': // Mirrors the server: an enabled schedule blocks archiving. From b561e250e621bbad87847cde32219b4753cedf0d Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Fri, 13 Nov 2026 12:44:47 +0000 Subject: [PATCH 4/5] Icons for every run menu action; omit an unknown pipeline version --- app/lib/application/open_in_chat.dart | 4 ++-- app/lib/features/runs/ui/run_more_menu.dart | 10 +++++++--- app/test/application/open_in_chat_test.dart | 6 ++++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/lib/application/open_in_chat.dart b/app/lib/application/open_in_chat.dart index 5d82c846..b6f3000c 100644 --- a/app/lib/application/open_in_chat.dart +++ b/app/lib/application/open_in_chat.dart @@ -17,8 +17,8 @@ String runChatReference(JsonMap run) { final version = '${run['pipeline_version'] ?? run['version'] ?? ''}'.trim(); final status = '${run['status'] ?? ''}'.trim(); return 'About Pipelines run #$id "${title.isEmpty ? 'Run $id' : title}" ' - '(pipeline "${pipeline.isEmpty ? 'unknown' : pipeline}" ' - 'v${version.isEmpty ? '?' : version}, status $status). ' + '(pipeline "${pipeline.isEmpty ? 'unknown' : pipeline}"' + '${version.isEmpty ? '' : ' v$version'}, status $status). ' 'Inspect it with `pipelines inspect $id`.'; } diff --git a/app/lib/features/runs/ui/run_more_menu.dart b/app/lib/features/runs/ui/run_more_menu.dart index b312161b..4bbc3ca3 100644 --- a/app/lib/features/runs/ui/run_more_menu.dart +++ b/app/lib/features/runs/ui/run_more_menu.dart @@ -145,9 +145,13 @@ class _RunMoreMenuState extends State { key: _keyOf(item), value: item, label: label, - icon: item == _RunMoreItem.openInChat - ? Icons.chat_bubble_outline - : null, + icon: switch (item) { + _RunMoreItem.retry => Icons.replay, + _RunMoreItem.rename => Icons.edit_outlined, + _RunMoreItem.schedule => Icons.schedule, + _RunMoreItem.delete => Icons.delete_outline, + _RunMoreItem.openInChat => Icons.chat_bubble_outline, + }, destructive: item == _RunMoreItem.delete, ), ], diff --git a/app/test/application/open_in_chat_test.dart b/app/test/application/open_in_chat_test.dart index 1b46a293..79469ae0 100644 --- a/app/test/application/open_in_chat_test.dart +++ b/app/test/application/open_in_chat_test.dart @@ -38,6 +38,12 @@ void main() { 'status': 'succeeded', }); expect(untitled, contains('run #8 "Run 8" (pipeline "release" v3')); + final unversioned = runChatReference({ + 'id': 9, + 'name': 'release', + 'status': 'running', + }); + expect(unversioned, contains('(pipeline "release", status running)')); }); test('run references contain the exact inspect command', () { From 97f727f468927c79a1f9a4b6fd0c6359a1778bf2 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Fri, 13 Nov 2026 12:45:23 +0000 Subject: [PATCH 5/5] Skill: always wait on a started run with pipelines wait Agents started runs and moved on, then missed failures. The skill now says to follow every run with a background pipelines wait, read the result when it ends, and act on it instead of polling or promising a report. --- internal/author/skill/SKILL.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/author/skill/SKILL.md b/internal/author/skill/SKILL.md index 760731b8..d8871dc0 100644 --- a/internal/author/skill/SKILL.md +++ b/internal/author/skill/SKILL.md @@ -13,7 +13,15 @@ task with the least ceremony, and keep work small enough to verify. `pipelines list` shows the registered workflows; `pipelines runs` shows history. Start a run with `pipelines run ""`, and inspect it with -`pipelines inspect `. `pipelines wait ` blocks until it finishes. +`pipelines inspect `. + +After starting a run, always follow it with `pipelines wait ` until it +finishes; never start a run and move on without waiting. Run the wait as a +background command (one per run, or one loop over several ids) so the session is +notified the moment the run ends, then read its result with +`pipelines inspect --json` and act on it: land, retry, or fix and report. +Do not poll with repeated `pipelines runs` calls, and do not tell the user a run +is done, or will be reported, without a wait covering it. A failed run keeps its worktree and commits. Read `pipelines inspect --json` before deciding: resume the failed stage (`pipelines retry `), fix directly,