feat(app): chat list drops search, New chat and Refresh are bar actions, and rows show agent, model and ~ paths
This commit is contained in:
@@ -43,12 +43,22 @@ String relativeChatSessionTime(Object? updatedAt, {DateTime? now}) {
|
|||||||
return '${then.day} ${_shortMonths[then.month - 1]}';
|
return '${then.day} ${_shortMonths[then.month - 1]}';
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The row's muted second line: the directory the chat runs in, plus the model
|
/// The row's muted second line: which agent runs the chat (an empty backend
|
||||||
/// the server recorded for it. Both come from the row; nothing is inferred.
|
/// is a legacy OpenCode row), its model, and the directory with the home
|
||||||
String chatSessionMeta(JsonMap session) => [
|
/// folder written as `~`.
|
||||||
'${session['directory'] ?? ''}'.trim(),
|
String chatSessionMeta(JsonMap session) {
|
||||||
'${session['model'] ?? ''}'.trim(),
|
final backend = '${session['backend'] ?? ''}'.trim();
|
||||||
].where((part) => part.isNotEmpty).join(' · ');
|
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
|
/// 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`).
|
/// directory and model (`1 day ago · /srv/probe · model-a`).
|
||||||
|
|||||||
@@ -24,34 +24,6 @@ void main() {
|
|||||||
expectNormalTextStyle(tester, message);
|
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<RenderBox>(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', (
|
testWidgets('Cupertino load error under MaterialApp uses normal text', (
|
||||||
tester,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
|
|||||||
@@ -109,10 +109,22 @@ void main() {
|
|||||||
test('meta and status come only from the row', () {
|
test('meta and status come only from the row', () {
|
||||||
expect(
|
expect(
|
||||||
chatSessionMeta({'directory': '/work', 'model': 'model-a'}),
|
chatSessionMeta({'directory': '/work', 'model': 'model-a'}),
|
||||||
'/work · model-a',
|
'opencode · model-a · /work',
|
||||||
);
|
);
|
||||||
expect(chatSessionMeta({'directory': '/work'}), '/work');
|
expect(chatSessionMeta({'directory': '/work'}), 'opencode · /work');
|
||||||
expect(chatSessionMeta({}), '');
|
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: false), isNull);
|
||||||
expect(chatSessionRowStatus({}, unseen: true), 'New');
|
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
|
// As on the web: the unread word trails the title; the muted meta line
|
||||||
// leads with the recency.
|
// leads with the recency.
|
||||||
expect(find.text('Starred chat'), findsOneWidget);
|
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('New'), findsOneWidget);
|
||||||
expect(find.text('2 hr ago · /work'), findsOneWidget);
|
expect(find.text('2 hr ago · opencode · /work'), findsOneWidget);
|
||||||
expect(
|
expect(
|
||||||
(tester.getCenter(find.text('Starred chat')).dy -
|
(tester.getCenter(find.text('Starred chat')).dy -
|
||||||
tester.getCenter(find.text('New')).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
|
// must not be rendered at the title's body size. The colour-only style the
|
||||||
// row passes merges with the tile's own `DefaultTextStyle`.
|
// row passes merges with the tile's own `DefaultTextStyle`.
|
||||||
final titleStyle = _styleOf(tester, 'Starred chat');
|
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, lessThan(titleStyle.fontSize!));
|
||||||
expect(metaStyle.fontSize, 12.0);
|
expect(metaStyle.fontSize, 12.0);
|
||||||
expect(_styleOf(tester, 'New').fontSize, titleStyle.fontSize);
|
expect(_styleOf(tester, 'New').fontSize, titleStyle.fontSize);
|
||||||
@@ -215,8 +230,8 @@ void main() {
|
|||||||
expect(tester.takeException(), isNull);
|
expect(tester.takeException(), isNull);
|
||||||
const title = 'A conversation title long enough to need an ellipsis';
|
const title = 'A conversation title long enough to need an ellipsis';
|
||||||
const meta =
|
const meta =
|
||||||
'3 days ago · /a/very/long/directory/that/must/ellipsise · '
|
'3 days ago · opencode · provider/an-extremely-long-recorded-model-id'
|
||||||
'provider/an-extremely-long-recorded-model-id';
|
' · /a/very/long/directory/that/must/ellipsise';
|
||||||
final titleParagraph = tester.renderObject<RenderParagraph>(
|
final titleParagraph = tester.renderObject<RenderParagraph>(
|
||||||
find.text(title),
|
find.text(title),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -73,9 +73,9 @@ void main() {
|
|||||||
], isUnseen: (session) => session['id'] == 's1');
|
], isUnseen: (session) => session['id'] == 's1');
|
||||||
|
|
||||||
expect(find.text('Starred chat'), findsOneWidget);
|
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('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.
|
// As on the web, the unread word shares the title's line.
|
||||||
expect(
|
expect(
|
||||||
(tester.getCenter(find.text('Starred chat')).dy -
|
(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.
|
// The meta line is the theme's muted colour, not the title colour.
|
||||||
final meta = tester.widget<Text>(find.text('5 min ago · /work · model-a'));
|
final meta = tester.widget<Text>(
|
||||||
final context = tester.element(find.text('5 min ago · /work · model-a'));
|
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);
|
expect(meta.style?.color, Theme.of(context).colorScheme.onSurfaceVariant);
|
||||||
|
|
||||||
// Native Material separators sit between rows, not around the group.
|
// Native Material separators sit between rows, not around the group.
|
||||||
@@ -150,8 +154,8 @@ void main() {
|
|||||||
expect(tester.takeException(), isNull);
|
expect(tester.takeException(), isNull);
|
||||||
const title = 'A conversation title long enough to need an ellipsis';
|
const title = 'A conversation title long enough to need an ellipsis';
|
||||||
const meta =
|
const meta =
|
||||||
'3 days ago · /a/very/long/directory/that/must/ellipsise · '
|
'3 days ago · opencode · provider/an-extremely-long-recorded-model-id'
|
||||||
'provider/an-extremely-long-recorded-model-id';
|
' · /a/very/long/directory/that/must/ellipsise';
|
||||||
final titleParagraph = tester.renderObject<RenderParagraph>(
|
final titleParagraph = tester.renderObject<RenderParagraph>(
|
||||||
find.text(title),
|
find.text(title),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ void main() {
|
|||||||
);
|
);
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|
||||||
pending.complete({'chat_sessions': [session]});
|
pending.complete({
|
||||||
|
'chat_sessions': [session],
|
||||||
|
});
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(localStore.state?.watermark('deep-linked'), greaterThan(0));
|
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', (
|
testWidgets('material empty server shows the distinct empty message', (
|
||||||
tester,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
@@ -124,14 +109,9 @@ void main() {
|
|||||||
await pumpCupertinoChat(tester, gateway);
|
await pumpCupertinoChat(tester, gateway);
|
||||||
|
|
||||||
expect(find.byType(CupertinoPageScaffold), findsOneWidget);
|
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(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 · /work'), findsOneWidget);
|
||||||
expect(find.text('Chats · /else'), 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<RenderBox>(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(
|
testWidgets(
|
||||||
'Cupertino load failure wraps the reason and hides the empty message',
|
'Cupertino load failure wraps the reason and hides the empty message',
|
||||||
(tester) async {
|
(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', (
|
testWidgets('duplicate Cupertino titles disambiguate the action labels', (
|
||||||
tester,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import 'chat_test_harness.dart';
|
|||||||
import 'fake_chat_gateway.dart';
|
import 'fake_chat_gateway.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('embedded, New chat sits beside search on one toolbar row', (
|
testWidgets('embedded, New chat and Refresh share one actions row', (
|
||||||
tester,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
final gateway = FakeChatGateway()
|
final gateway = FakeChatGateway()
|
||||||
@@ -26,13 +26,14 @@ void main() {
|
|||||||
);
|
);
|
||||||
await tester.pumpAndSettle();
|
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 create = find.byKey(const Key('chat-new-chat'));
|
||||||
|
final refresh = find.byKey(const Key('chat-refresh'));
|
||||||
|
expect(create, findsOneWidget);
|
||||||
expect(
|
expect(
|
||||||
find.descendant(of: create, matching: find.text('New chat')),
|
(tester.getCenter(create).dy - tester.getCenter(refresh).dy).abs(),
|
||||||
findsOneWidget,
|
lessThan(4),
|
||||||
);
|
);
|
||||||
expect((tester.getCenter(create).dy - search.dy).abs(), lessThan(4));
|
|
||||||
expect(tester.getCenter(create).dx, greaterThan(search.dx));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user