feat(chat): contact-list chat rows with avatar, time and unread emphasis

Rows lead with a circular harness avatar, put the time beside the title,
collapse metadata into one muted model · folder line and trail the
actions menu. Unread chats are bold with an accent time and dot, running
chats badge their avatar, and Star moves into the menu.
This commit is contained in:
2026-10-30 21:05:24 +00:00
parent 44b2cff347
commit 4c4dcbbd14
16 changed files with 519 additions and 555 deletions
@@ -15,7 +15,10 @@ void main() {
..sessionsReply = {'chat_sessions': sampleSessions()};
await pumpMaterialChat(tester, gateway);
await tester.tap(find.byKey(const Key('chat-star-s2')));
// Starring lives in the row's actions menu.
await tester.tap(find.byKey(const Key('chat-actions-s2')));
await tester.pumpAndSettle();
await tester.tap(find.text('Star'));
await tester.pumpAndSettle();
expect(gateway.lastFields('chat_star'), {
'chat_query': {'session_id': 's2', 'starred': true},
@@ -1,69 +0,0 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/ui/sessions/session_row_content.dart';
import 'package:pipelines_app/features/chat/ui/sessions/session_actions.dart';
void main() {
for (final cupertino in [false, true]) {
for (final width in [120.0, 360.0]) {
testWidgets(
'right-side recency/actions, Cupertino=$cupertino width=$width',
(tester) async {
final star = SessionStarButton(
session: const {'id': 's'},
onPressed: () {},
);
final more = SessionActionsButton(
session: const {'id': 's'},
onSelected: (_) {},
);
final row = Center(
child: SizedBox(
width: width,
child: ChatSessionRowContent(
title: 'Chat title',
status: null,
recency: '5 min ago',
meta: const ['opencode', 'model', '/work'],
titleStyle: const TextStyle(fontSize: 17),
metaStyle: const TextStyle(fontSize: 12),
statusStyle: const TextStyle(fontSize: 12),
actions: [
KeyedSubtree(key: const Key('star'), child: star),
KeyedSubtree(key: const Key('more'), child: more),
],
),
),
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: row))
: MaterialApp(home: Scaffold(body: row)),
);
await tester.pumpAndSettle();
final backend = tester.getRect(find.text('opencode'));
final time = tester.getRect(find.text('5 min ago'));
final favorite = tester.getRect(find.byKey(const Key('star')));
final menu = tester.getRect(find.byKey(const Key('more')));
expect(time.left, greaterThanOrEqualTo(backend.right));
expect(
time.top,
closeTo(backend.top, 0.1),
reason: 'Timestamp belongs beside metadata, not below it',
);
expect(favorite.left, greaterThanOrEqualTo(backend.right));
expect(menu.left, greaterThanOrEqualTo(backend.right));
if (width == 360) {
expect(
favorite.top,
lessThan(tester.getRect(find.text('/work')).bottom),
);
expect(menu.top, closeTo(favorite.top, 0.1));
}
expect(tester.takeException(), isNull);
},
);
}
}
}
@@ -53,18 +53,18 @@ void main() {
],
};
await pumpMaterialChat(tester, gateway);
expect(find.text('New'), findsNothing);
expect(find.byKey(const Key('chat-row-unread')), findsNothing);
updatedAt = 2000;
await tester.tap(find.byKey(const Key('chat-refresh')));
await tester.pumpAndSettle();
expect(find.text('New'), findsNothing);
expect(find.byKey(const Key('chat-row-unread')), findsNothing);
await tester.tap(find.byKey(const Key('chat-row-s1')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('chat-refresh')));
await tester.pumpAndSettle();
expect(find.text('New'), findsNothing);
expect(find.byKey(const Key('chat-row-unread')), findsNothing);
});
testWidgets('a closed row never reports New after newer activity', (
@@ -85,7 +85,7 @@ void main() {
],
};
await pumpMaterialChat(tester, gateway);
expect(find.text('New'), findsNothing);
expect(find.byKey(const Key('chat-row-unread')), findsNothing);
// Another device moved the chat on and closed it after this device read it.
updatedAt = 2000;
@@ -94,11 +94,11 @@ void main() {
await tester.pumpAndSettle();
await expandClosedChats(tester);
expect(find.text('New'), findsNothing);
expect(find.byKey(const Key('chat-row-unread')), findsNothing);
expect(
find.descendant(
of: find.byKey(const Key('chat-row-s1')),
matching: find.text('Closed'),
matching: find.textContaining(RegExp(r'^Closed( ·|$)')),
),
findsOneWidget,
);
@@ -3,6 +3,7 @@ import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/ui/sessions/session_list_cupertino.dart';
import 'package:pipelines_app/features/chat/ui/sessions/session_row_content.dart';
import 'package:pipelines_app/features/chat/ui/sessions/session_row_style.dart';
/// A grouped Cupertino list, the host the web client runs on macOS/iOS.
@@ -32,7 +33,9 @@ Future<void> _pumpRows(
),
),
);
await tester.pumpAndSettle();
// A running row's activity badge animates for as long as it runs.
await tester.pump();
await tester.pump(const Duration(milliseconds: 100));
}
void _useNarrowText(WidgetTester tester) {
@@ -47,7 +50,7 @@ void _useNarrowText(WidgetTester tester) {
/// The resolved style a text is painted with, after merging with the host's
/// own `DefaultTextStyle`.
TextStyle _styleOf(WidgetTester tester, String text) =>
tester.renderObject<RenderParagraph>(find.text(text)).text.style!;
tester.renderObject<RenderParagraph>(find.textContaining(text)).text.style!;
void main() {
test('relative recency uses the web wording and never invents a time', () {
@@ -106,22 +109,21 @@ void main() {
);
});
test('meta and status come only from the row', () {
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 ~.
test('the subtitle and status come only from the row', () {
expect(
chatSessionMetaLines({
chatSessionSubtitle({'directory': '/work', 'model': 'model-a'}),
'model-a · /work',
);
expect(chatSessionSubtitle({'directory': '/work'}), '/work');
expect(chatSessionSubtitle({}), '');
// The harness is the avatar, not a word; the home folder reads as ~.
expect(
chatSessionSubtitle({
'backend': 'claude',
'model': 'opus',
'directory': '/Users/alan/repos/pipelines',
}),
['claude', 'opus', '~/repos/pipelines'],
'opus · ~/repos/pipelines',
);
expect(homeRelativePath('/home/dev/x'), '~/x');
expect(homeRelativePath('/Users/alan'), '~');
@@ -129,7 +131,6 @@ void main() {
expect(chatSessionRowStatus({}, unseen: false), isNull);
expect(chatSessionRowStatus({}, unseen: true), 'New');
// Running never hides an unread message; the native spinner is separate.
expect(chatSessionRowStatus({'running': true}, unseen: true), 'New');
expect(chatSessionRowStatus({'running': true}, unseen: false), isNull);
expect(
@@ -138,24 +139,27 @@ void main() {
);
});
testWidgets('a row reads title, muted meta and trailing recency/unread', (
testWidgets('a row reads avatar, title with time, one muted line and menu', (
tester,
) async {
final now = DateTime.now();
final sessions = <JsonMap>[
{
'id': 's1',
'title': 'Starred chat',
'title': 'Unread chat',
'backend': 'claude',
'directory': '/work',
'model': 'model-a',
'starred': true,
'updated_at': now
.subtract(const Duration(minutes: 5))
.millisecondsSinceEpoch,
},
{
'id': 's2',
'title': 'Open chat',
'title': 'Read chat',
'directory': '/work',
'running': true,
'updated_at': now
.subtract(const Duration(hours: 2, minutes: 30))
.millisecondsSinceEpoch,
@@ -167,41 +171,52 @@ void main() {
isUnseen: (session) => session['id'] == 's1',
);
// 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'), findsOneWidget);
expect(find.text('model-a'), findsOneWidget);
expect(find.text('New'), 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('New')).dy,
greaterThan(tester.getCenter(find.text('Starred chat')).dy),
final title = tester.getRect(find.textContaining('Unread chat'));
final time = tester.getRect(find.text('5 min ago'));
final subtitle = tester.getRect(find.text('model-a · /work'));
final avatar = tester.getRect(
find.descendant(
of: find.byKey(const Key('chat-row-s1')),
matching: find.byType(ChatSessionAvatar),
),
);
// Avatar leads, the time trails the title on its line, the muted line
// sits beneath, and the menu trails the whole row.
expect(avatar.right, lessThanOrEqualTo(title.left));
expect(time.left, greaterThan(title.right));
expect(time.center.dy, closeTo(title.center.dy, 2));
expect(subtitle.top, greaterThanOrEqualTo(title.bottom - 1));
expect(
tester.getCenter(find.text('5 min ago')).dx,
greaterThan(tester.getCenter(find.text('Starred chat')).dx),
tester.getRect(find.byKey(const Key('chat-actions-s1'))).left,
greaterThanOrEqualTo(time.right),
);
// Metadata and state use native caption roles, not title-sized text.
final titleStyle = _styleOf(tester, 'Starred chat');
final metaStyle = _styleOf(tester, '5 min ago');
expect(metaStyle.fontSize, lessThan(titleStyle.fontSize!));
expect(
metaStyle.fontSize,
CupertinoTheme.of(
tester.element(find.text('5 min ago')),
).textTheme.tabLabelTextStyle.fontSize,
);
expect(_styleOf(tester, 'New').fontSize, metaStyle.fontSize);
// Unread is bold with an accent time and dot; read rows are not.
expect(_styleOf(tester, 'Unread chat').fontWeight, FontWeight.w700);
expect(_styleOf(tester, 'Read chat').fontWeight, FontWeight.w500);
expect(find.byKey(const Key('chat-row-unread')), findsOneWidget);
final accent = CupertinoTheme.of(
tester.element(find.text('5 min ago')),
).primaryColor;
expect(_styleOf(tester, '5 min ago').color, accent);
expect(_styleOf(tester, '2 hr ago').color, isNot(accent));
// Each session is still its own native tile with its own actions, so the
// inset group draws the separator between them.
// Starred shows a small star by the title; running a badge on the avatar.
expect(
find.descendant(
of: find.byKey(const Key('chat-row-s1')),
matching: find.byKey(const Key('chat-row-starred')),
),
findsOneWidget,
);
expect(
find.descendant(
of: find.byKey(const Key('chat-row-s2')),
matching: find.byKey(const Key('chat-row-working')),
),
findsOneWidget,
);
expect(find.byType(CupertinoListTile), findsNWidgets(2));
expect(find.byKey(const Key('chat-star-s1')), findsOneWidget);
expect(find.byKey(const Key('chat-actions-s2')), findsOneWidget);
expect(
tester.getTopLeft(find.byKey(const Key('chat-row-s2'))).dy,
greaterThan(
@@ -210,7 +225,7 @@ void main() {
);
});
testWidgets('at 320px 2x the long title and meta ellipsise, the word does not', (
testWidgets('at 320px 2x the long title and subtitle ellipsise', (
tester,
) async {
_useNarrowText(tester);
@@ -234,43 +249,29 @@ void main() {
], isUnseen: (session) => session['id'] == 's1');
expect(tester.takeException(), isNull);
const title = 'A conversation title long enough to need an ellipsis';
const meta = '/a/very/long/directory/that/must/ellipsise';
final titleParagraph = tester.renderObject<RenderParagraph>(
find.text(title),
final title = tester.renderObject<RenderParagraph>(
find.text('A conversation title long enough to need an ellipsis'),
);
expect(titleParagraph.maxLines, 2);
expect(titleParagraph.didExceedMaxLines, isTrue);
final metaParagraph = tester.renderObject<RenderParagraph>(
find.descendant(
of: find.byKey(const Key('chat-row-s1')),
matching: find.text(meta),
expect(title.maxLines, 1);
expect(title.didExceedMaxLines, isTrue);
final subtitle = tester.renderObject<RenderParagraph>(
find.text(
'provider/an-extremely-long-recorded-model-id · '
'/a/very/long/directory/that/must/ellipsise',
),
);
expect(metaParagraph.maxLines, 2);
expect(metaParagraph.didExceedMaxLines, isTrue);
expect(subtitle.maxLines, 1);
expect(subtitle.didExceedMaxLines, isTrue);
// The state word is the row's only unread marker: at the smallest supported
// surface with 2x text it stays whole (it is scaled down only when even the
// full text column cannot hold it) and inside the tile's trailing edge.
for (final row in ['s1', 'c1']) {
final word = row == 's1' ? 'New' : 'Closed';
final paragraph = tester.renderObject<RenderParagraph>(find.text(word));
expect(paragraph.maxLines, 1);
expect(paragraph.didExceedMaxLines, isFalse, reason: '$word is clipped');
final rect = tester.getRect(find.text(word));
expect(rect.width, greaterThan(0));
// The time and the Closed word stay inside their row.
for (final (row, word) in [('s1', '3 days ago'), ('c1', 'Closed')]) {
expect(
rect.right,
tester.getRect(find.textContaining(word)).right,
lessThanOrEqualTo(
tester.getRect(find.byKey(Key('chat-row-$row'))).right,
),
);
}
expect(
tester.getCenter(find.text('New')).dy,
greaterThan(tester.getCenter(find.text(title)).dy),
);
expect(find.byKey(const Key('chat-row-unread')), findsOneWidget);
});
}
@@ -3,6 +3,7 @@ import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/ui/sessions/session_list_material.dart';
import 'package:pipelines_app/features/chat/ui/sessions/session_row_content.dart';
import 'expand_closed.dart';
/// The Android host: a Material grouped list with its native separators.
@@ -49,14 +50,14 @@ void _useNarrowText(WidgetTester tester) {
}
void main() {
testWidgets('a Material row reads title, muted meta and trailing recency', (
testWidgets('a Material row reads avatar, title with time and muted line', (
tester,
) async {
final now = DateTime.now();
await _pumpRows(tester, [
{
'id': 's1',
'title': 'Starred chat',
'title': 'Unread chat',
'directory': '/work',
'model': 'model-a',
'updated_at': now
@@ -65,7 +66,7 @@ void main() {
},
{
'id': 's2',
'title': 'Open chat',
'title': 'Read chat',
'directory': '/work',
'updated_at': now
.subtract(const Duration(hours: 2, minutes: 30))
@@ -73,26 +74,38 @@ void main() {
},
], isUnseen: (session) => session['id'] == 's1');
expect(find.text('Starred chat'), 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'), findsOneWidget);
final title = tester.getRect(find.text('Unread chat'));
final time = tester.getRect(find.text('5 min ago'));
expect(time.left, greaterThan(title.right));
expect(time.center.dy, closeTo(title.center.dy, 2));
expect(
tester.getCenter(find.text('New')).dy,
greaterThan(tester.getCenter(find.text('Starred chat')).dy),
tester.getRect(find.text('model-a · /work')).top,
greaterThanOrEqualTo(title.bottom - 1),
);
expect(find.text('/work'), findsOneWidget);
expect(
tester.getCenter(find.text('5 min ago')).dx,
greaterThan(tester.getCenter(find.text('Starred chat')).dx),
tester.getRect(find.byType(ChatSessionAvatar).first).right,
lessThanOrEqualTo(title.left),
);
// The meta line is the theme's muted colour, not the title colour.
final meta = tester.widget<Text>(find.text('5 min ago'));
final context = tester.element(find.text('5 min ago'));
expect(meta.style?.color, Theme.of(context).colorScheme.onSurfaceVariant);
// Unread: bold title, accent time and a dot; the read row stays muted.
final scheme = Theme.of(tester.element(find.text('5 min ago'))).colorScheme;
expect(
tester.widget<Text>(find.text('5 min ago')).style?.color,
scheme.primary,
);
expect(
tester.widget<Text>(find.text('2 hr ago')).style?.color,
scheme.onSurfaceVariant,
);
expect(find.byKey(const Key('chat-row-unread')), findsOneWidget);
expect(
find.descendant(
of: find.byKey(const Key('chat-row-s1')),
matching: find.byKey(const Key('chat-row-unread')),
),
findsOneWidget,
);
// Native Material separators sit between rows, not around the group.
expect(find.byType(Divider), findsOneWidget);
@@ -102,7 +115,6 @@ void main() {
tester.getBottomLeft(find.byKey(const Key('chat-row-s1'))).dy,
),
);
expect(find.byKey(const Key('chat-star-s1')), findsOneWidget);
expect(find.byKey(const Key('chat-actions-s2')), findsOneWidget);
});
@@ -119,18 +131,18 @@ void main() {
], section: 'Closed');
await expandClosedChats(tester);
// The section header also says Closed; the row's trailing word is its own.
// The section header also says Closed; the row's own line leads with it.
expect(
find.descendant(
of: find.byKey(const Key('chat-row-c1')),
matching: find.text('Closed'),
matching: find.text('Closed · /work'),
),
findsOneWidget,
);
expect(find.text('New'), findsNothing);
expect(find.byKey(const Key('chat-row-unread')), findsNothing);
});
testWidgets('at 320px 2x the Material row ellipsises text, not its word', (
testWidgets('at 320px 2x the Material row ellipsises and never overflows', (
tester,
) async {
_useNarrowText(tester);
@@ -141,6 +153,7 @@ void main() {
'title': 'A conversation title long enough to need an ellipsis',
'directory': '/a/very/long/directory/that/must/ellipsise',
'model': 'provider/an-extremely-long-recorded-model-id',
'starred': true,
'updated_at': now
.subtract(const Duration(days: 3))
.millisecondsSinceEpoch,
@@ -154,50 +167,24 @@ void main() {
], isUnseen: (session) => session['id'] == 's1');
expect(tester.takeException(), isNull);
const title = 'A conversation title long enough to need an ellipsis';
const meta = '/a/very/long/directory/that/must/ellipsise';
final titleParagraph = tester.renderObject<RenderParagraph>(
find.text(title),
final title = tester.renderObject<RenderParagraph>(
find.textContaining('A conversation title long enough'),
);
expect(titleParagraph.maxLines, 2);
expect(titleParagraph.didExceedMaxLines, isTrue);
final metaParagraph = tester.renderObject<RenderParagraph>(
find.descendant(
of: find.byKey(const Key('chat-row-s1')),
matching: find.text(meta),
),
expect(title.maxLines, 1);
expect(title.didExceedMaxLines, isTrue);
final subtitle = tester.renderObject<RenderParagraph>(
find.textContaining('provider/an-extremely-long-recorded-model-id'),
);
expect(metaParagraph.maxLines, 2);
expect(metaParagraph.didExceedMaxLines, isTrue);
// `New`/`Closed` is the row's only unread marker; it stays whole at the
// smallest supported surface with 2x text.
for (final row in ['s1', 'c1']) {
final word = row == 's1' ? 'New' : 'Closed';
final paragraph = tester.renderObject<RenderParagraph>(find.text(word));
expect(paragraph.maxLines, 1);
expect(paragraph.didExceedMaxLines, isFalse, reason: '$word is clipped');
final rect = tester.getRect(find.text(word));
expect(rect.width, greaterThan(0));
expect(subtitle.maxLines, 1);
expect(subtitle.didExceedMaxLines, isTrue);
for (final (row, word) in [('s1', '3 days ago'), ('c1', 'Closed')]) {
expect(
rect.right,
tester.getRect(find.textContaining(word)).right,
lessThanOrEqualTo(
tester.getRect(find.byKey(Key('chat-row-$row'))).right,
),
);
}
// The title/state and every metadata field occupy distinct lines.
expect(
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),
);
expect(find.byKey(const Key('chat-row-unread')), findsOneWidget);
});
}
@@ -144,7 +144,10 @@ void main() {
};
await pumpMaterialChat(tester, gateway);
await tester.tap(find.byKey(const Key('chat-star-s2')));
// Starring lives in the row's actions menu.
await tester.tap(find.byKey(const Key('chat-actions-s2')));
await tester.pumpAndSettle();
await tester.tap(find.text('Star'));
await tester.pumpAndSettle();
expect(gateway.lastFields('chat_star'), {
'chat_query': {'session_id': 's2', 'starred': true},
@@ -152,8 +155,8 @@ void main() {
expect(gateway.count('chat_sessions'), greaterThanOrEqualTo(2));
expect(
find.descendant(
of: find.byKey(const Key('chat-star-s2')),
matching: find.byIcon(Icons.star),
of: find.byKey(const Key('chat-row-s2')),
matching: find.byKey(const Key('chat-row-starred')),
),
findsOneWidget,
);
@@ -6,7 +6,6 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/ui/sessions/chat_session_local.dart';
import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_screen.dart';
import 'package:pipelines_app/features/chat/ui/sessions/session_row_content.dart';
import 'chat_test_harness.dart';
import 'fake_chat_gateway.dart';
@@ -83,16 +82,16 @@ void main() {
) async {
final fake = gateway();
await _pump(tester, fake);
expect(find.text('New'), findsNothing);
expect(find.byKey(const Key('chat-row-unread')), findsNothing);
fake.pushed.add(_event('s1'));
await tester.pumpAndSettle();
expect(find.text('New'), findsOneWidget);
expect(find.byKey(const Key('chat-row-unread')), findsOneWidget);
expect(fake.count('chat_sessions'), 1);
await tester.tap(find.byKey(const Key('chat-row-s1')));
await tester.pumpAndSettle();
expect(find.text('New'), findsNothing);
expect(find.byKey(const Key('chat-row-unread')), findsNothing);
});
testWidgets('usage frames and the open chat never raise New', (tester) async {
@@ -101,7 +100,7 @@ void main() {
fake.pushed.add(_event('s1'));
fake.pushed.add(_event('s1', kind: 'usage'));
await tester.pumpAndSettle();
expect(find.text('New'), findsNothing);
expect(find.byKey(const Key('chat-row-unread')), findsNothing);
});
testWidgets('leaving the conversation lets later activity mark it New', (
@@ -118,7 +117,7 @@ void main() {
'chat_permission': {'session_id': 's1'},
});
await tester.pumpAndSettle();
expect(find.text('New'), findsOneWidget);
expect(find.byKey(const Key('chat-row-unread')), findsOneWidget);
});
testWidgets('step and reasoning churn show loading, not New', (tester) async {
@@ -134,19 +133,14 @@ void main() {
});
await tester.pump();
await tester.pump();
expect(find.text('New'), findsNothing);
expect(
tester
.widget<ChatSessionRowContent>(find.byType(ChatSessionRowContent))
.loading,
isTrue,
);
expect(find.byKey(const Key('chat-row-unread')), findsNothing);
expect(find.byKey(const Key('chat-row-working')), findsOneWidget);
expect(find.byType(CircularProgressIndicator), findsOneWidget);
fake.pushed.add(_event('s1', kind: 'reasoning', delta: 'thinking'));
await tester.pump();
await tester.pump();
expect(find.text('New'), findsNothing);
expect(find.byKey(const Key('chat-row-unread')), findsNothing);
expect(fake.count('chat_sessions'), 1);
fake.pushed.add({
@@ -160,7 +154,7 @@ void main() {
await tester.pump();
await tester.pump();
expect(find.byType(CircularProgressIndicator), findsNothing);
expect(find.text('New'), findsNothing);
expect(find.byKey(const Key('chat-row-unread')), findsNothing);
});
testWidgets('an unread visible answer remains New while running', (
@@ -178,7 +172,7 @@ void main() {
});
fake.pushed.add(_event('s1'));
await tester.pumpAndSettle();
expect(find.text('New'), findsOneWidget);
expect(find.byKey(const Key('chat-row-unread')), findsOneWidget);
expect(find.byType(CircularProgressIndicator), findsNothing);
});
@@ -200,7 +194,7 @@ void main() {
});
await tester.pump();
await tester.pump();
expect(find.text('New'), findsNothing);
expect(find.byKey(const Key('chat-row-unread')), findsNothing);
expect(find.byType(CircularProgressIndicator), findsOneWidget);
fake.pushed.add({
@@ -220,7 +214,7 @@ void main() {
},
});
await tester.pumpAndSettle();
expect(find.text('New'), findsOneWidget);
expect(find.byKey(const Key('chat-row-unread')), findsOneWidget);
expect(find.byType(CircularProgressIndicator), findsNothing);
});
@@ -237,13 +231,13 @@ void main() {
},
});
await tester.pumpAndSettle();
expect(find.text('New'), findsNothing);
expect(find.byKey(const Key('chat-row-unread')), findsNothing);
fake.pushed.add({
'type': 'chat_permission',
'chat_permission': {'session_id': 's1', 'request_id': 'p2'},
});
await tester.pumpAndSettle();
expect(find.text('New'), findsOneWidget);
expect(find.byKey(const Key('chat-row-unread')), findsOneWidget);
});
testWidgets('updated_at alone never manufactures unread state', (
@@ -261,7 +255,7 @@ void main() {
await tester.pumpAndSettle();
fake.pushed.add(_event('unknown'));
await tester.pumpAndSettle();
expect(find.text('New'), findsNothing);
expect(find.byKey(const Key('chat-row-unread')), findsNothing);
await tester.pumpWidget(const SizedBox.shrink());
fake.pushed.add(_event('s1'));
await tester.pump();
@@ -290,7 +284,7 @@ void main() {
delayed.loaded.complete(const ChatSessionLocal());
await tester.pump();
await tester.pump();
expect(find.text('New'), findsNothing);
expect(find.byKey(const Key('chat-row-unread')), findsNothing);
expect(delayed.saved?.isUnseen('s1'), isFalse);
});
@@ -310,14 +304,14 @@ void main() {
await tester.pump();
await tester.pump();
expect(find.byType(CupertinoActivityIndicator), findsOneWidget);
expect(find.text('New'), findsNothing);
expect(find.byKey(const Key('chat-row-unread')), findsNothing);
fake.pushed.add(_event('s1'));
await tester.pumpAndSettle();
expect(find.text('New'), findsOneWidget);
expect(find.byKey(const Key('chat-row-unread')), findsOneWidget);
await tester.tap(find.byKey(const Key('chat-row-s1')));
await tester.pump();
await tester.pump();
expect(find.text('New'), findsNothing);
expect(find.byKey(const Key('chat-row-unread')), findsNothing);
});
}
@@ -55,7 +55,7 @@ void main() {
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('chat-refresh')));
await tester.pumpAndSettle();
expect(find.text('New'), findsNothing);
expect(find.byKey(const Key('chat-row-unread')), findsNothing);
expect(localStore.state?.watermark('deep-linked'), greaterThan(0));
});
@@ -71,19 +71,16 @@ void main() {
expect(find.text('Starred'), findsOneWidget);
expect(find.text('Chats'), findsNWidgets(2));
// The Closed section header, and each closed row's trailing word.
expect(
find.byKey(const ValueKey('chat-section-Closed')),
findsOneWidget,
);
expect(find.byKey(const ValueKey('chat-section-Closed')), findsOneWidget);
expect(
find.descendant(
of: find.byKey(const Key('chat-row-s4')),
matching: find.text('Closed'),
matching: find.textContaining(RegExp(r'^Closed( ·|$)')),
),
findsOneWidget,
);
expect(find.text('Starred chat'), findsOneWidget);
expect(find.text('Starred closed'), findsOneWidget);
expect(find.textContaining('Starred chat'), findsOneWidget);
expect(find.textContaining('Starred closed'), findsOneWidget);
expect(find.text('Open chat'), findsOneWidget);
expect(find.byIcon(Icons.folder_outlined), findsNWidgets(4));
expect(find.byType(Scaffold), findsOneWidget);
@@ -116,7 +113,10 @@ void main() {
expect(find.text('/work'), findsWidgets);
expect(find.text('/else'), findsWidgets);
await tester.tap(find.byKey(const Key('chat-star-s2')));
// Starring lives in the row's actions menu.
await tester.tap(find.byKey(const Key('chat-actions-s2')));
await tester.pumpAndSettle();
await tester.tap(find.text('Star'));
await tester.pumpAndSettle();
expect(gateway.lastFields('chat_star'), {
'chat_query': {'session_id': 's2', 'starred': true},
@@ -9,7 +9,7 @@ void main() {
for (final cupertino in [false, true]) {
for (final backend in ['opencode', 'claude']) {
testWidgets(
'$backend identity beside title, one actionable star ($cupertino)',
'$backend avatar beside title; the menu stars and unstars ($cupertino)',
(tester) async {
var starred = true;
final body = StatefulBuilder(
@@ -72,22 +72,25 @@ void main() {
tester.widget<ImageIcon>(find.byType(ImageIcon)).image,
AssetImage('assets/harnesses/$backend.png'),
);
final title = tester.getRect(find.text('Harness chat'));
final title = tester.getRect(find.textContaining('Harness chat'));
final icon = tester.getRect(mark);
expect(icon.right, lessThanOrEqualTo(title.left));
expect(icon.top, lessThan(title.bottom));
expect(icon.bottom, greaterThan(title.top));
expect(
find.byIcon(cupertino ? CupertinoIcons.star_fill : Icons.star),
findsOneWidget,
);
await tester.tap(find.byKey(const Key('chat-star-s')));
expect(find.byKey(const Key('chat-row-starred')), findsOneWidget);
// Star and unstar live in the row's menu, not a separate button.
await tester.tap(find.byKey(const Key('chat-actions-s')));
await tester.pumpAndSettle();
await tester.tap(find.text('Unstar'));
await tester.pumpAndSettle();
expect(starred, isFalse);
expect(
find.byIcon(cupertino ? CupertinoIcons.star : Icons.star_border),
findsOneWidget,
);
expect(find.byKey(const Key('chat-row-starred')), findsNothing);
await tester.tap(find.byKey(const Key('chat-actions-s')));
await tester.pumpAndSettle();
await tester.tap(find.text('Star'));
await tester.pumpAndSettle();
expect(starred, isTrue);
expect(
find.byType(SessionHarnessIcon),
findsOneWidget,