feat(app): match the web run detail tabs and summary shape

This commit is contained in:
2026-10-22 14:13:38 +01:00
parent dc0a52380b
commit be6b6239fc
7 changed files with 561 additions and 326 deletions
@@ -7,39 +7,27 @@ import 'package:pipelines_app/features/runs/ui/run_detail_summary_fields.dart';
import 'run_detail_graph_support.dart';
/// A run whose latest visit recorded every summary fact, plus reported usage.
/// A run whose recorded facts fill every Summary row.
JsonMap recordedRunFixture() => <String, dynamic>{
'id': 51,
'title': 'Summary run',
'name': 'release',
'pipeline_id': 3,
'version': 2,
'status': 'succeeded',
'current_stage': 'review',
'workspace': '/srv/workspaces/run-51',
'content_hash': 'abc123def456',
'created_at': '2026-10-19T09:30:00Z',
'finished_at': '2026-10-19T09:32:05Z',
'retry_of': 12,
'diagnostic': 'Traceback: boom',
'completed_steps': 2,
'input': <String, dynamic>{'prompt': 'ship it'},
'output': <String, dynamic>{'result': 'ok'},
'steps': <dynamic>[
<String, dynamic>{
'stage': 'build',
'sequence': 1,
'status': 'completed',
'outcome': 'success',
'provider': 'openai',
'model': 'gpt-luna',
'target': 'review',
},
<String, dynamic>{
'stage': 'review',
'sequence': 2,
'status': 'completed',
'outcome': 'success',
'provider': 'anthropic',
'model': 'claude-x',
'target': '#success',
'verdict': <String, dynamic>{
'option': 'approve',
'reason': 'Looks good.',
},
},
<String, dynamic>{'stage': 'build', 'sequence': 1, 'status': 'completed'},
<String, dynamic>{'stage': 'review', 'sequence': 2, 'status': 'completed'},
],
'usage': <String, dynamic>{
'stages': 1,
@@ -53,42 +41,88 @@ JsonMap recordedRunFixture() => <String, dynamic>{
},
};
/// A run that recorded none of the summary facts and reported no usage.
/// A run that recorded no summary fact and no input or output.
JsonMap absentRunFixture() => <String, dynamic>{
'id': 51,
'title': 'Sparse run',
'name': 'release',
'status': 'succeeded',
'current_stage': ' ',
'workspace': '',
'content_hash': ' ',
'created_at': '',
'finished_at': '',
'input': <String, dynamic>{'prompt': 'ship it'},
'steps': <dynamic>[
<String, dynamic>{
'stage': 'build',
'sequence': 1,
'status': 'completed',
'provider': ' ',
'model': '',
'target': ' ',
'verdict': null,
},
],
'diagnostic': ' ',
'steps': <dynamic>[],
};
const summaryFacts = [
const recordedLabels = [
'Pipeline',
'Stage',
'Workspace',
'Content hash',
'Started',
'Finished',
'Duration',
'Provider/model',
'Target',
'Verdict',
'Retry of',
'Diagnostic',
];
void main() {
test('recorded facts become the web summary rows in order', () {
final rows = detailSummaryRows(recordedRunFixture());
expect(rows.map((row) => row.label), recordedLabels);
expect(rows.first.value, 'id 3 · v2');
expect(rows.firstWhere((row) => row.label == 'Stage').value, 'review');
expect(
rows.firstWhere((row) => row.label == 'Workspace').value,
'/srv/workspaces/run-51',
);
final hash = rows.firstWhere((row) => row.label == 'Content hash');
expect(hash.value, 'abc123def456');
expect(hash.monospace, isTrue);
expect(
rows.firstWhere((row) => row.label == 'Started').value,
formatLocalTimestamp('2026-10-19T09:30:00Z'),
);
expect(
rows.firstWhere((row) => row.label == 'Finished').value,
formatLocalTimestamp('2026-10-19T09:32:05Z'),
);
expect(rows.firstWhere((row) => row.label == 'Duration').value, '2m 5s');
expect(rows.firstWhere((row) => row.label == 'Retry of').value, 'run 12');
final diagnostic = rows.firstWhere((row) => row.label == 'Diagnostic');
expect(diagnostic.value, 'Traceback: boom');
expect(diagnostic.block, isTrue);
});
test('a blank fact is omitted, never an Unavailable row', () {
final rows = detailSummaryRows(absentRunFixture());
expect(rows, isEmpty);
expect(rows.any((row) => row.value == 'Unavailable'), isFalse);
});
test('an absent pipeline id falls back to the recorded name', () {
final rows = detailSummaryRows(absentRunFixture()..['name'] = 'release');
expect(rows.single.label, 'Pipeline');
expect(rows.single.value, 'release');
});
test('identity uses the recorded and completed visit wording', () {
expect(
detailSummaryIdentity(recordedRunFixture()),
'run 51 · 2 recorded visits · 2 completed visits',
);
expect(
detailSummaryIdentity(absentRunFixture()),
'run 51 · 0 recorded visits · 0 completed visits',
);
});
for (final platform in RunDetailTestPlatform.values) {
testWidgets('${platform.name} summary renders each recorded field', (
testWidgets('${platform.name} summary renders the recorded rows only', (
tester,
) async {
await pumpRunDetail(
@@ -98,32 +132,41 @@ void main() {
size: const Size(900, 1600),
);
for (final label in summaryFacts) {
for (final label in recordedLabels) {
expect(find.text(label), findsOneWidget, reason: label);
}
expect(find.text('id 3 · v2'), findsOneWidget);
expect(find.text('review'), findsOneWidget);
expect(find.text('/srv/workspaces/run-51'), findsOneWidget);
expect(find.text('abc123def456'), findsOneWidget);
final started = formatLocalTimestamp('2026-10-19T09:30:00Z');
final finished = formatLocalTimestamp('2026-10-19T09:32:05Z');
expect(find.text(started!), findsOneWidget);
expect(find.text(finished!), findsOneWidget);
expect(find.text('2m 5s'), findsOneWidget);
expect(find.text('anthropic / claude-x'), findsOneWidget);
expect(find.text('#success'), findsOneWidget);
expect(find.text('approve\nLooks good.'), findsOneWidget);
expect(find.text('run 12'), findsOneWidget);
expect(find.text('Traceback: boom'), findsOneWidget);
// Tokens and cost keep their existing Summary home and exact values.
await tester.ensureVisible(find.text('Metrics'));
await tester.tap(find.text('Metrics'));
await tester.pumpAndSettle();
expect(find.text('123'), findsOneWidget);
expect(find.text('100'), findsOneWidget);
expect(find.text('23'), findsOneWidget);
expect(find.text('\$0.500000'), findsOneWidget);
// The web run detail has no usage block, so no metrics tile is drawn.
expect(find.text('Metrics'), findsNothing);
expect(find.text('Unavailable'), findsNothing);
expect(find.text('Original prompt'), findsOneWidget);
if (platform == RunDetailTestPlatform.material) {
final hash = tester.widget<SelectableText>(
find.widgetWithText(SelectableText, 'abc123def456'),
);
expect(hash.style?.fontFamily, 'monospace');
} else {
final tile = tester.widget<CupertinoListTile>(
find.byKey(const ValueKey('run-detail-summary-content-hash')),
);
expect((tile.subtitle! as Text).style?.fontFamily, 'monospace');
}
});
testWidgets('${platform.name} summary states absent facts as unknown', (
tester,
) async {
testWidgets('${platform.name} summary sections state their exact empty '
'wording', (tester) async {
await pumpRunDetail(
tester,
platform,
@@ -131,50 +174,39 @@ void main() {
size: const Size(900, 1600),
);
for (final label in summaryFacts) {
expect(find.text(label), findsOneWidget, reason: label);
for (final label in recordedLabels) {
expect(find.text(label), findsNothing, reason: label);
}
expect(
find.text(summaryUnknownValue),
findsNWidgets(summaryFacts.length),
);
expect(find.text('0'), findsNothing);
expect(find.text('false'), findsNothing);
expect(find.text('Unavailable'), findsNothing);
expect(find.text('Metrics'), findsNothing);
await tester.ensureVisible(find.text('Metrics'));
await tester.tap(find.text('Metrics'));
await tester.ensureVisible(find.text('Input'));
await tester.pumpAndSettle();
expect(find.text('No reported usage.'), findsOneWidget);
expect(find.text('0'), findsNothing);
await tester.tap(find.text('Input'));
await tester.pumpAndSettle();
expect(find.text('No input recorded.'), findsOneWidget);
await tester.ensureVisible(find.text('Output'));
await tester.pumpAndSettle();
await tester.tap(find.text('Output'));
await tester.pumpAndSettle();
expect(find.text('No output recorded.'), findsOneWidget);
});
testWidgets('${platform.name} summary input section shows the recorded '
'field', (tester) async {
await pumpRunDetail(
tester,
platform,
run: recordedRunFixture(),
size: const Size(900, 1600),
);
await tester.ensureVisible(find.text('Input'));
await tester.pumpAndSettle();
await tester.tap(find.text('Input'));
await tester.pumpAndSettle();
expect(find.textContaining('"prompt": "ship it"'), findsOneWidget);
});
}
test('visit facts come from the current stage latest visit', () {
final run = recordedRunFixture()..['current_stage'] = 'build';
final fields = detailSummaryFields(run);
String value(String label) =>
fields.firstWhere((field) => field.label == label).value;
expect(value('Provider/model'), 'openai / gpt-luna');
expect(value('Target'), 'review');
expect(value('Verdict'), 'Unavailable');
});
test('a current stage without a visit records no visit facts', () {
final run = recordedRunFixture()..['current_stage'] = 'audit';
final fields = detailSummaryFields(run);
for (final label in ['Provider/model', 'Target', 'Verdict']) {
expect(
fields.firstWhere((field) => field.label == label).value,
'Unavailable',
reason: label,
);
}
});
test('unknown wording is the web usage word and never zero', () {
expect(summaryUnknownValue, 'Unavailable');
final fields = detailSummaryFields(absentRunFixture());
expect(fields.map((field) => field.label), summaryFacts);
expect(fields.every((field) => field.value == 'Unavailable'), isTrue);
});
}
@@ -3,6 +3,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/graph/widgets/run_graph_view.dart';
import 'package:pipelines_app/features/runs/actions/title_wording.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_tab.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_tab_strip.dart';
import 'run_detail_graph_support.dart';
@@ -13,11 +14,24 @@ void main() {
) async {
await pumpRunDetail(tester, platform);
for (final label in ['Summary', 'Graph', 'Input', 'Output', 'Timeline']) {
expect(renderedRunDetailTabs, [
RunDetailTab.summary,
RunDetailTab.graph,
RunDetailTab.timeline,
]);
for (final label in ['Summary', 'Graph', 'Timeline']) {
expect(find.text(label), findsOneWidget);
}
// Input and Output are Summary sections now, never separate tabs.
final strip = find.byKey(const Key('run-detail-tabs'));
for (final label in ['Input', 'Output']) {
expect(
find.descendant(of: strip, matching: find.text(label)),
findsNothing,
);
}
var previous = double.negativeInfinity;
for (final tab in RunDetailTab.values) {
for (final tab in renderedRunDetailTabs) {
final center = tester.getCenter(runDetailTab(tab));
expect(center.dx, greaterThan(previous));
previous = center.dx;
@@ -26,8 +40,6 @@ void main() {
for (final tab in [
RunDetailTab.graph,
RunDetailTab.input,
RunDetailTab.output,
RunDetailTab.timeline,
RunDetailTab.summary,
]) {
@@ -31,7 +31,7 @@ class FakeGateway implements ApiGateway {
const prompt = ' keep\n\nspacing ';
JsonMap runFixture({JsonMap? usage, int steps = 2}) {
JsonMap runFixture({int steps = 2}) {
final run = <String, dynamic>{
'id': 7,
'title': 'Nightly build',
@@ -58,20 +58,9 @@ JsonMap runFixture({JsonMap? usage, int steps = 2}) {
},
],
};
if (usage != null) run['usage'] = usage;
return run;
}
JsonMap usageFixture({int known = 1}) => {
'stages': 1,
'tokens_total': 0,
'tokens_known_stages': known,
'tokens_in': 0,
'tokens_out': 0,
'split_known': true,
'cost_known_stages': known,
};
Future<void> pumpDetail(
WidgetTester tester,
AppPlatform platform,
@@ -160,11 +149,14 @@ void main() {
expect(find.textContaining('Original prompt'), findsOneWidget);
if (platform == AppPlatform.material) {
expect(find.byType(Chip), findsOneWidget);
expect(find.byType(ExpansionTile), findsOneWidget);
expect(
tester.widget(find.byKey(const ValueKey('run-detail-summary-input'))),
isA<ExpansionTile>(),
);
} else {
expect(find.byType(Material), findsNothing);
expect(find.byType(Chip), findsNothing);
expect(find.byType(CupertinoExpansionTile), findsOneWidget);
expect(find.byType(CupertinoExpansionTile), findsWidgets);
}
Future<void> tapTab(String label) async {
@@ -174,10 +166,25 @@ void main() {
await tester.pumpAndSettle();
}
await tapTab('Input');
Future<void> openSummarySection(String label) async {
final summaryScroll = find.descendant(
of: find.byKey(const Key('run-detail-tab-body-summary')),
matching: find.byType(Scrollable),
);
await tester.scrollUntilVisible(
find.text(label),
200,
scrollable: summaryScroll.first,
);
await tester.pumpAndSettle();
await tester.tap(find.text(label));
await tester.pumpAndSettle();
}
await openSummarySection('Input');
expect(find.textContaining('"alpha": 1'), findsOneWidget);
await tapTab('Output');
await openSummarySection('Output');
expect(find.textContaining('"ok": true'), findsOneWidget);
await tapTab('Timeline');
@@ -275,21 +282,4 @@ void main() {
expect(find.text('Could not copy prompt to clipboard.'), findsOneWidget);
});
}
testWidgets('reported zero and missing usage stay distinct', (tester) async {
gateway.detail = runFixture(usage: usageFixture());
await controller.select(1);
await pumpDetail(tester, AppPlatform.material, controller, gateway);
await tester.tap(find.text('Metrics'));
await tester.pumpAndSettle();
expect(find.text('Unavailable'), findsNothing);
expect(find.text('0'), findsNWidgets(3));
expect(find.text('\$0.000000'), findsOneWidget);
gateway.detail = runFixture(usage: usageFixture(known: 0));
await controller.select(1);
await tester.pumpAndSettle();
expect(find.text('Unavailable'), findsNWidgets(4));
expect(find.text('0'), findsNothing);
});
}