Complete prompt presets, body-priority panes and clearer chat and stage layouts

This commit is contained in:
2026-10-25 23:11:06 +00:00
parent de1b62791f
commit 121ace1cee
31 changed files with 990 additions and 396 deletions
@@ -57,8 +57,7 @@ void main() {
);
expect(
find.text(
"This server has no request for choosing a chat's model, so a new "
"chat uses the server's default.",
"New chats start with the server's default model.",
),
findsOneWidget,
);
@@ -150,17 +149,28 @@ void main() {
findsOneWidget,
);
expect(find.text('Chat harness: OpenCode'), findsOneWidget);
await tester.ensureVisible(
find.byKey(const Key('chat-create-prompt-choice')),
);
await tester.tap(find.byKey(const Key('chat-create-prompt-choice')));
await tester.pumpAndSettle();
await tester.tap(find.text('Careful coding'));
await tester.pumpAndSettle();
expect(
find.textContaining('Act as a careful coding agent.'),
findsOneWidget,
);
await tester.ensureVisible(find.byKey(const Key('chat-create-backend')));
await tester.tap(find.byKey(const Key('chat-create-backend')));
await tester.pumpAndSettle();
await tester.tap(find.text('Codex'));
await tester.pumpAndSettle();
expect(find.text('Chat harness: Codex'), findsOneWidget);
await tester.ensureVisible(
find.byKey(const Key('chat-create-server-directory')),
);
await tester.tap(find.byKey(const Key('chat-create-server-directory')));
await tester.pumpAndSettle();
expect(find.text('/archive'), findsOneWidget);
@@ -68,6 +68,7 @@ Future<ChatDraft?> _create(
find.byKey(const Key('chat-create-instructions')),
prompt,
);
await tester.pump();
}
await tester.ensureVisible(find.byKey(const Key('chat-create-confirm')));
await tester.tap(find.byKey(const Key('chat-create-confirm')));
@@ -95,6 +96,11 @@ void main() {
await tester.pumpWidget(const SizedBox());
final second = await _create(tester, prompts);
expect(second!.instructions, isEmpty);
expect(
prompts.saved.values.single.text,
'Review only.',
reason: 'A promptless chat must not erase the Last used preset',
);
});
testWidgets('a chat starts without a prompt even after a prior choice', (
@@ -103,11 +109,11 @@ void main() {
final prompts = _MemoryPrompts();
final draft = await _create(tester, prompts);
expect(draft!.instructions, isEmpty);
expect(prompts.saved.values.single.send, isFalse);
expect(prompts.saved, isEmpty);
await tester.pumpWidget(const SizedBox());
await _create(tester, prompts);
expect(prompts.saved.values.single.send, isFalse);
expect(prompts.saved, isEmpty);
});
testWidgets('the prompt menu selects a preset and permits custom edits', (
@@ -182,6 +188,62 @@ void main() {
);
});
testWidgets(
'custom starts empty and survives switching to a preset and back',
(tester) async {
await _open(tester, _MemoryPrompts());
await tester.tap(find.byKey(const Key('chat-create-send-prompt')));
await tester.pumpAndSettle();
final field = find.byKey(const Key('chat-create-instructions'));
String text() => tester.widget<TextField>(field).controller!.text;
expect(text(), isEmpty);
expect(
tester
.widget<FilledButton>(find.byKey(const Key('chat-create-confirm')))
.onPressed,
isNull,
);
await tester.enterText(field, 'My custom draft');
await tester.pump();
await _pickPrompt(tester, 'Careful coding');
expect(text(), chatDefaultSessionInstructions);
await _pickPrompt(tester, 'Custom');
expect(text(), 'My custom draft');
expect(
tester
.widget<FilledButton>(find.byKey(const Key('chat-create-confirm')))
.onPressed,
isNotNull,
);
},
);
testWidgets('late saved data preserves opt-in and still offers Last used', (
tester,
) async {
final prompts = _DelayedPrompts();
await _open(tester, prompts, settle: false);
await tester.pump(const Duration(milliseconds: 1));
await tester.tap(find.byKey(const Key('chat-create-send-prompt')));
await tester.pump();
prompts.result.complete((send: true, text: 'Saved preset'));
await tester.pumpAndSettle();
expect(
tester
.widget<Switch>(find.byKey(const Key('chat-create-send-prompt')))
.value,
isTrue,
);
await _pickPrompt(tester, 'Last used prompt');
expect(
tester
.widget<TextField>(find.byKey(const Key('chat-create-instructions')))
.controller!
.text,
'Saved preset',
);
});
testWidgets('Cupertino prompt chooser has native preset and custom choices', (
tester,
) async {
@@ -213,6 +275,15 @@ void main() {
});
}
Future<void> _pickPrompt(WidgetTester tester, String label) async {
final chooser = find.byKey(const Key('chat-create-prompt-choice'));
await tester.ensureVisible(chooser);
await tester.tap(chooser);
await tester.pumpAndSettle();
await tester.tap(find.text(label).last);
await tester.pumpAndSettle();
}
Future<void> _open(
WidgetTester tester,
ChatCreatePromptStore prompts, {
@@ -185,14 +185,17 @@ void main() {
greaterThan(tester.getCenter(find.text('Starred chat')).dx),
);
// The meta line keeps `CupertinoListTile`'s native 12pt subtitle style; it
// must not be rendered at the title's body size. The colour-only style the
// row passes merges with the tile's own `DefaultTextStyle`.
// 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, 12.0);
expect(_styleOf(tester, 'New').fontSize, titleStyle.fontSize);
expect(
metaStyle.fontSize,
CupertinoTheme.of(
tester.element(find.text('5 min ago')),
).textTheme.tabLabelTextStyle.fontSize,
);
expect(_styleOf(tester, 'New').fontSize, metaStyle.fontSize);
// Each session is still its own native tile with its own actions, so the
// inset group draws the separator between them.
@@ -34,6 +34,7 @@ void main() {
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('chat-create-send-prompt')));
await tester.pumpAndSettle();
await _chooseCareful(tester);
await tester.tap(find.byKey(const Key('chat-create-confirm')));
await tester.pumpAndSettle();
@@ -196,6 +197,7 @@ void main() {
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('chat-create-send-prompt')));
await tester.pumpAndSettle();
await _chooseCareful(tester);
await tester.tap(find.byKey(const Key('chat-create-confirm')));
await tester.pumpAndSettle();
@@ -231,3 +233,12 @@ void main() {
expect(find.byKey(const Key('chat-row-error-s2')), findsNothing);
});
}
Future<void> _chooseCareful(WidgetTester tester) async {
final chooser = find.byKey(const Key('chat-create-prompt-choice'));
await tester.ensureVisible(chooser);
await tester.tap(chooser);
await tester.pumpAndSettle();
await tester.tap(find.text('Careful coding').last);
await tester.pumpAndSettle();
}
@@ -62,6 +62,7 @@ void main() {
testWidgets(
'material list keeps closed starred rows once and groups directories once',
(tester) async {
_inventoryViewport(tester);
final gateway = FakeChatGateway()
..sessionsReply = {'chat_sessions': sampleSessions()};
await pumpMaterialChat(tester, gateway);
@@ -101,6 +102,7 @@ void main() {
testWidgets(
'Cupertino app renders standard controls, groups and renames without Material',
(tester) async {
_inventoryViewport(tester);
final gateway = FakeChatGateway()
..sessionsReply = {'chat_sessions': sampleSessions()};
await pumpCupertinoChat(tester, gateway);
@@ -203,6 +205,7 @@ void main() {
testWidgets('closed chats start folded away behind their heading', (
tester,
) async {
_inventoryViewport(tester);
final gateway = FakeChatGateway()
..sessionsReply = {'chat_sessions': sampleSessions()};
await pumpMaterialChat(tester, gateway);
@@ -213,3 +216,10 @@ void main() {
expect(find.byKey(const Key('chat-row-s4')), findsOneWidget);
});
}
void _inventoryViewport(WidgetTester tester) {
// This test inventories every row; separate layout tests cover small screens.
tester.view.physicalSize = const Size(800, 1600);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
}
@@ -4,7 +4,13 @@ import 'package:flutter_test/flutter_test.dart';
/// Closed chats start folded away; opens that section when it is shown.
Future<void> expandClosedChats(WidgetTester tester) async {
final section = find.byKey(const ValueKey('chat-section-Closed'));
if (section.evaluate().isEmpty) return;
if (section.evaluate().isEmpty) {
await tester.scrollUntilVisible(
section,
200,
scrollable: find.byType(Scrollable).first,
);
}
final heading = find.descendant(of: section, matching: find.text('Closed'));
await tester.ensureVisible(heading.first);
await tester.tap(heading.first);