Runs list carries per-run token usage; app shows tokens beside size, Most tokens sort, Summary and stage tokens
This commit is contained in:
@@ -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});
|
||||
@@ -23,6 +24,7 @@ typedef DetailVisit = ({
|
||||
String outcome,
|
||||
String target,
|
||||
String? duration,
|
||||
String? tokens,
|
||||
});
|
||||
|
||||
/// The run's primary label: the stored title, else the pipeline name, and only
|
||||
@@ -149,6 +151,10 @@ List<DetailVisit> detailTimeline(dynamic steps) {
|
||||
outcome: '${step['outcome'] ?? ''}'.trim(),
|
||||
target: '${step['target'] ?? ''}'.trim(),
|
||||
duration: _visitDuration(step),
|
||||
tokens: switch (stageTokenUsage(JsonMap.from(step))) {
|
||||
final usage? => tokenUsageLabel(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
|
||||
@@ -53,6 +55,16 @@ List<DetailSummaryRow> detailSummaryRows(JsonMap run) {
|
||||
_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
|
||||
|
||||
@@ -16,7 +16,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.
|
||||
|
||||
@@ -135,8 +135,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,
|
||||
@@ -152,7 +152,14 @@ class RunTimelineRow extends StatelessWidget {
|
||||
title: Text(visit.title),
|
||||
time: visit.duration,
|
||||
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,12 @@ 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)));
|
||||
final cost = tokenUsageCost(usage);
|
||||
if (cost != null) facts.add((label: 'Cost', value: cost));
|
||||
}
|
||||
final target = _text(step['target']);
|
||||
if (target != null) facts.add((label: 'Target', value: target));
|
||||
return facts;
|
||||
|
||||
@@ -9,6 +9,7 @@ import '../../../ui/status/run_status_icon.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'] ?? ''}');
|
||||
final subtitle = [
|
||||
?pipelineLabel,
|
||||
@@ -84,6 +88,7 @@ class RunListRow extends StatelessWidget {
|
||||
?facts.duration,
|
||||
?facts.progress,
|
||||
?size,
|
||||
?tokens,
|
||||
].join(' · ');
|
||||
// A narrow pane keeps the decision facts: the pipeline, and progress
|
||||
// while executing (duration only when there is no pipeline to show).
|
||||
@@ -93,6 +98,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(' · ');
|
||||
final state = runStateOf(run['status']);
|
||||
return AppListRow(
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user