From 04c6e82a4d668dc67c8df28de9ffdf4d65459c40 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Fri, 23 Oct 2026 18:54:46 +0100 Subject: [PATCH] feat(app): chat list drops search, New chat and Refresh are bar actions, and rows show agent, model and ~ paths --- .../chat/ui/sessions/session_row_style.dart | 22 +++-- .../sessions/chat_cupertino_theme_test.dart | 28 ------ .../chat_session_row_layout_test.dart | 31 +++++-- .../chat_session_row_material_test.dart | 16 ++-- .../sessions/chat_sessions_screen_test.dart | 88 ++----------------- .../chat/ui/sessions/chat_toolbar_test.dart | 13 +-- 6 files changed, 61 insertions(+), 137 deletions(-) diff --git a/app/lib/features/chat/ui/sessions/session_row_style.dart b/app/lib/features/chat/ui/sessions/session_row_style.dart index 5755ea99..eeee99a3 100644 --- a/app/lib/features/chat/ui/sessions/session_row_style.dart +++ b/app/lib/features/chat/ui/sessions/session_row_style.dart @@ -43,12 +43,22 @@ String relativeChatSessionTime(Object? updatedAt, {DateTime? now}) { return '${then.day} ${_shortMonths[then.month - 1]}'; } -/// The row's muted second line: the directory the chat runs in, plus the model -/// the server recorded for it. Both come from the row; nothing is inferred. -String chatSessionMeta(JsonMap session) => [ - '${session['directory'] ?? ''}'.trim(), - '${session['model'] ?? ''}'.trim(), -].where((part) => part.isNotEmpty).join(' · '); +/// The row's muted second line: which agent runs the chat (an empty backend +/// is a legacy OpenCode row), its model, and the directory with the home +/// folder written as `~`. +String chatSessionMeta(JsonMap session) { + final backend = '${session['backend'] ?? ''}'.trim(); + return [ + backend.isEmpty ? 'opencode' : backend, + '${session['model'] ?? ''}'.trim(), + homeRelativePath('${session['directory'] ?? ''}'.trim()), + ].where((part) => part.isNotEmpty).join(' · '); +} + +final _homePrefix = RegExp(r'^(/Users/[^/]+|/home/[^/]+|/root)(?=/|$)'); + +/// `/Users/alan/repos/x` (or `/home/alan/...`) as `~/repos/x`. +String homeRelativePath(String path) => path.replaceFirst(_homePrefix, '~'); /// The row's muted second line as the web words it: recency first, then the /// directory and model (`1 day ago · /srv/probe · model-a`). diff --git a/app/test/features/chat/ui/sessions/chat_cupertino_theme_test.dart b/app/test/features/chat/ui/sessions/chat_cupertino_theme_test.dart index b16bcc73..d2f01eae 100644 --- a/app/test/features/chat/ui/sessions/chat_cupertino_theme_test.dart +++ b/app/test/features/chat/ui/sessions/chat_cupertino_theme_test.dart @@ -24,34 +24,6 @@ void main() { expectNormalTextStyle(tester, message); }); - testWidgets('Cupertino no-match message under MaterialApp wraps normally', ( - tester, - ) async { - usePhoneSurface(tester); - final gateway = FakeChatGateway() - ..sessionsReply = {'chat_sessions': sampleSessions()}; - await pumpIosMaterialChat(tester, gateway); - - await tester.enterText( - find.byType(CupertinoSearchTextField), - 'zzz-no-match-with-a-long-query', - ); - await tester.pumpAndSettle(); - - const message = 'No chats match "zzz-no-match-with-a-long-query".'; - expect(find.text(message), findsOneWidget); - expectNormalTextStyle(tester, message); - expect( - tester.renderObject(find.text(message)).size.height, - greaterThan(30), - reason: 'the query message must wrap instead of being cut to one line', - ); - expect( - find.widgetWithText(CupertinoButton, 'Clear search'), - findsOneWidget, - ); - }); - testWidgets('Cupertino load error under MaterialApp uses normal text', ( tester, ) async { diff --git a/app/test/features/chat/ui/sessions/chat_session_row_layout_test.dart b/app/test/features/chat/ui/sessions/chat_session_row_layout_test.dart index 0a1602b6..35e5d91e 100644 --- a/app/test/features/chat/ui/sessions/chat_session_row_layout_test.dart +++ b/app/test/features/chat/ui/sessions/chat_session_row_layout_test.dart @@ -109,10 +109,22 @@ void main() { test('meta and status come only from the row', () { expect( chatSessionMeta({'directory': '/work', 'model': 'model-a'}), - '/work · model-a', + 'opencode · model-a · /work', ); - expect(chatSessionMeta({'directory': '/work'}), '/work'); - expect(chatSessionMeta({}), ''); + expect(chatSessionMeta({'directory': '/work'}), 'opencode · /work'); + expect(chatSessionMeta({}), 'opencode'); + // The agent kind is the row's backend; the home folder reads as ~. + expect( + chatSessionMeta({ + 'backend': 'claude', + 'model': 'opus', + 'directory': '/Users/alan/repos/pipelines', + }), + 'claude · opus · ~/repos/pipelines', + ); + expect(homeRelativePath('/home/dev/x'), '~/x'); + expect(homeRelativePath('/Users/alan'), '~'); + expect(homeRelativePath('/srv/work'), '/srv/work'); expect(chatSessionRowStatus({}, unseen: false), isNull); expect(chatSessionRowStatus({}, unseen: true), 'New'); @@ -157,9 +169,9 @@ void main() { // As on the web: the unread word trails the title; the muted meta line // leads with the recency. expect(find.text('Starred chat'), findsOneWidget); - expect(find.text('5 min ago · /work · model-a'), findsOneWidget); + expect(find.text('5 min ago · opencode · model-a · /work'), findsOneWidget); expect(find.text('New'), findsOneWidget); - expect(find.text('2 hr ago · /work'), findsOneWidget); + expect(find.text('2 hr ago · opencode · /work'), findsOneWidget); expect( (tester.getCenter(find.text('Starred chat')).dy - tester.getCenter(find.text('New')).dy) @@ -171,7 +183,10 @@ void main() { // must not be rendered at the title's body size. The colour-only style the // row passes merges with the tile's own `DefaultTextStyle`. final titleStyle = _styleOf(tester, 'Starred chat'); - final metaStyle = _styleOf(tester, '5 min ago · /work · model-a'); + final metaStyle = _styleOf( + tester, + '5 min ago · opencode · model-a · /work', + ); expect(metaStyle.fontSize, lessThan(titleStyle.fontSize!)); expect(metaStyle.fontSize, 12.0); expect(_styleOf(tester, 'New').fontSize, titleStyle.fontSize); @@ -215,8 +230,8 @@ void main() { expect(tester.takeException(), isNull); const title = 'A conversation title long enough to need an ellipsis'; const meta = - '3 days ago · /a/very/long/directory/that/must/ellipsise · ' - 'provider/an-extremely-long-recorded-model-id'; + '3 days ago · opencode · provider/an-extremely-long-recorded-model-id' + ' · /a/very/long/directory/that/must/ellipsise'; final titleParagraph = tester.renderObject( find.text(title), ); diff --git a/app/test/features/chat/ui/sessions/chat_session_row_material_test.dart b/app/test/features/chat/ui/sessions/chat_session_row_material_test.dart index eeb951ff..b6d6fa72 100644 --- a/app/test/features/chat/ui/sessions/chat_session_row_material_test.dart +++ b/app/test/features/chat/ui/sessions/chat_session_row_material_test.dart @@ -73,9 +73,9 @@ void main() { ], isUnseen: (session) => session['id'] == 's1'); expect(find.text('Starred chat'), findsOneWidget); - expect(find.text('5 min ago · /work · model-a'), findsOneWidget); + expect(find.text('5 min ago · opencode · model-a · /work'), findsOneWidget); expect(find.text('New'), findsOneWidget); - expect(find.text('2 hr ago · /work'), findsOneWidget); + expect(find.text('2 hr ago · opencode · /work'), findsOneWidget); // As on the web, the unread word shares the title's line. expect( (tester.getCenter(find.text('Starred chat')).dy - @@ -85,8 +85,12 @@ void main() { ); // The meta line is the theme's muted colour, not the title colour. - final meta = tester.widget(find.text('5 min ago · /work · model-a')); - final context = tester.element(find.text('5 min ago · /work · model-a')); + final meta = tester.widget( + find.text('5 min ago · opencode · model-a · /work'), + ); + final context = tester.element( + find.text('5 min ago · opencode · model-a · /work'), + ); expect(meta.style?.color, Theme.of(context).colorScheme.onSurfaceVariant); // Native Material separators sit between rows, not around the group. @@ -150,8 +154,8 @@ void main() { expect(tester.takeException(), isNull); const title = 'A conversation title long enough to need an ellipsis'; const meta = - '3 days ago · /a/very/long/directory/that/must/ellipsise · ' - 'provider/an-extremely-long-recorded-model-id'; + '3 days ago · opencode · provider/an-extremely-long-recorded-model-id' + ' · /a/very/long/directory/that/must/ellipsise'; final titleParagraph = tester.renderObject( find.text(title), ); diff --git a/app/test/features/chat/ui/sessions/chat_sessions_screen_test.dart b/app/test/features/chat/ui/sessions/chat_sessions_screen_test.dart index 366a1512..dea160f9 100644 --- a/app/test/features/chat/ui/sessions/chat_sessions_screen_test.dart +++ b/app/test/features/chat/ui/sessions/chat_sessions_screen_test.dart @@ -36,7 +36,9 @@ void main() { ); await tester.pump(); - pending.complete({'chat_sessions': [session]}); + pending.complete({ + 'chat_sessions': [session], + }); await tester.pumpAndSettle(); expect(localStore.state?.watermark('deep-linked'), greaterThan(0)); @@ -90,23 +92,6 @@ void main() { }, ); - testWidgets('material search distinguishes no-match and clears back', ( - tester, - ) async { - final gateway = FakeChatGateway() - ..sessionsReply = {'chat_sessions': sampleSessions()}; - await pumpMaterialChat(tester, gateway); - - await tester.enterText(find.byType(TextField), 'zzz'); - await tester.pumpAndSettle(); - expect(find.text('No chats match "zzz".'), findsOneWidget); - expect(find.text('Open chat'), findsNothing); - - await tester.tap(find.text('Clear search')); - await tester.pumpAndSettle(); - expect(find.text('Open chat'), findsOneWidget); - }); - testWidgets('material empty server shows the distinct empty message', ( tester, ) async { @@ -124,14 +109,9 @@ void main() { await pumpCupertinoChat(tester, gateway); expect(find.byType(CupertinoPageScaffold), findsOneWidget); - expect(find.byType(CupertinoSearchTextField), findsOneWidget); + // The list has no search field; New chat and Refresh are the actions. + expect(find.byType(CupertinoSearchTextField), findsNothing); expect(find.byType(Scaffold), findsNothing); - expect( - tester.getTopLeft(find.byType(CupertinoSearchTextField)).dy, - greaterThanOrEqualTo( - tester.getBottomLeft(find.byType(CupertinoNavigationBar)).dy, - ), - ); expect(find.text('Chats · /work'), findsOneWidget); expect(find.text('Chats · /else'), findsOneWidget); @@ -168,40 +148,6 @@ void main() { }, ); - testWidgets( - 'Cupertino no-match message wraps and Clear search is its own button', - (tester) async { - usePhoneSurface(tester); - final semantics = tester.ensureSemantics(); - final gateway = FakeChatGateway() - ..sessionsReply = {'chat_sessions': sampleSessions()}; - await pumpCupertinoChat(tester, gateway); - - const query = 'zzz-no-match-with-a-long-query'; - await tester.enterText(find.byType(CupertinoSearchTextField), query); - await tester.pumpAndSettle(); - - const message = 'No chats match "zzz-no-match-with-a-long-query".'; - expect(find.text(message), findsOneWidget); - expect(find.text('Open chat'), findsNothing); - final messageBox = tester.renderObject(find.text(message)); - expect( - messageBox.size.height, - greaterThan(30), - reason: 'the query message must wrap instead of being cut to one line', - ); - - final clear = find.bySemanticsLabel('Clear search'); - expect(clear, findsOneWidget); - expect(tester.getSemantics(clear).label, 'Clear search'); - - await tester.tap(find.text('Clear search')); - await tester.pumpAndSettle(); - expect(find.text('Open chat'), findsOneWidget); - semantics.dispose(); - }, - ); - testWidgets( 'Cupertino load failure wraps the reason and hides the empty message', (tester) async { @@ -229,30 +175,6 @@ void main() { }, ); - testWidgets('Cupertino no-match message survives 2x text scaling', ( - tester, - ) async { - usePhoneSurface(tester); - tester.platformDispatcher.textScaleFactorTestValue = 2; - addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue); - final gateway = FakeChatGateway() - ..sessionsReply = {'chat_sessions': sampleSessions()}; - await pumpCupertinoChat(tester, gateway); - - await tester.enterText( - find.byType(CupertinoSearchTextField), - 'zzz-no-match-with-a-long-query', - ); - await tester.pumpAndSettle(); - - expect( - find.text('No chats match "zzz-no-match-with-a-long-query".'), - findsOneWidget, - ); - expect(find.text('Clear search'), findsOneWidget); - expect(tester.takeException(), isNull); - }); - testWidgets('duplicate Cupertino titles disambiguate the action labels', ( tester, ) async { diff --git a/app/test/features/chat/ui/sessions/chat_toolbar_test.dart b/app/test/features/chat/ui/sessions/chat_toolbar_test.dart index b8b93a15..f324c0fd 100644 --- a/app/test/features/chat/ui/sessions/chat_toolbar_test.dart +++ b/app/test/features/chat/ui/sessions/chat_toolbar_test.dart @@ -6,7 +6,7 @@ import 'chat_test_harness.dart'; import 'fake_chat_gateway.dart'; void main() { - testWidgets('embedded, New chat sits beside search on one toolbar row', ( + testWidgets('embedded, New chat and Refresh share one actions row', ( tester, ) async { final gateway = FakeChatGateway() @@ -26,13 +26,14 @@ void main() { ); await tester.pumpAndSettle(); - final search = tester.getCenter(find.byType(TextField)); + // No search field: New chat and Refresh share one actions row. + expect(find.byType(TextField), findsNothing); final create = find.byKey(const Key('chat-new-chat')); + final refresh = find.byKey(const Key('chat-refresh')); + expect(create, findsOneWidget); expect( - find.descendant(of: create, matching: find.text('New chat')), - findsOneWidget, + (tester.getCenter(create).dy - tester.getCenter(refresh).dy).abs(), + lessThan(4), ); - expect((tester.getCenter(create).dy - search.dy).abs(), lessThan(4)); - expect(tester.getCenter(create).dx, greaterThan(search.dx)); }); }