diff --git a/app/lib/features/chat/ui/sessions/session_list_cupertino.dart b/app/lib/features/chat/ui/sessions/session_list_cupertino.dart index 85d439d8..20c2d75d 100644 --- a/app/lib/features/chat/ui/sessions/session_list_cupertino.dart +++ b/app/lib/features/chat/ui/sessions/session_list_cupertino.dart @@ -148,12 +148,12 @@ class _CupertinoSessionRow extends StatelessWidget { final id = '${session['id'] ?? ''}'; // Cupertino's grouped list owns the separators and the native tile metrics; // the row only decides where the title, its state word and the muted meta - // go. The meta line (recency first) keeps the tile's native 12pt style by + // go. Each metadata line keeps the tile's native 12pt style by // passing colour only, so `Text` merges with `CupertinoListTile`'s own // `DefaultTextStyle` instead of overriding it with the title's size. final theme = CupertinoTheme.of(context); final secondary = CupertinoColors.secondaryLabel.resolveFrom(context); - final meta = chatSessionRowMetaLine(session); + final meta = chatSessionRowMetaLines(session); final status = chatSessionRowStatus(session, unseen: unseen); final statusStyle = TextStyle( color: status == 'Closed' ? secondary : theme.primaryColor, @@ -179,11 +179,18 @@ class _CupertinoSessionRow extends StatelessWidget { ), subtitle: meta.isEmpty ? null - : Text( - meta, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle(color: secondary), + : Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + for (final line in meta) + Text( + line, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle(color: secondary), + ), + ], ), onTap: () => onOpen(session), trailing: Row( diff --git a/app/lib/features/chat/ui/sessions/session_list_material.dart b/app/lib/features/chat/ui/sessions/session_list_material.dart index c67bcb24..efc92f21 100644 --- a/app/lib/features/chat/ui/sessions/session_list_material.dart +++ b/app/lib/features/chat/ui/sessions/session_list_material.dart @@ -151,14 +151,14 @@ class _MaterialSessionRow extends StatelessWidget { @override Widget build(BuildContext context) { final id = '${session['id'] ?? ''}'; - // The same content as the Cupertino row: title with the unread/closed word - // trailing, then a muted `recency · directory · model` line. + // The same content as the Cupertino row: title and state, then each + // recorded metadata field on its own muted line. // `ListTile` does not force one ellipsised line like `CupertinoListTile`, // so both text widgets state their line limit themselves. The meta line // passes colour only, so it keeps the tile's native subtitle style. final theme = Theme.of(context); final secondary = theme.colorScheme.onSurfaceVariant; - final meta = chatSessionRowMetaLine(session); + final meta = chatSessionRowMetaLines(session); final status = chatSessionRowStatus(session, unseen: unseen); final statusStyle = TextStyle( color: status == 'Closed' ? secondary : theme.colorScheme.primary, @@ -179,11 +179,18 @@ class _MaterialSessionRow extends StatelessWidget { ), subtitle: meta.isEmpty ? null - : Text( - meta, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle(color: secondary), + : Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + for (final line in meta) + Text( + line, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle(color: secondary), + ), + ], ), onTap: () => onOpen(session), trailing: Row( 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 eeee99a3..7d022ef9 100644 --- a/app/lib/features/chat/ui/sessions/session_row_style.dart +++ b/app/lib/features/chat/ui/sessions/session_row_style.dart @@ -43,16 +43,14 @@ String relativeChatSessionTime(Object? updatedAt, {DateTime? now}) { return '${then.day} ${_shortMonths[then.month - 1]}'; } -/// 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) { +/// Recorded session fields rendered independently beneath the title. +List chatSessionMetaLines(JsonMap session) { final backend = '${session['backend'] ?? ''}'.trim(); return [ backend.isEmpty ? 'opencode' : backend, '${session['model'] ?? ''}'.trim(), homeRelativePath('${session['directory'] ?? ''}'.trim()), - ].where((part) => part.isNotEmpty).join(' · '); + ].where((part) => part.isNotEmpty).toList(); } final _homePrefix = RegExp(r'^(/Users/[^/]+|/home/[^/]+|/root)(?=/|$)'); @@ -60,12 +58,11 @@ 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`). -String chatSessionRowMetaLine(JsonMap session, {DateTime? now}) => [ +/// All secondary row information, each as a distinct line. +List chatSessionRowMetaLines(JsonMap session, {DateTime? now}) => [ relativeChatSessionTime(session['updated_at'], now: now), - chatSessionMeta(session), -].where((part) => part.isNotEmpty).join(' · '); + ...chatSessionMetaLines(session), +].where((part) => part.isNotEmpty).toList(); /// The word on the row's trailing edge while the session has news or a state: /// `Closed` from the row, otherwise `New`. A streaming session deliberately 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 35e5d91e..3d9a31f5 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 @@ -107,20 +107,21 @@ void main() { }); test('meta and status come only from the row', () { - expect( - chatSessionMeta({'directory': '/work', 'model': 'model-a'}), - 'opencode · model-a · /work', - ); - expect(chatSessionMeta({'directory': '/work'}), 'opencode · /work'); - expect(chatSessionMeta({}), 'opencode'); + expect(chatSessionMetaLines({'directory': '/work', 'model': 'model-a'}), [ + 'opencode', + 'model-a', + '/work', + ]); + expect(chatSessionMetaLines({'directory': '/work'}), ['opencode', '/work']); + expect(chatSessionMetaLines({}), ['opencode']); // The agent kind is the row's backend; the home folder reads as ~. expect( - chatSessionMeta({ + chatSessionMetaLines({ 'backend': 'claude', 'model': 'opus', 'directory': '/Users/alan/repos/pipelines', }), - 'claude · opus · ~/repos/pipelines', + ['claude', 'opus', '~/repos/pipelines'], ); expect(homeRelativePath('/home/dev/x'), '~/x'); expect(homeRelativePath('/Users/alan'), '~'); @@ -169,9 +170,12 @@ 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 · opencode · model-a · /work'), findsOneWidget); + expect(find.text('5 min ago'), findsOneWidget); + expect(find.text('model-a'), findsOneWidget); expect(find.text('New'), findsOneWidget); - expect(find.text('2 hr ago · opencode · /work'), findsOneWidget); + expect(find.text('2 hr ago'), findsOneWidget); + expect(find.text('opencode'), findsNWidgets(2)); + expect(find.text('/work'), findsNWidgets(2)); expect( (tester.getCenter(find.text('Starred chat')).dy - tester.getCenter(find.text('New')).dy) @@ -183,10 +187,7 @@ 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 · opencode · model-a · /work', - ); + final metaStyle = _styleOf(tester, '5 min ago'); expect(metaStyle.fontSize, lessThan(titleStyle.fontSize!)); expect(metaStyle.fontSize, 12.0); expect(_styleOf(tester, 'New').fontSize, titleStyle.fontSize); @@ -229,15 +230,18 @@ void main() { expect(tester.takeException(), isNull); const title = 'A conversation title long enough to need an ellipsis'; - const meta = - '3 days ago · opencode · provider/an-extremely-long-recorded-model-id' - ' · /a/very/long/directory/that/must/ellipsise'; + const meta = '/a/very/long/directory/that/must/ellipsise'; final titleParagraph = tester.renderObject( find.text(title), ); expect(titleParagraph.maxLines, 1); expect(titleParagraph.didExceedMaxLines, isTrue); - final metaParagraph = tester.renderObject(find.text(meta)); + final metaParagraph = tester.renderObject( + find.descendant( + of: find.byKey(const Key('chat-row-s1')), + matching: find.text(meta), + ), + ); expect(metaParagraph.maxLines, 1); expect(metaParagraph.didExceedMaxLines, isTrue); 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 65db673f..0e6c0aa8 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 @@ -74,9 +74,12 @@ void main() { ], isUnseen: (session) => session['id'] == 's1'); expect(find.text('Starred chat'), findsOneWidget); - expect(find.text('5 min ago · opencode · model-a · /work'), findsOneWidget); + expect(find.text('5 min ago'), findsOneWidget); + expect(find.text('opencode'), findsNWidgets(2)); + expect(find.text('model-a'), findsOneWidget); + expect(find.text('/work'), findsNWidgets(2)); expect(find.text('New'), findsOneWidget); - expect(find.text('2 hr ago · opencode · /work'), findsOneWidget); + expect(find.text('2 hr ago'), findsOneWidget); // As on the web, the unread word shares the title's line. expect( (tester.getCenter(find.text('Starred chat')).dy - @@ -86,12 +89,8 @@ void main() { ); // The meta line is the theme's muted colour, not the title colour. - 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'), - ); + final meta = tester.widget(find.text('5 min ago')); + final context = tester.element(find.text('5 min ago')); expect(meta.style?.color, Theme.of(context).colorScheme.onSurfaceVariant); // Native Material separators sit between rows, not around the group. @@ -155,15 +154,18 @@ void main() { expect(tester.takeException(), isNull); const title = 'A conversation title long enough to need an ellipsis'; - const meta = - '3 days ago · opencode · provider/an-extremely-long-recorded-model-id' - ' · /a/very/long/directory/that/must/ellipsise'; + const meta = '/a/very/long/directory/that/must/ellipsise'; final titleParagraph = tester.renderObject( find.text(title), ); expect(titleParagraph.maxLines, 1); expect(titleParagraph.didExceedMaxLines, isTrue); - final metaParagraph = tester.renderObject(find.text(meta)); + final metaParagraph = tester.renderObject( + find.descendant( + of: find.byKey(const Key('chat-row-s1')), + matching: find.text(meta), + ), + ); expect(metaParagraph.maxLines, 1); expect(metaParagraph.didExceedMaxLines, isTrue); @@ -184,9 +186,14 @@ void main() { ); } - // Two lines: the title/word line, then the muted recency/meta line. + // The title/state and every metadata field occupy distinct lines. expect( - tester.getCenter(find.text(meta)).dy, + tester.getCenter( + find.descendant( + of: find.byKey(const Key('chat-row-s1')), + matching: find.text(meta).last, + ), + ).dy, greaterThan(tester.getCenter(find.text(title)).dy), ); });