fix(runs): colour timeline outcomes by name, not by status

A completed step's outcome chip took the success colour, so 'rejected'
read green beside 'success'. Outcome chips now get one colour per
distinct outcome name in the run (assigned by first appearance, from a
well-separated hue list that continues by the golden angle), so equal
names match and different names never share a colour. No outcome word
is wired to a colour; the status glyph still shows the step's state.
This commit is contained in:
2026-10-31 12:28:54 +00:00
parent 480f8843eb
commit 1bf2ae41c4
4 changed files with 153 additions and 1 deletions
@@ -2,6 +2,7 @@ import '../../../ui/theme/app_theme.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/status/outcome_palette.dart';
import '../../../ui/status/run_status_icon.dart';
import '../domain/run_models.dart';
import 'run_detail_content.dart';
@@ -38,6 +39,9 @@ class RunTimelineList extends StatelessWidget {
children: const [Text('No visits recorded.')],
);
}
// One colour per distinct outcome name across the whole run, so the same
// outcome reads the same on every row and different ones never match.
final palette = OutcomePalette(visits.map((visit) => visit.outcome));
final rows = [
for (var index = 0; index < visits.length; index += 1)
RunTimelineRow(
@@ -47,6 +51,7 @@ class RunTimelineList extends StatelessWidget {
visit: visits[index],
selected: visits[index].sequence == selectedSequence,
cupertino: cupertino,
palette: palette,
onTap: onSelected == null ? null : () => onSelected!(index),
),
];
@@ -83,6 +88,7 @@ class RunTimelineRow extends StatelessWidget {
required this.selected,
required this.cupertino,
this.onTap,
this.palette,
});
final DetailVisit visit;
@@ -90,6 +96,10 @@ class RunTimelineRow extends StatelessWidget {
final bool cupertino;
final VoidCallback? onTap;
/// The run's outcome colours; without one the row colours its own outcome
/// as the first (and only) name.
final OutcomePalette? palette;
/// The visit's state for its glyph: the outcome when it has one (a completed
/// step can still have failed), else the step status.
String get _state {
@@ -110,7 +120,14 @@ class RunTimelineRow extends StatelessWidget {
final label = visit.outcome.isNotEmpty
? visit.outcome
: (visit.status.isEmpty ? 'unknown' : visit.status);
final color = runStatusColor(_state).resolveFrom(context);
// An outcome is coloured by its name (no word is wired to a colour); a
// visit with no outcome yet keeps its status colour.
final color = visit.outcome.isNotEmpty
? (palette ?? OutcomePalette([visit.outcome])).colorFor(
context,
visit.outcome,
)
: runStatusColor(_state).resolveFrom(context);
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
decoration: BoxDecoration(