Keep background pane updates from stealing destination navigation

This commit is contained in:
2026-11-06 18:24:58 +00:00
parent 4bae206afd
commit 417a696785
4 changed files with 80 additions and 8 deletions
@@ -28,15 +28,8 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
_workspaceSignature = signature;
void update() {
if (!mounted) return;
final id = _workspace.activePane?.sessionId;
setState(() {});
if (!_workspaceVisible ||
id == null ||
id == _publishedWorkspaceSession) {
return;
}
_publishedWorkspaceSession = id;
widget.onSessionSelected?.call(id);
_publishWorkspaceRoute();
}
if (SchedulerBinding.instance.schedulerPhase ==
@@ -47,6 +40,20 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
}
}
void _publishWorkspaceRoute() {
if (!mounted) return;
final id = _workspace.activePane?.sessionId;
final destination = ShellBarScope.maybeOf(context)?.registry.focus;
if (!_workspaceVisible ||
id == null ||
id == _publishedWorkspaceSession ||
(destination != null && destination != AppDestination.chat)) {
return;
}
_publishedWorkspaceSession = id;
widget.onSessionSelected?.call(id);
}
void _split(JsonMap session, ChatSplitAxis axis) {
final id = '${session['id'] ?? ''}';
if (id.isEmpty) return;
+5
View File
@@ -435,6 +435,11 @@ class _ChatScreenState extends State<ChatScreen> with _ChatScreenWorkspace {
@override
Widget build(BuildContext context) {
final selected = _selected;
if (_workspaceVisible && selected != _publishedWorkspaceSession) {
WidgetsBinding.instance.addPostFrameCallback(
(_) => _publishWorkspaceRoute(),
);
}
_offeredNext = selected != null && _nextAfter(selected) != null;
// A phone opens a chat as a real Navigator page with stock Back. A wide
// window keeps the destination rail and the chat list beside the open
+18
View File
@@ -0,0 +1,18 @@
# Multiple chat panes
The chat list's More menu offers **Open to the right** and **Open below** on wide windows. Each action splits the active pane; nested horizontal and vertical splits can be combined. A normal row click or conversation-number shortcut replaces the active pane, or focuses an already-open chat. Each chat appears once in the workspace.
Drag the divider in either direction to resize. The divider has an accessible label and keyboard arrow resizing; double-click restores an even split. Minimum pane sizes protect the composer. An accent outline identifies the active pane. Clicking a pane activates it without stealing a transcript selection. Closing a pane collapses its adjoining split and never closes or interrupts the underlying chat.
Keyboard navigation:
- Ctrl+Shift+Arrow moves to the neighbouring pane; Command+Shift+Arrow also works on macOS.
- With one pane, these keys retain their normal editing behavior.
- Ctrl+/ opens/refocuses Search; Command+/ also works on macOS. The existing query is preserved.
- Ctrl+1…9 and macOS Command+1…9 select conversations only in Chat. Pipelines and Runs no longer consume number shortcuts; Ctrl+Tab no longer cycles destinations.
Narrow windows show only the active pane, with an **Open chats** picker retaining the others. Widening restores the split layout and drafts. Each leaf has a stable pane identity and its own header registry, composer, transcript, stream filtering and scroll position. Closing a neighbour or resizing does not remount those views. `/new` results update their originating pane even if focus moved while the request was pending. Route navigation names the active chat. The split layout is visit-local, not restored after a browser reload.
Implementation is app-only; no new backend, pipeline definition or TUI changes. The existing WebSocket multiplexes session streams. A new generic capture key mapping supports physical Slash/left/right key codes for browser acceptance.
Background `/new` completions update their retained pane without navigating away from Search or another destination. Returning to Chat publishes the current active session route. Narrow-window Back returns to the list without issuing a server chat-close or interrupt request.
@@ -4,6 +4,8 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/screen.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
import 'package:pipelines_app/features/chat/ui/sessions/session_actions.dart';
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
@@ -260,4 +262,44 @@ void main() {
await tester.pumpWidget(const SizedBox.shrink());
},
);
testWidgets(
'background new-session completion never navigates away from Search',
(tester) async {
final gateway = await _setup(tester);
final opened = <String>[];
await tester.pumpWidget(
MaterialApp(
home: AdaptiveShell(
destination: AppDestination.chat,
destinationBodies: {
AppDestination.chat: (_) =>
ChatScreen(gateway: gateway, onSessionSelected: opened.add),
AppDestination.search: (_) => const Text('Search destination'),
},
),
),
);
await tester.pumpAndSettle();
await tester.tap(find.text('Chat a').first);
await tester.pumpAndSettle();
await _split(tester, 'b', 'Open to the right');
final finishedNew = tester
.widget<ChatThreadView>(_thread('b'))
.onNewSession!;
final before = opened.length;
await tester.tap(find.byKey(const ValueKey('shell.destination.search')));
await tester.pumpAndSettle();
finishedNew('b', {'id': 'b-new', 'title': 'Fresh B'}, 'Started fresh');
await tester.pumpAndSettle();
expect(find.text('Search destination'), findsOneWidget);
expect(opened.length, before);
await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
await tester.pumpAndSettle();
expect(_thread('a'), findsOneWidget);
expect(_thread('b-new'), findsOneWidget);
expect(opened.last, 'b-new');
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox.shrink());
},
);
}