fix(app): meaning colours for common outcomes; detail pages fill the pane

Timeline outcomes: success-like words are green, failures red,
rejections orange, retries/advisories amber, skips/cancellations grey;
a second word of the same family takes the family's next shade and any
other word a distinct hue outside the families, so different outcomes
still never share a colour.
Run detail, stage page and pipeline Summary no longer cap their width
at 840: on an unfolded foldable the sections fill the pane. The unused
ReadingWidth helper is removed.
This commit is contained in:
2026-10-31 14:36:15 +00:00
parent 33cb9ca121
commit 6b11b136db
9 changed files with 195 additions and 261 deletions
@@ -8,7 +8,6 @@ import '../../../shell/destination.dart';
import '../../../shell/empty_detail_pane.dart';
import '../../../shell/shell_bar.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/layout/reading_width.dart';
import '../../graph/domain/graph_definition.dart';
import '../../graph/widgets/stage_definition_view.dart';
import '../pipeline_models.dart';
@@ -305,20 +304,10 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
);
}
/// A scrolling reading body: the whole pane scrolls, the content keeps
/// [kReadingMaxWidth] from the leading edge.
Widget _scrolling(Widget child) => ListView(
children: [
Align(
alignment: AlignmentDirectional.topStart,
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: kReadingMaxWidth),
child: child,
),
),
const SizedBox(height: 24),
],
);
/// A scrolling reading body: the whole pane scrolls and the content fills
/// its width.
Widget _scrolling(Widget child) =>
ListView(children: [child, const SizedBox(height: 24)]);
Widget _withoutDetail(BuildContext context) {
if (!_controller.hasSelection) {
+2 -10
View File
@@ -1,7 +1,6 @@
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/adaptive/segmented_bar.dart';
import '../../../ui/adaptive/top_glass_strip.dart';
import '../../../ui/layout/reading_width.dart';
import 'dart:math' as math;
import 'package:flutter/cupertino.dart';
@@ -377,15 +376,8 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
);
final body = KeyedSubtree(
key: ValueKey('run-detail-body-${widget.run['id']}'),
// Reading tabs keep a readable width on a wide window; canvases,
// viewers and the gallery keep the whole pane.
child: switch (shown) {
RunDetailTab.summary ||
RunDetailTab.input ||
RunDetailTab.output ||
RunDetailTab.timeline => ReadingWidth(child: _body(shown)),
_ => _body(shown),
},
// Every tab fills the pane, on a phone and an unfolded foldable alike.
child: _body(shown),
);
if (edge == FloatingBarEdge.top &&
constraints.maxWidth >= kRunDetailWideChromeMinWidth) {
+13 -22
View File
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/layout/reading_width.dart';
import 'run_detail_content.dart';
import 'run_detail_visit_facts_view.dart';
import 'run_detail_visit_sections.dart';
@@ -73,31 +72,23 @@ class _RunVisitPaneState extends State<RunVisitPane> {
selected: _section,
onSelected: (section) => setState(() => _section = section),
),
// Reading sections keep a readable width on a wide window; the
// gallery and the changes viewer keep the whole page.
child: _capped(
runVisitSectionBody(
section: _section,
run: widget.run,
step: widget.step,
visitIndex: widget.visitIndex,
stageKey: widget.visit.stage,
runSteps: widget.runSteps,
gateway: widget.gateway,
onRunChanged: widget.onRunChanged,
configuredEndpoint: widget.configuredEndpoint,
cupertino: widget.cupertino,
facts: RunVisitFactsView(step: widget.step),
),
// Every section fills the page, on a phone and an unfolded foldable.
child: runVisitSectionBody(
section: _section,
run: widget.run,
step: widget.step,
visitIndex: widget.visitIndex,
stageKey: widget.visit.stage,
runSteps: widget.runSteps,
gateway: widget.gateway,
onRunChanged: widget.onRunChanged,
configuredEndpoint: widget.configuredEndpoint,
cupertino: widget.cupertino,
facts: RunVisitFactsView(step: widget.step),
),
),
);
}
Widget _capped(Widget body) => switch (_section) {
RunVisitSection.artifacts || RunVisitSection.changes => body,
_ => ReadingWidth(child: body),
};
}
/// The page bar's subtitle for a recorded visit: its per-stage visit, then the run
-40
View File
@@ -1,40 +0,0 @@
import 'dart:math' as math;
import 'package:flutter/widgets.dart';
/// The widest a detail's reading body (a run or pipeline Summary, a stage
/// page's sections) grows on a wide window, so its text, trailing copy
/// buttons and facts stay within reach of the title instead of stretching
/// to the window's far edge.
const double kReadingMaxWidth = 840;
/// Caps [child] at [maxWidth] from the leading edge, where the detail's bar
/// pieces, header strip and tabs start. It passes the full height through
/// unchanged, so a scrollable child fills the height as before; only its
/// width is capped.
class ReadingWidth extends StatelessWidget {
const ReadingWidth({
super.key,
required this.child,
this.maxWidth = kReadingMaxWidth,
});
final Widget child;
final double maxWidth;
@override
Widget build(BuildContext context) => LayoutBuilder(
// One structure at every width, so resizing across the cap never
// remounts the body (its scroll offset and open sections stay).
builder: (context, constraints) {
return Align(
alignment: AlignmentDirectional.topStart,
child: SizedBox(
width: math.min(maxWidth, constraints.maxWidth),
height: constraints.hasBoundedHeight ? constraints.maxHeight : null,
child: child,
),
);
},
);
}
+116 -30
View File
@@ -1,28 +1,44 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
/// Colours for recorded outcome names, assigned per run by first appearance.
/// Colours for recorded outcome names within one run.
///
/// Outcome words are pipeline-defined ('approved', 'rejected', 'retry', …), so
/// no name is hard-wired to a colour: the same name always gets the same
/// colour within a run and two different names never share one. The first
/// [_hues] names use well-separated hues; later ones continue around the
/// colour wheel by the golden angle so they stay distinct.
/// Well-known outcome words get a colour family that matches their meaning —
/// success-like words are green, failures red, rejections orange, retries and
/// advisories amber, skips and cancellations grey — and every other word gets
/// a distinct hue outside those families, by first appearance. The same name
/// always gets the same colour, and two different names never share one: a
/// second word of the same family takes that family's next shade.
class OutcomePalette {
OutcomePalette(Iterable<String> outcomes) {
final familyUse = <_Family, int>{};
var other = 0;
for (final outcome in outcomes) {
final key = _key(outcome);
if (key.isNotEmpty) _index.putIfAbsent(key, () => _index.length);
if (key.isEmpty || _swatches.containsKey(key)) continue;
final family = _familyOf(key);
if (family != null) {
final used = familyUse[family] ?? 0;
final shades = _familyShades[family]!;
if (used < shades.length) {
familyUse[family] = used + 1;
_swatches[key] = _Swatch.material(shades[used]);
continue;
}
}
_swatches[key] = other < _otherHues.length
? _Swatch.material(_otherHues[other])
: _Swatch.wheel(other);
other += 1;
}
}
final Map<String, int> _index = {};
final Map<String, _Swatch> _swatches = {};
static String _key(String outcome) => outcome.trim().toLowerCase();
/// The position [outcome] was first seen at, or null for a blank or unseen
/// name.
int? indexOf(String outcome) => _index[_key(outcome)];
/// Whether [outcome] was seen (and so has a colour of its own).
bool contains(String outcome) => _swatches.containsKey(_key(outcome));
/// [outcome]'s colour for the host's brightness; an unseen or blank name
/// uses the host's secondary text colour.
@@ -32,37 +48,107 @@ class OutcomePalette {
final brightness = cupertino
? CupertinoTheme.brightnessOf(context)
: Theme.of(context).brightness;
final index = indexOf(outcome);
if (index == null) {
final swatch = _swatches[_key(outcome)];
if (swatch == null) {
return cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant;
}
return outcomeColorAt(index, brightness);
return swatch.resolve(brightness);
}
/// [outcome]'s colour on a page of [brightness], or null when unseen.
Color? colorForBrightness(String outcome, Brightness brightness) =>
_swatches[_key(outcome)]?.resolve(brightness);
}
const List<MaterialColor> _hues = [
enum _Family { success, failure, rejection, caution, neutral }
/// The meaning a well-known outcome word carries, if any.
_Family? _familyOf(String key) {
final word = key.replaceAll(RegExp(r'[\s-]+'), '_');
const success = {
'success',
'succeeded',
'ok',
'pass',
'passed',
'approved',
'accepted',
'done',
'completed',
'complete',
'merged',
'landed',
};
const failure = {'error', 'failure', 'failed', 'fail', 'crashed', 'broken'};
const rejection = {
'rejected',
'reject',
'blocked',
'denied',
'declined',
'changes_requested',
};
const caution = {
'retry',
'blocked_retryable',
'advisory',
'warning',
'needs_work',
'partial',
};
const neutral = {
'skipped',
'skip',
'canceled',
'cancelled',
'stopped',
'none',
};
if (success.contains(word)) return _Family.success;
if (failure.contains(word)) return _Family.failure;
if (rejection.contains(word)) return _Family.rejection;
if (caution.contains(word)) return _Family.caution;
if (neutral.contains(word)) return _Family.neutral;
return null;
}
/// Each family's shades, in the order successive distinct words take them.
const Map<_Family, List<MaterialColor>> _familyShades = {
_Family.success: [Colors.green, Colors.lightGreen, Colors.teal],
_Family.failure: [Colors.red, Colors.pink],
_Family.rejection: [Colors.deepOrange, Colors.orange],
_Family.caution: [Colors.amber, Colors.yellow],
_Family.neutral: [Colors.blueGrey, Colors.grey],
};
/// Hues for words with no family, chosen away from the family colours.
const List<MaterialColor> _otherHues = [
Colors.blue,
Colors.green,
Colors.deepOrange,
Colors.purple,
Colors.teal,
Colors.pink,
Colors.amber,
Colors.indigo,
Colors.brown,
Colors.cyan,
Colors.brown,
Colors.deepPurple,
Colors.lightBlue,
];
/// The colour for the [index]th distinct outcome, readable on the page in
/// [brightness] (darker shades on light pages, lighter on dark).
Color outcomeColorAt(int index, Brightness brightness) {
final dark = brightness == Brightness.dark;
if (index < _hues.length) {
final hue = _hues[index];
return dark ? hue.shade300 : hue.shade800;
class _Swatch {
const _Swatch.material(MaterialColor this.color) : wheelIndex = null;
const _Swatch.wheel(int this.wheelIndex) : color = null;
final MaterialColor? color;
final int? wheelIndex;
Color resolve(Brightness brightness) {
final dark = brightness == Brightness.dark;
final material = color;
if (material != null) return dark ? material.shade300 : material.shade800;
// Past the named hues, continue round the wheel by the golden angle,
// starting from a blue-violet so the next words stay clear of the
// families' greens, reds, oranges and ambers.
final degrees = (230 + wheelIndex! * 137.508) % 360;
return HSLColor.fromAHSL(1, degrees, 0.55, dark ? 0.72 : 0.35).toColor();
}
final degrees = (index * 137.508) % 360;
return HSLColor.fromAHSL(1, degrees, 0.6, dark ? 0.7 : 0.35).toColor();
}