Files
pipelines/app/lib/features/runs/ui/run_path_mini.dart
T
alan ca2f7eee32 App: add a selectable app design with a Terminal look
AppDesign builds each design's light and dark ThemeData with an
AppDesignTokens extension (corner radius, flat surfaces, frame colour,
ANSI accents, prompt glyph). Settings gains a Design picker stored per
device; the theme hosts rebuild live. Terminal is monospace (bundled
RobotoMono), near-black or paper, flat 1px frames with 3px corners, and
draws the chat transcript as prompt lines, tool dot/result lines and
bracketed follow-up lines. Default keeps its exact themes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 16:43:59 +00:00

96 lines
3.2 KiB
Dart

import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/status/run_status_icon.dart';
import '../../graph/widgets/graph_stage_node.dart' show graphStatusState;
/// One stage on a run's path: its key and the state its latest visit left.
typedef RunPathStage = ({String key, String state});
/// The stages a run visited, in first-visit order, each with the state of its
/// latest visit, plus the end it reached (`#success`/`#failure`) if any. Read
/// from the run's recorded steps or the list row's `graph_evidence`.
({List<RunPathStage> stages, String? end}) runPath(JsonMap run) {
final raw = run['steps'] is List
? run['steps'] as List
: (run['graph_evidence'] is Map
? (run['graph_evidence'] as Map)['visits'] as List? ?? const []
: const []);
final order = <String>[];
final states = <String, String>{};
String? end;
for (final entry in raw) {
if (entry is! Map) continue;
final key = '${entry['stage'] ?? ''}'.trim();
if (key.isEmpty) continue;
if (!states.containsKey(key)) order.add(key);
final target = '${entry['target'] ?? ''}'.trim();
final outcome = '${entry['outcome'] ?? ''}'.trim();
final status = '${entry['status'] ?? ''}'.trim();
states[key] = target == '#failure' || outcome == 'error'
? 'failed'
: graphStatusState(status.isEmpty ? outcome : status);
if (target == '#success' || target == '#failure') end = target;
}
return (
stages: [for (final key in order) (key: key, state: states[key]!)],
end: end,
);
}
/// A run's path as a small picture: one coloured box per visited stage,
/// joined in order, and a dot for the end it reached.
class RunPathMini extends StatelessWidget {
const RunPathMini({super.key, required this.run, this.maxStages = 6});
final JsonMap run;
final int maxStages;
@override
Widget build(BuildContext context) {
final path = runPath(run);
if (path.stages.isEmpty) return const SizedBox.shrink();
// A long path keeps its latest stages.
final stages = path.stages.length > maxStages
? path.stages.sublist(path.stages.length - maxStages)
: path.stages;
final line = Theme.of(context).colorScheme.outlineVariant;
Widget box(RunPathStage stage) => Container(
width: 14,
height: 10,
decoration: BoxDecoration(
color: runStatusColorOf(context, stage.state),
borderRadius: BorderRadius.circular(3),
),
);
Widget join() => Container(width: 5, height: 1.5, color: line);
final end = path.end;
return ExcludeSemantics(
child: Row(
key: const Key('run-path-mini'),
mainAxisSize: MainAxisSize.min,
children: [
for (var index = 0; index < stages.length; index += 1) ...[
if (index > 0) join(),
box(stages[index]),
],
if (end != null) ...[
join(),
Container(
width: 8,
height: 8,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: runStatusColorOf(
context,
end == '#success' ? 'succeeded' : 'failed',
),
),
),
],
],
),
);
}
}