Merge branch 'main' into worktree-agent-aab11f4f1fe3dff6b
# Conflicts: # app/test/features/runs/ui/run_list_row_test.dart
This commit is contained in:
@@ -16,6 +16,7 @@ typedef DetailMetric = ({String label, String value});
|
||||
typedef DetailVisit = ({
|
||||
String stage,
|
||||
int? sequence,
|
||||
int visit,
|
||||
String title,
|
||||
String subtitle,
|
||||
String status,
|
||||
@@ -114,22 +115,42 @@ List<DetailMetric> detailUsageMetrics(dynamic raw) {
|
||||
/// Every recorded visit with its server sequence, in recorded order.
|
||||
List<DetailVisit> detailTimeline(dynamic steps) {
|
||||
if (steps is! List) return const [];
|
||||
final records = steps.whereType<Map>().toList(growable: false);
|
||||
final ordered = List<int>.generate(records.length, (index) => index)
|
||||
..sort((a, b) {
|
||||
final bySequence = (_int(records[a]['sequence']) ?? 0).compareTo(
|
||||
_int(records[b]['sequence']) ?? 0,
|
||||
);
|
||||
return bySequence != 0 ? bySequence : a.compareTo(b);
|
||||
});
|
||||
final positions = <String, int>{};
|
||||
final visits = <int, int>{};
|
||||
for (final index in ordered) {
|
||||
final stage = '${records[index]['stage'] ?? ''}'.trim();
|
||||
final position = (positions[stage] ?? 0) + 1;
|
||||
positions[stage] = position;
|
||||
visits[index] = _displayVisit(records[index], position);
|
||||
}
|
||||
return [
|
||||
for (final step in steps.whereType<Map>())
|
||||
(
|
||||
stage: '${step['stage'] ?? ''}'.trim(),
|
||||
sequence: step['sequence'] is num
|
||||
? (step['sequence'] as num).toInt()
|
||||
: null,
|
||||
title:
|
||||
'${_text(step['stage'], 'Stage unavailable')} · visit '
|
||||
'${step['sequence'] is num ? (step['sequence'] as num).toInt() : 'unavailable'}',
|
||||
subtitle: _visitSubtitle(step),
|
||||
status: '${step['status'] ?? ''}'.trim(),
|
||||
outcome: '${step['outcome'] ?? ''}'.trim(),
|
||||
target: '${step['target'] ?? ''}'.trim(),
|
||||
duration: _visitDuration(step),
|
||||
),
|
||||
for (var index = 0; index < records.length; index += 1)
|
||||
() {
|
||||
final step = records[index];
|
||||
final stage = '${step['stage'] ?? ''}'.trim();
|
||||
final visit = visits[index]!;
|
||||
return (
|
||||
stage: stage,
|
||||
sequence: step['sequence'] is num
|
||||
? (step['sequence'] as num).toInt()
|
||||
: null,
|
||||
visit: visit,
|
||||
title: '${_text(step['stage'], 'Stage unavailable')} · Visit $visit',
|
||||
subtitle: _visitSubtitle(step),
|
||||
status: '${step['status'] ?? ''}'.trim(),
|
||||
outcome: '${step['outcome'] ?? ''}'.trim(),
|
||||
target: '${step['target'] ?? ''}'.trim(),
|
||||
duration: _visitDuration(step),
|
||||
);
|
||||
}(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -166,6 +187,15 @@ String _visitSubtitle(Map step) {
|
||||
].join(' · ');
|
||||
}
|
||||
|
||||
/// The stage's own recorded visit number, falling back to its position among
|
||||
/// visits to that stage rather than the run-wide step sequence.
|
||||
int _displayVisit(Map step, int position) {
|
||||
final control = step['control'];
|
||||
final recorded = control is Map ? control['visit'] : null;
|
||||
if (recorded is num && recorded > 0) return recorded.toInt();
|
||||
return position;
|
||||
}
|
||||
|
||||
/// The web's `stepDuration`: finished minus started, when both are recorded.
|
||||
String? _visitDuration(Map step) {
|
||||
final started = DateTime.tryParse('${step['started_at'] ?? ''}');
|
||||
|
||||
@@ -90,13 +90,13 @@ class _RunVisitPaneState extends State<RunVisitPane> {
|
||||
}
|
||||
}
|
||||
|
||||
/// The page bar's subtitle for a recorded visit: its sequence, then the run
|
||||
/// The page bar's subtitle for a recorded visit: its per-stage visit, then the run
|
||||
/// it belongs to (`Visit 2 · Run 7 · Nightly report`).
|
||||
String runVisitSubtitle(JsonMap run, DetailVisit visit) {
|
||||
final runId = '${run['id'] ?? ''}'.trim();
|
||||
final title = detailTitle(run);
|
||||
return [
|
||||
if (visit.sequence != null) 'Visit ${visit.sequence}',
|
||||
'Visit ${visit.visit}',
|
||||
if (runId.isNotEmpty) 'Run $runId',
|
||||
if (title.isNotEmpty && title != 'Run $runId') title,
|
||||
].join(' · ');
|
||||
|
||||
@@ -13,7 +13,7 @@ import '../../attention/notify/notification_controller.dart';
|
||||
import '../../attention/runtime/attention_controller.dart';
|
||||
import '../../attention/runtime/attention_store.dart';
|
||||
import '../../attention/ui/needs_you_runs_heading.dart';
|
||||
import '../../pipelines/pipeline_format.dart' show formatRanAgo;
|
||||
import '../../../ui/text/relative_time.dart';
|
||||
import '../domain/run_models.dart';
|
||||
import '../../../shell/shell_bar.dart';
|
||||
import 'run_more_menu.dart';
|
||||
@@ -354,7 +354,7 @@ class RunListRow extends StatelessWidget {
|
||||
child: RunStatusIcon(state: state, label: runStatusLabel(run)),
|
||||
),
|
||||
title: Text(title),
|
||||
time: formatRanAgo('${run['created_at'] ?? ''}', now),
|
||||
time: formatRelativeTimestamp('${run['created_at'] ?? ''}', now: now),
|
||||
subtitle: Text(subtitle),
|
||||
compactSubtitle: Text(compactSubtitle),
|
||||
// A narrow list pane beside the open run leaves the row no room for a
|
||||
|
||||
Reference in New Issue
Block a user