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:
2026-11-04 17:44:29 +00:00
296 changed files with 17727 additions and 3360 deletions
@@ -3,6 +3,7 @@ import 'dart:convert';
import '../../../core/api_gateway.dart';
import '../../pipelines/pipeline_format.dart' show formatDuration;
import '../domain/run_models.dart';
import '../domain/run_tokens.dart';
/// One labelled value in the run detail's metrics block.
typedef DetailMetric = ({String label, String value});
@@ -24,6 +25,7 @@ typedef DetailVisit = ({
String target,
String? duration,
DateTime? runningSince,
String? tokens,
});
/// The run's primary label: the stored title, else the pipeline name, and only
@@ -75,6 +77,7 @@ List<DetailMetric> detailUsageMetrics(dynamic raw) {
final tokenStages = _int(usage['tokens_known_stages']) ?? 0;
final costStages = _int(usage['cost_known_stages']) ?? 0;
final totalTokens = _int(usage['tokens_total']);
final cost = usage['cost_usd'] is num ? usage['cost_usd'] as num : null;
final splitKnown = usage['split_known'] == true && tokenStages > 0;
final rows = <DetailMetric>[
if (stages != null) (label: 'Stages', value: '$stages'),
@@ -94,11 +97,11 @@ List<DetailMetric> detailUsageMetrics(dynamic raw) {
),
(
label: 'Reported cost',
// cost_usd is omitted by the server when zero, so a known stage count
// makes an absent value a real $0.000000 rather than an unknown cost.
value: costStages == 0
? 'Unavailable'
: '\$${((usage['cost_usd'] as num?) ?? 0).toStringAsFixed(6)}',
// A cost of zero (or none) is what subscription models report even
// with a "known" cost: it is not reported, never a measured zero.
value: costStages == 0 || cost == null || cost <= 0
? 'Not reported'
: '\$${cost.toStringAsFixed(6)}',
),
];
if (stages != null && tokenStages < stages) {
@@ -151,6 +154,10 @@ List<DetailVisit> detailTimeline(dynamic steps) {
target: '${step['target'] ?? ''}'.trim(),
duration: _visitDuration(step),
runningSince: _visitRunningSince(step),
tokens: switch (stageTokenUsage(JsonMap.from(step))) {
final usage? => stageTokenRowLabel(usage),
null => null,
},
);
}(),
];
@@ -1,5 +1,7 @@
import '../../../core/api_gateway.dart';
import '../../pipelines/pipeline_format.dart';
import '../domain/run_deletion.dart' show formatByteSize, runSizeBytes;
import '../domain/run_tokens.dart';
import 'run_detail_visit_facts.dart';
/// One recorded Summary row: the web run summary's key/value shape.
@@ -14,9 +16,9 @@ typedef DetailSummaryRow = ({
bool block,
});
/// The run Summary's rows, in the web summary's order: Pipeline, Stage,
/// Workspace, Content hash, Started, Finished, Duration, Retry of and the
/// Diagnostic block.
/// The run Summary's rows: Pipeline, Stage, Workspace, Content hash, Started,
/// Finished, Duration, Size on disk, Tokens, Cost, Retry of and the Diagnostic
/// block.
///
/// Only values the server actually recorded are rows: a blank field is omitted
/// rather than drawn as an empty or invented placeholder, exactly as
@@ -56,6 +58,16 @@ List<DetailSummaryRow> detailSummaryRows(JsonMap run, {DateTime? now}) {
? now?.difference(since).inSeconds
: durationSeconds(_text(run['created_at']), _text(run['finished_at']));
if (seconds != null) add('Duration', formatDuration(seconds));
// What the run occupies on disk and what it spent, as the server measured
// and the harness reported; an unmeasured size or unreported usage has no
// row.
final bytes = runSizeBytes(run);
if (bytes != null) add('Size on disk', formatByteSize(bytes));
final usage = runTokenUsage(run);
if (usage != null) {
add('Tokens', tokenUsageDetail(usage));
add('Cost', tokenUsageCost(usage));
}
final retryOf = _number(run['retry_of'])?.toInt() ?? 0;
if (retryOf > 0) add('Retry of', 'run $retryOf');
// A diagnostic is a recorded document: its own whitespace is preserved, but a
@@ -17,7 +17,7 @@ import '../../../ui/adaptive/floating_bar_layout.dart';
/// the stored original prompt with its copy control and the collapsible Input
/// and Output sections.
///
/// The web run detail has no usage block, so no metrics are drawn here. A fact
/// The run's size and reported token usage are facts like the others. A fact
/// the server did not record is omitted rather than shown as an invented or
/// `Unavailable` row; only the Input/Output empty sentences remain, and only
/// when that section recorded nothing.
@@ -137,8 +137,8 @@ class RunTimelineRow extends StatelessWidget {
@override
Widget build(BuildContext context) {
final state = _state;
// The outcome chip leads the second line, then where the visit went; the
// duration is the row's time.
// The outcome chip leads the second line, then where the visit went and
// the tokens it reported; the duration is the row's time.
return AppListRow(
cupertino: cupertino,
selected: selected,
@@ -163,7 +163,14 @@ class RunTimelineRow extends StatelessWidget {
),
),
subtitleLeading: _outcome(context),
subtitle: visit.target.isEmpty ? null : Text('→ ${visit.target}'),
subtitle: visit.target.isEmpty && visit.tokens == null
? null
: Text(
[
if (visit.target.isNotEmpty) '→ ${visit.target}',
?visit.tokens,
].join(' · '),
),
);
}
}
@@ -1,6 +1,7 @@
import '../../../core/api_gateway.dart';
import '../../graph/domain/stage_definition.dart';
import '../../pipelines/pipeline_format.dart';
import '../domain/run_tokens.dart';
import 'run_detail_content.dart';
/// The exact empty wording for a visit's recorded Input and Output. They are
@@ -80,6 +81,11 @@ List<VisitFact> detailVisitFacts(JsonMap step) {
if (duration != null) facts.add((label: 'Duration', value: duration));
final model = detailVisitProviderModel(step);
if (model != null) facts.add((label: 'Provider/model', value: model));
final usage = stageTokenUsage(step);
if (usage != null) {
facts.add((label: 'Tokens', value: tokenUsageDetail(usage)));
facts.add((label: 'Cost', value: tokenUsageCost(usage)));
}
final target = _text(step['target']);
if (target != null) facts.add((label: 'Target', value: target));
return facts;
@@ -10,6 +10,7 @@ import '../../../ui/text/live_elapsed_builder.dart';
import '../../../ui/text/relative_time_label.dart';
import '../domain/run_deletion.dart';
import '../domain/run_models.dart';
import '../domain/run_tokens.dart';
import 'run_more_menu.dart';
/// One run in the list: a status avatar, title/time, and one muted fact
@@ -77,6 +78,9 @@ class RunListRow extends StatelessWidget {
final scheduled = run['scheduled'] == true;
final bytes = runSizeBytes(run);
final size = bytes == null ? null : formatByteSize(bytes);
// Reported tokens sit beside the size; an older server sends none.
final usage = runTokenUsage(run);
final tokens = usage == null ? null : tokenUsageLabel(usage);
final createdAt = DateTime.tryParse('${run['created_at'] ?? ''}');
String subtitle(DateTime now) {
final facts = runRowFacts(run, now);
@@ -86,6 +90,7 @@ class RunListRow extends StatelessWidget {
?facts.duration,
?facts.progress,
?size,
?tokens,
].join(' · ');
}
@@ -99,6 +104,7 @@ class RunListRow extends StatelessWidget {
if (run['executing'] == true && facts.progress != null) facts.progress!,
if (pipelineLabel == null && facts.duration != null) facts.duration!,
?size,
?tokens,
].join(' · ');
}
@@ -162,14 +162,7 @@ class RunsController extends ChangeNotifier {
// A cancel/decision reply changes lifecycle fields as well as title.
// Keep sparse/unknown summary fields, without copying bulky detail-only
// payloads into the held list or inventing missing values.
const detailOnly = {
'steps',
'input',
'output',
'graph',
'usage',
'notifications',
};
const detailOnly = {'steps', 'input', 'output', 'graph', 'notifications'};
runs = [...runs]
..[index] = {
...runs[index],
@@ -7,6 +7,7 @@ const runSorts = [
('newest_first', 'Newest first'),
('oldest_first', 'Oldest first'),
('largest_first', 'Largest first'),
('most_tokens', 'Most tokens'),
('longest_duration', 'Longest duration'),
('shortest_duration', 'Shortest duration'),
('pipeline_name', 'Pipeline name'),
@@ -25,8 +26,8 @@ const runTimeRanges = [
];
/// Sorts that list runs flat instead of under day headings: an order by
/// size has no meaningful day grouping.
const flatRunSorts = {'largest_first'};
/// size or token count has no meaningful day grouping.
const flatRunSorts = {'largest_first', 'most_tokens'};
/// The pipelines the loaded runs belong to, by name then id.
List<({int id, String name})> runFilterPipelines(RunsController controller) {