From 803a067edf3c103f44c138a796dde02ab3c3d344 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Fri, 6 Nov 2026 19:19:24 +0000 Subject: [PATCH] Populate metadata for every restored chat pane --- app/lib/features/chat/screen.dart | 5 +++-- app/test/features/chat/chat_workspace_restore_test.dart | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/lib/features/chat/screen.dart b/app/lib/features/chat/screen.dart index 3492d85f..0d7f895e 100644 --- a/app/lib/features/chat/screen.dart +++ b/app/lib/features/chat/screen.dart @@ -295,6 +295,7 @@ class _ChatScreenState extends State with _ChatScreenWorkspace { void _adoptRows(List rows) { if (!mounted) return; final selected = _selected; + final retained = _workspace.panes.map((pane) => pane.sessionId).toSet(); final next = {}; for (final row in rows) { final id = '${row['id'] ?? ''}'; @@ -303,7 +304,7 @@ class _ChatScreenState extends State with _ChatScreenWorkspace { final previous = _listedRows[id]; _listedRows[id] = listed; final opened = _openedSessions[id]; - if (opened == null && id != selected) continue; + if (opened == null && id != selected && !retained.contains(id)) continue; if (opened != null && chatJsonEquals(previous, listed)) continue; final adopted = {...?opened, ...listed}; if (opened != null && opened.containsKey('running')) { @@ -336,7 +337,7 @@ class _ChatScreenState extends State with _ChatScreenWorkspace { /// The row to open for [id], with an accepted model folded in. @override JsonMap? _rowFor(String id) { - final row = _openedSessions[id]; + final row = _openedSessions[id] ?? _listedRows[id]; final accepted = _acceptedModels[id]; if (row == null || accepted == null) return row; return { diff --git a/app/test/features/chat/chat_workspace_restore_test.dart b/app/test/features/chat/chat_workspace_restore_test.dart index 30136c8c..8306f779 100644 --- a/app/test/features/chat/chat_workspace_restore_test.dart +++ b/app/test/features/chat/chat_workspace_restore_test.dart @@ -79,6 +79,15 @@ void main() { expect(controller.panes.map((pane) => pane.sessionId), ['a', 'b']); expect(controller.activePane?.sessionId, 'b'); if (width > 1000) { + for (final pane in controller.panes) { + expect( + find.descendant( + of: find.byKey(ValueKey('chat-pane-detail-${pane.id}')), + matching: find.text('Chat ${pane.sessionId}'), + ), + findsOneWidget, + ); + } expect( tester .widget(find.byType(ChatSidebarButton).first)