Run card mini-map and stage strip; graph edge hover highlight

The show_run card carries the run's graph and per-stage progress (bounded by
the graph, not the run length) and draws a still mini-map with the run graph
plus a stage strip with status, visits and time. Hovering or tapping an edge
in the pipeline and run graphs highlights it, its label and endpoints, with a
tooltip naming from -> to, the outcome and, for runs, how often it was taken.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 12:56:51 +00:00
parent c4de1de27b
commit 7872e57d40
17 changed files with 1709 additions and 51 deletions
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
import '../../../../../core/api_gateway.dart';
import '../../../chat_run_opener.dart';
import '../../../domain/chat_shown_run.dart';
import 'chat_shown_run_map_view.dart';
import 'chat_shown_surface.dart';
/// The glyph of a run status.
@@ -134,6 +135,10 @@ class _ChatShownRunCardState extends State<ChatShownRunCard> {
),
],
),
if (run.map case final map?) ...[
const SizedBox(height: 10),
ChatShownRunMapView(run: run, map: map, now: _now),
],
],
),
);
@@ -0,0 +1,175 @@
import 'package:flutter/material.dart';
import '../../../../graph/widgets/run_graph_view.dart';
import '../../../domain/chat_shown_run.dart';
/// The mini-map's height: enough for one row of stages and the ends below it
/// at a glance, small enough to keep the card compact.
const double chatShownRunMapHeight = 136;
/// A `show_run` card's graph: a still mini-map of the run's pipeline drawn by
/// the run graph itself (visited stages with their status, the live stage's
/// halo, the taken path solid and untaken routes dashed), then a strip of every
/// stage with its status, visits and time.
class ChatShownRunMapView extends StatelessWidget {
const ChatShownRunMapView({
super.key,
required this.run,
required this.map,
required this.now,
});
final ChatShownRun run;
final ChatShownRunMap map;
/// The current time in epoch milliseconds, for running stages' durations.
final int now;
@override
Widget build(BuildContext context) {
final colors = Theme.of(context).colorScheme;
final current = run.finished ? '' : run.currentStage;
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: [
DecoratedBox(
decoration: BoxDecoration(
color: colors.surfaceContainerLow,
border: Border.all(color: colors.outlineVariant),
borderRadius: BorderRadius.circular(8),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: SizedBox(
key: const Key('chat-shown-run-map'),
height: chatShownRunMapHeight,
child: Padding(
padding: const EdgeInsets.all(6),
child: RunGraphView(
graph: map.graph,
run: map.runDetail(
currentStage: run.currentStage,
executing: !run.finished,
),
onStageSelected: (_) {},
showHeader: false,
expandable: false,
still: true,
),
),
),
),
),
const SizedBox(height: 8),
Wrap(
key: const Key('chat-shown-run-stages'),
spacing: 6,
runSpacing: 6,
children: [
for (final stage in map.stages)
_StageEntry(
stage: stage,
current: stage.key == current,
duration: stage.duration(now),
),
],
),
],
);
}
}
/// The glyph of a recorded stage status; a stage never entered is a hollow
/// circle.
IconData chatShownStageIcon(String status, {required bool visited}) {
if (!visited) return Icons.radio_button_unchecked;
return switch (status) {
'completed' || 'succeeded' => Icons.check_circle,
'failed' => Icons.error,
'running' => Icons.play_circle,
'waiting' => Icons.front_hand,
'interrupted' => Icons.pause_circle,
'canceled' => Icons.cancel,
_ => Icons.circle,
};
}
Color _stageColor(ColorScheme colors, ChatShownRunStage stage) {
if (!stage.visited) return colors.outline;
return switch (stage.status) {
'completed' || 'succeeded' => colors.primary,
'failed' || 'interrupted' => colors.error,
'running' || 'waiting' => colors.tertiary,
_ => colors.onSurfaceVariant,
};
}
/// One stage of the strip: status glyph, name, `×visits` when it looped and
/// the time spent. The run's current stage is filled and bold.
class _StageEntry extends StatelessWidget {
const _StageEntry({
required this.stage,
required this.current,
required this.duration,
});
final ChatShownRunStage stage;
final bool current;
final String? duration;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final colors = theme.colorScheme;
final base = theme.textTheme.labelMedium ?? const TextStyle();
final name = base.copyWith(
color: stage.visited ? colors.onSurface : colors.onSurfaceVariant,
fontWeight: current ? FontWeight.w700 : null,
);
final meta = base.copyWith(color: colors.onSurfaceVariant);
final status = stage.visited ? stage.status : 'not run';
final facts = [if (stage.visits > 1) '×${stage.visits}', ?duration];
return Semantics(
container: true,
label: [
stage.key,
status,
if (stage.visits > 1) '${stage.visits} visits',
?duration,
if (current) 'current stage',
].join(', '),
child: ExcludeSemantics(
child: DecoratedBox(
key: ValueKey('chat-shown-run-stage:${stage.key}'),
decoration: BoxDecoration(
color: current ? colors.secondaryContainer : null,
border: Border.all(
color: current ? colors.secondary : colors.outlineVariant,
),
borderRadius: BorderRadius.circular(8),
),
child: Padding(
padding: const EdgeInsetsDirectional.fromSTEB(6, 3, 8, 3),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
chatShownStageIcon(stage.status, visited: stage.visited),
size: MediaQuery.textScalerOf(context).scale(14),
color: _stageColor(colors, stage),
),
const SizedBox(width: 4),
Text(stage.key, style: name),
if (facts.isNotEmpty) ...[
const SizedBox(width: 6),
Text(facts.join(' · '), style: meta),
],
],
),
),
),
),
);
}
}