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);
@@ -0,0 +1,44 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/pipelines/widgets/pipeline_scope_control.dart';
void main() {
for (final cupertino in [false, true]) {
for (final width in [120.0, 500.0]) {
testWidgets(
'native scope remains usable at $width, Cupertino=$cupertino',
(tester) async {
var scheduled = false;
final control = StatefulBuilder(
builder: (context, setState) => Center(
child: SizedBox(
width: width,
child: PipelineScopeControl(
scheduled: scheduled,
onSelected: (value) => setState(() => scheduled = value),
),
),
),
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: control))
: MaterialApp(home: Scaffold(body: control)),
);
await tester.pumpAndSettle();
if (width == 120) {
await tester.tap(find.byKey(const Key('pipeline-scope')));
await tester.pumpAndSettle();
await tester.tap(find.text('Scheduled').last);
} else {
await tester.tap(find.text('Scheduled'));
}
await tester.pumpAndSettle();
expect(scheduled, isTrue);
expect(tester.takeException(), isNull);
},
);
}
}
}
@@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'run_detail_finders.dart';
import 'package:pipelines_app/features/runs/ui/run_graph_preview.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/graph/widgets/run_graph_view.dart';
@@ -136,8 +137,8 @@ void main() {
await pumpDeepLink(tester, platform, stage: 'plan', visit: 0);
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expect(find.text('plan · visit 1'), findsOneWidget);
expect(find.text('plan · visit 5'), findsNothing);
expectVisitHeading(tester, 'plan', 1);
expect(find.text('Visit 5'), findsNothing);
// The visit is its own page over the Timeline tab.
expect(
find.byKey(
@@ -180,7 +181,7 @@ void main() {
await pumpDeepLink(tester, RunDetailTestPlatform.material, stage: 'plan');
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expect(find.text('plan · visit 5'), findsOneWidget);
expectVisitHeading(tester, 'plan', 5);
});
testWidgets('a Graph click opens the same latest visit as the stage route', (
@@ -194,7 +195,7 @@ void main() {
// The web client's graph click takes the last visit in sequence order, not
// the last row in reply order, so both entry points agree.
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expect(find.text('plan · visit 5'), findsOneWidget);
expectVisitHeading(tester, 'plan', 5);
});
testWidgets('an out-of-range visit is clamped to the stage last visit', (
@@ -208,7 +209,7 @@ void main() {
);
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expect(find.text('plan · visit 5'), findsOneWidget);
expectVisitHeading(tester, 'plan', 5);
});
testWidgets('a declared but unvisited stage selects its graph node', (
@@ -258,7 +259,7 @@ void main() {
await tester.pumpAndSettle();
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expect(find.text('plan · visit 5'), findsOneWidget);
expectVisitHeading(tester, 'plan', 5);
});
testWidgets('a route change applies its visit and a plain route closes it', (
@@ -296,11 +297,11 @@ void main() {
),
);
await tester.pumpAndSettle();
expect(find.text('plan · visit 1'), findsOneWidget);
expectVisitHeading(tester, 'plan', 1);
rebuild(() => visit = 1);
await tester.pumpAndSettle();
expect(find.text('plan · visit 5'), findsOneWidget);
expectVisitHeading(tester, 'plan', 5);
rebuild(() => stage = null);
await tester.pumpAndSettle();
@@ -1,6 +1,22 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
/// Wide screens deliberately repeat the selected title in the visible list.
Finder runDetailText(String text) =>
find.descendant(of: find.byType(RunDetailView), matching: find.text(text));
/// Stage identity and visit coordinates are separate rendered fields now.
void expectVisitHeading(WidgetTester tester, String stage, num sequence) {
final pane = find.byKey(const Key('run-visit-pane'));
expect(pane, findsOneWidget);
final title = find.descendant(
of: pane,
matching: find.byKey(const Key('run-visit-title')),
);
expect(tester.widget<Text>(title).data, stage);
expect(
find.descendant(of: pane, matching: find.text('Visit $sequence')),
findsOneWidget,
);
}
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'run_detail_finders.dart';
import 'package:pipelines_app/features/graph/widgets/graph_stage_node.dart';
import 'package:pipelines_app/features/graph/widgets/run_graph_canvas.dart';
import 'package:pipelines_app/features/graph/widgets/run_graph_view.dart';
@@ -65,7 +66,7 @@ void main() {
findsNothing,
);
expect(find.byKey(const Key('run-visit-title')), findsOneWidget);
expect(find.text('plan · visit 1'), findsOneWidget);
expectVisitHeading(tester, 'plan', 1);
expect(find.byKey(const Key('run-visit-facts-grid')), findsOneWidget);
expect(find.textContaining('audit · visit'), findsNothing);
});
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'run_detail_finders.dart';
import 'package:pipelines_app/features/artifacts/ui/artifact_gallery_page.dart';
import 'package:pipelines_app/features/graph/widgets/stage_definition_view.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_visit_facts.dart';
@@ -182,7 +183,7 @@ void main() {
});
await openVisit(tester, platform, run: run, sequence: 2);
expect(find.text('plan · visit 2'), findsOneWidget);
expectVisitHeading(tester, 'plan', 2);
await openVisitTab(tester, RunVisitSection.artifacts);
expect(find.text('plan-2.csv'), findsOneWidget);
expect(find.text('public/shared.csv'), findsNothing);
@@ -1,6 +1,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'run_detail_finders.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/runs/data/runs_repository.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
@@ -112,7 +113,7 @@ void main() {
);
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expect(find.text('build · visit 2'), findsOneWidget);
expectVisitHeading(tester, 'build', 2);
});
}
@@ -66,7 +66,13 @@ void main() {
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
// The body keeps the landed viewer's own identity for that visit.
expect(find.text('plan'), findsOneWidget);
expect(
find.descendant(
of: find.byType(ChangesViewer),
matching: find.text('plan'),
),
findsOneWidget,
);
expect(find.text('Visit 1 · completed'), findsOneWidget);
expect(find.text('lib/plan.dart'), findsOneWidget);
expect(find.text('lib/build.dart'), findsNothing);