Merge branch 'main' into worktree-agent-a35ac03e196ffae50
# Conflicts: # app/lib/features/runs/ui/run_detail_content.dart # app/lib/features/runs/ui/run_list_row.dart # app/tool/search_selection_probe_entry.dart
This commit is contained in:
@@ -24,6 +24,7 @@ JsonMap recordedRunFixture() => <String, dynamic>{
|
||||
'retry_of': 12,
|
||||
'diagnostic': 'Traceback: boom',
|
||||
'completed_steps': 2,
|
||||
'size_bytes': 5 * 1024 * 1024,
|
||||
'input': <String, dynamic>{'prompt': 'ship it'},
|
||||
'output': <String, dynamic>{'result': 'ok'},
|
||||
'steps': <dynamic>[
|
||||
@@ -64,6 +65,9 @@ const recordedLabels = [
|
||||
'Started',
|
||||
'Finished',
|
||||
'Duration',
|
||||
'Size on disk',
|
||||
'Tokens',
|
||||
'Cost',
|
||||
'Retry of',
|
||||
'Diagnostic',
|
||||
];
|
||||
@@ -91,6 +95,12 @@ void main() {
|
||||
formatLocalTimestamp('2026-10-19T09:32:05Z'),
|
||||
);
|
||||
expect(rows.firstWhere((row) => row.label == 'Duration').value, '2m 5s');
|
||||
expect(rows.firstWhere((row) => row.label == 'Size on disk').value, '5 MB');
|
||||
expect(
|
||||
rows.firstWhere((row) => row.label == 'Tokens').value,
|
||||
'123 · 100 in, 23 out',
|
||||
);
|
||||
expect(rows.firstWhere((row) => row.label == 'Cost').value, '\$0.50');
|
||||
expect(rows.firstWhere((row) => row.label == 'Retry of').value, 'run 12');
|
||||
final diagnostic = rows.firstWhere((row) => row.label == 'Diagnostic');
|
||||
expect(diagnostic.value, 'Traceback: boom');
|
||||
|
||||
@@ -86,6 +86,48 @@ void main() {
|
||||
expect(find.text('Pipeline unavailable · 2m 5s · 3 steps'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('shows reported tokens beside the size, and nothing without', (
|
||||
tester,
|
||||
) async {
|
||||
Future<void> pump(JsonMap run) => tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: RunListRow(run: run, now: DateTime.utc(2026, 10, 22)),
|
||||
),
|
||||
),
|
||||
);
|
||||
final sized = {..._finished, 'size_bytes': 340 * 1024 * 1024};
|
||||
await pump({
|
||||
...sized,
|
||||
'usage': {
|
||||
'stages': 3,
|
||||
'tokens_known_stages': 3,
|
||||
'tokens_total': 22400015,
|
||||
},
|
||||
});
|
||||
expect(
|
||||
find.text('release · 2m 5s · 3 steps · 340 MB · 22.4M tokens'),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
await pump({
|
||||
...sized,
|
||||
'usage': {
|
||||
'stages': 3,
|
||||
'tokens_known_stages': 2,
|
||||
'tokens_total': 22400015,
|
||||
},
|
||||
});
|
||||
expect(
|
||||
find.text('release · 2m 5s · 3 steps · 340 MB · ≥22.4M tokens'),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
// An older server's list carries no usage: the row is unchanged.
|
||||
await pump(sized);
|
||||
expect(find.text('release · 2m 5s · 3 steps · 340 MB'), findsOneWidget);
|
||||
});
|
||||
|
||||
test('the run action sheet is titled with the run', () {
|
||||
expect(runMoreMenuTitle(_finished), 'Ship the release notes');
|
||||
expect(runMoreMenuTitle({'id': 5, 'name': 'nightly'}), 'nightly');
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_detail_content.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_detail_visit_facts.dart';
|
||||
|
||||
final _reported = <String, dynamic>{
|
||||
'stage': 'build',
|
||||
'sequence': 1,
|
||||
'status': 'completed',
|
||||
'outcome': 'success',
|
||||
'target': 'review',
|
||||
'usage': {
|
||||
'tokens_total': 1500000,
|
||||
'tokens_known': true,
|
||||
'split_known': true,
|
||||
'tokens_in': 1200000,
|
||||
'tokens_out': 300000,
|
||||
'cost_known': true,
|
||||
'cost_usd': 0.42,
|
||||
},
|
||||
};
|
||||
|
||||
final _unreported = <String, dynamic>{
|
||||
'stage': 'gate',
|
||||
'sequence': 2,
|
||||
'status': 'completed',
|
||||
};
|
||||
|
||||
void main() {
|
||||
test('a visit lists its reported tokens and cost as facts', () {
|
||||
final facts = detailVisitFacts(_reported);
|
||||
expect(
|
||||
facts,
|
||||
contains((label: 'Tokens', value: '1.5M · 1.2M in, 300K out')),
|
||||
);
|
||||
expect(facts, contains((label: 'Cost', value: '\$0.42')));
|
||||
final none = detailVisitFacts(_unreported);
|
||||
expect(none.any((fact) => fact.label == 'Tokens'), isFalse);
|
||||
expect(none.any((fact) => fact.label == 'Cost'), isFalse);
|
||||
});
|
||||
|
||||
test('a stage row carries its compact token total', () {
|
||||
final visits = detailTimeline([_reported, _unreported]);
|
||||
expect(visits[0].tokens, '1.5M tokens · \$0.42');
|
||||
expect(visits[1].tokens, isNull);
|
||||
});
|
||||
|
||||
String? rowLabel(Map<String, dynamic> usage) => detailTimeline([
|
||||
{..._unreported, 'usage': usage},
|
||||
])[0].tokens;
|
||||
|
||||
test('a stage row adds its cached share and cost when reported', () {
|
||||
const base = {'tokens_known': true, 'tokens_total': 20100000};
|
||||
expect(
|
||||
rowLabel({
|
||||
...base,
|
||||
'cache_known': true,
|
||||
'cache_read': 19100000,
|
||||
'cost_known': true,
|
||||
'cost_usd': 0.4249,
|
||||
}),
|
||||
'20.1M tokens · 95% cached · \$0.42',
|
||||
);
|
||||
// A known split with no reads is a real 0%, not an absence.
|
||||
expect(
|
||||
rowLabel({...base, 'cache_known': true}),
|
||||
'20.1M tokens · 0% cached',
|
||||
);
|
||||
// An older row without cache_known, or a cache read alone, shows no share.
|
||||
expect(rowLabel({...base, 'cache_read': 19100000}), '20.1M tokens');
|
||||
// Tiny costs stay visible; zero or unknown costs are omitted on the row.
|
||||
expect(
|
||||
rowLabel({...base, 'cost_known': true, 'cost_usd': 0.0042}),
|
||||
'20.1M tokens · <\$0.01',
|
||||
);
|
||||
expect(
|
||||
rowLabel({...base, 'cost_known': true, 'cost_usd': 0.005}),
|
||||
'20.1M tokens · \$0.01',
|
||||
);
|
||||
expect(
|
||||
rowLabel({...base, 'cost_known': true, 'cost_usd': 0}),
|
||||
'20.1M tokens',
|
||||
);
|
||||
expect(rowLabel({...base, 'cost_usd': 1.5}), '20.1M tokens');
|
||||
// The stage detail still says the cost was not reported.
|
||||
final facts = detailVisitFacts({
|
||||
..._unreported,
|
||||
'usage': {...base, 'cost_known': true},
|
||||
});
|
||||
expect(facts, contains((label: 'Cost', value: 'Not reported')));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user