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
@@ -17,217 +17,258 @@ void main() {
for (final cupertino in [false, true]) {
for (final brightness in Brightness.values) {
for (final width in [640.0, 840.0, 1280.0]) {
testWidgets('shared equal panes and selected rows: $cupertino '
'$brightness at $width', (tester) async {
SharedPreferences.setMockInitialValues({});
tester.view.physicalSize = Size(width, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final fixture = PipelineFixture();
final gateway = FakeGateway(
(type, fields) => switch (type) {
'list_pipelines' => pipelineListReply(fixture.summaries),
'get_pipeline' => pipelineDetailReply(
fixture.detailFor(
fields['pipeline_id'] as int,
fields['version'] as int,
)!,
),
'list_runs' => {
'runs': [
for (final id in [1, 2])
{'id': id, 'title': 'Run item $id', 'status': 'succeeded'},
],
},
'get_run' => {
'run_detail': {
'id': fields['run_id'],
'title': 'Run item ${fields['run_id']}',
'status': 'succeeded',
'input': {'prompt': 'Recorded input'},
for (final scale in [1.0, 2.0]) {
testWidgets('shared body-priority panes and selected rows: $cupertino '
'$brightness at $width @${scale}x', (tester) async {
SharedPreferences.setMockInitialValues({});
tester.view.physicalSize = Size(width, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
tester.platformDispatcher.textScaleFactorTestValue = scale;
addTearDown(
tester.platformDispatcher.clearTextScaleFactorTestValue,
);
final fixture = PipelineFixture();
final gateway = FakeGateway(
(type, fields) => switch (type) {
'list_pipelines' => pipelineListReply(fixture.summaries),
'get_pipeline' => pipelineDetailReply(
fixture.detailFor(
fields['pipeline_id'] as int,
fields['version'] as int,
)!,
),
'list_runs' => {
'runs': [
for (final id in [1, 2])
{
'id': id,
'title': 'Run item $id',
'status': 'succeeded',
},
],
},
},
'chat_sessions' => {
'chat_sessions': [
{
'id': 'a',
'title': 'Chat item a',
'backend': 'claude',
'model': 'claude-opus',
'mode': 'auto',
'mode_name': 'Auto',
'get_run' => {
'run_detail': {
'id': fields['run_id'],
'title': 'Run item ${fields['run_id']}',
'status': 'succeeded',
'input': {'prompt': 'Recorded input'},
},
{
'id': 'b',
'title': 'Chat item b',
'backend': 'claude',
'model': 'claude-opus',
'mode': 'auto',
'mode_name': 'Auto',
},
],
},
'chat_sessions' => {
'chat_sessions': [
{
'id': 'a',
'title': 'Chat item a',
'backend': 'claude',
'model': 'claude-opus',
'mode': 'auto',
'mode_name': 'Auto',
},
{
'id': 'b',
'title': 'Chat item b',
'backend': 'claude',
'model': 'claude-opus',
'mode': 'auto',
'mode_name': 'Auto',
},
],
},
'chat_messages' => {
'chat_history': {'messages': []},
},
_ => {},
},
'chat_messages' => {
'chat_history': {'messages': []},
);
final shell = AdaptiveShell(
cupertino: cupertino,
destinationBodies: {
AppDestination.pipelines: (_) =>
PipelinesScreen(gateway: gateway, embedded: true),
AppDestination.runs: (_) => RunsScreen(gateway: gateway),
AppDestination.chat: (_) => ChatScreen(gateway: gateway),
},
_ => {},
},
);
final shell = AdaptiveShell(
cupertino: cupertino,
destinationBodies: {
AppDestination.pipelines: (_) =>
PipelinesScreen(gateway: gateway, embedded: true),
AppDestination.runs: (_) => RunsScreen(gateway: gateway),
AppDestination.chat: (_) => ChatScreen(gateway: gateway),
},
);
await tester.pumpWidget(
cupertino
? CupertinoApp(
theme: CupertinoThemeData(brightness: brightness),
home: shell,
)
: MaterialApp(
theme: brightness == Brightness.dark
? appDarkTheme()
: appLightTheme(),
home: shell,
),
);
await tester.pumpAndSettle();
final paneWidths = <double>[];
for (final destination in ['Pipelines', 'Runs', 'Chat']) {
if (destination != 'Pipelines') {
await tester.tap(find.text(destination).first);
await tester.pumpAndSettle();
expect(
tester.takeException(),
isNull,
reason: '$destination list',
);
}
final list = find.byKey(const ValueKey('list-detail-list'));
final detail = find.byKey(const ValueKey('list-detail-body'));
expect(list, findsOneWidget);
expect(detail, findsOneWidget);
final before = tester.getSize(list).width;
paneWidths.add(before);
expect(before, closeTo(tester.getSize(detail).width, 0.01));
final rowKeys = switch (destination) {
'Pipelines' => ['pipeline-row-1', 'pipeline-row-2'],
'Runs' => ['run-row-1', 'run-row-2'],
_ => ['chat-row-a', 'chat-row-b'],
};
for (final key in rowKeys) {
final target = find.byKey(ValueKey(key));
// In a narrow Cupertino list the row center can be a star/menu
// control. Open the chat through its title, not a trailing action.
await tester.tap(
destination == 'Chat'
);
await tester.pumpWidget(
cupertino
? CupertinoApp(
theme: CupertinoThemeData(brightness: brightness),
home: shell,
)
: MaterialApp(
theme: brightness == Brightness.dark
? appDarkTheme()
: appLightTheme(),
home: shell,
),
);
await tester.pumpAndSettle();
final paneWidths = <double>[];
final bodyWidths = <double>[];
for (final destination in ['Pipelines', 'Runs', 'Chat']) {
if (destination != 'Pipelines') {
await tester.tap(find.text(destination).first);
await tester.pumpAndSettle();
expect(
tester.takeException(),
isNull,
reason: '$destination list',
);
}
final list = find.byKey(const ValueKey('list-detail-list'));
final detail = find.byKey(const ValueKey('list-detail-body'));
expect(list, findsOneWidget);
expect(detail, findsOneWidget);
final before = tester.getSize(list).width;
final bodyBefore = tester.getSize(detail).width;
paneWidths.add(before);
bodyWidths.add(bodyBefore);
expect(bodyBefore, greaterThanOrEqualTo(width * 0.5));
expect(bodyBefore, lessThanOrEqualTo(width * 0.6));
expect(bodyBefore, greaterThan(before));
final rowKeys = switch (destination) {
'Pipelines' => ['pipeline-row-1', 'pipeline-row-2'],
'Runs' => ['run-row-1', 'run-row-2'],
_ => ['chat-row-a', 'chat-row-b'],
};
for (final key in rowKeys) {
final target = find.byKey(ValueKey(key));
// In a narrow Cupertino list the row center can be a star/menu
// control. Open the chat through its title, not a trailing action.
final opener = destination == 'Chat'
? find.descendant(
of: target,
matching: find.text('Chat item ${key.split('-').last}'),
)
: target,
);
: target;
await tester.ensureVisible(opener);
await tester.tap(opener);
await tester.pumpAndSettle();
expect(
tester.takeException(),
isNull,
reason: '$destination after opening $key',
);
expect(tester.getSize(list).width, closeTo(before, 0.01));
expect(tester.getSize(detail).width, closeTo(bodyBefore, 0.01));
expect(
tester.state<NavigatorState>(find.byType(Navigator)).canPop(),
isFalse,
);
for (final rowKey in rowKeys) {
final row = find.byKey(ValueKey(rowKey));
expect(
row,
findsOneWidget,
reason: 'the list must remain visible',
);
final selected = rowKey == key;
expect(
tester.getSemantics(row).flagsCollection.isSelected ==
Tristate.isTrue,
selected,
reason: '$destination: $rowKey after opening $key',
);
final context = tester.element(row);
if (cupertino) {
final color = destination == 'Runs'
? tester.widget<CupertinoButton>(row).color
: tester.widget<CupertinoListTile>(row).backgroundColor;
expect(
color,
selected
? CupertinoColors.tertiarySystemFill.resolveFrom(
context,
)
: isNull,
);
} else if (destination == 'Runs') {
final id = rowKey.split('-').last;
expect(
tester
.widget<Material>(
find.byKey(ValueKey('run-row-surface-$id')),
)
.color,
selected
? Theme.of(context).colorScheme.secondaryContainer
: Colors.transparent,
);
} else {
final tile = tester.widget<ListTile>(row);
expect(tile.selected, selected);
expect(
tile.selectedTileColor,
Theme.of(context).colorScheme.secondaryContainer,
);
}
}
}
if (destination == 'Chat') {
final star = find.byKey(const Key('chat-star-b'));
await tester.ensureVisible(star);
await tester.tap(star);
await tester.pumpAndSettle();
expect(
gateway
.callsOf('chat_star')
.last
.fields['chat_query']['session_id'],
'b',
);
final actions = find.byKey(const Key('chat-actions-b'));
await tester.ensureVisible(actions);
await tester.tap(actions);
await tester.pumpAndSettle();
expect(find.text('Rename…'), findsOneWidget);
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
}
// A phone still uses stock page navigation; returning to a wide
// window must keep the selected item without clearing its route.
tester.view.physicalSize = const Size(390, 900);
await tester.pumpAndSettle();
expect(
tester.takeException(),
isNull,
reason: '$destination after opening $key',
tester.state<NavigatorState>(find.byType(Navigator)).canPop(),
isTrue,
reason: '$destination should push its selected item on a phone',
);
expect(tester.getSize(list).width, closeTo(before, 0.01));
expect(tester.getSize(detail).width, closeTo(before, 0.01));
expect(
find.byKey(const ValueKey('list-detail-list')),
findsNothing,
);
tester.view.physicalSize = Size(width, 900);
await tester.pumpAndSettle();
expect(
tester.state<NavigatorState>(find.byType(Navigator)).canPop(),
isFalse,
);
for (final rowKey in rowKeys) {
final row = find.byKey(ValueKey(rowKey));
expect(
row,
findsOneWidget,
reason: 'the list must remain visible',
);
final selected = rowKey == key;
expect(
tester.getSemantics(row).flagsCollection.isSelected ==
Tristate.isTrue,
selected,
reason: '$destination: $rowKey after opening $key',
);
final context = tester.element(row);
if (cupertino) {
final color = destination == 'Runs'
? tester.widget<CupertinoButton>(row).color
: tester.widget<CupertinoListTile>(row).backgroundColor;
expect(
color,
selected
? CupertinoColors.tertiarySystemFill.resolveFrom(
context,
)
: isNull,
);
} else if (destination == 'Runs') {
final id = rowKey.split('-').last;
expect(
tester
.widget<Material>(
find.byKey(ValueKey('run-row-surface-$id')),
)
.color,
selected
? Theme.of(context).colorScheme.secondaryContainer
: Colors.transparent,
);
} else {
final tile = tester.widget<ListTile>(row);
expect(tile.selected, selected);
expect(
tile.selectedTileColor,
Theme.of(context).colorScheme.secondaryContainer,
);
}
}
expect(tester.getSize(list).width, closeTo(before, 0.01));
expect(
tester
.getSemantics(find.byKey(ValueKey(rowKeys.last)))
.flagsCollection
.isSelected,
Tristate.isTrue,
);
}
// A phone still uses stock page navigation; returning to a wide
// window must keep the selected item without clearing its route.
tester.view.physicalSize = const Size(390, 900);
await tester.pumpAndSettle();
expect(
tester.state<NavigatorState>(find.byType(Navigator)).canPop(),
isTrue,
reason: '$destination should push its selected item on a phone',
paneWidths,
everyElement(closeTo(paneWidths.first, 0.01)),
reason: 'Pipelines, Runs and Chat must use identical pane widths',
);
expect(tester.takeException(), isNull);
expect(
find.byKey(const ValueKey('list-detail-list')),
findsNothing,
bodyWidths,
everyElement(closeTo(bodyWidths.first, 0.01)),
reason:
'Every destination must share the body-priority sizing policy',
);
tester.view.physicalSize = Size(width, 900);
await tester.pumpAndSettle();
expect(
tester.state<NavigatorState>(find.byType(Navigator)).canPop(),
isFalse,
);
expect(tester.getSize(list).width, closeTo(before, 0.01));
expect(
tester
.getSemantics(find.byKey(ValueKey(rowKeys.last)))
.flagsCollection
.isSelected,
Tristate.isTrue,
);
}
expect(
paneWidths,
everyElement(closeTo(paneWidths.first, 0.01)),
reason: 'Pipelines, Runs and Chat must use identical pane widths',
);
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox.shrink());
});
await tester.pumpWidget(const SizedBox.shrink());
});
}
}
}
}
+4 -3
View File
@@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import '../features/runs/ui/run_detail_finders.dart';
import '../native_back.dart';
import 'package:pipelines_app/application/app_route.dart';
import 'package:pipelines_app/application/app_router.dart';
@@ -335,8 +336,8 @@ void main() {
// The query reached the detail: visit 0 is the earlier plan visit (seq 1),
// not the latest one the pane would show without a visit.
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);
expect(provider.value.uri.toString(), '/runs/77/stage/plan?visit=0');
// A history entry the app itself writes is parsed back as a query, so
@@ -350,7 +351,7 @@ void main() {
await tester.pump();
await tester.pump(const Duration(milliseconds: 400));
await tester.pump(const Duration(milliseconds: 400));
expect(find.text('plan · visit 5'), findsOneWidget);
expectVisitHeading(tester, 'plan', 5);
expect(provider.value.uri.path, '/runs/77/stage/plan');
expect(provider.value.uri.query, 'visit=1');
});
+3 -14
View File
@@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart';
import '../features/runs/ui/run_detail_finders.dart';
import '../native_back.dart';
import 'package:pipelines_app/application/app_route.dart';
import 'package:pipelines_app/application/app_router.dart';
@@ -496,13 +497,7 @@ void main() {
expect(provider.value.uri.path, '/runs/7');
expect(find.byType(SearchScreen), findsNothing);
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expect(
find.descendant(
of: find.byKey(const Key('run-visit-pane')),
matching: find.text('build · visit 2'),
),
findsOneWidget,
);
expectVisitHeading(tester, 'build', 2);
// Leave the visit page (it covers the shell), then a retired field hit
// opens the plain Summary with no visit.
@@ -613,13 +608,7 @@ void main() {
await tester.pumpAndSettle();
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expect(
find.descendant(
of: find.byKey(const Key('run-visit-pane')),
matching: find.text('build · visit 2'),
),
findsOneWidget,
);
expectVisitHeading(tester, 'build', 2);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();