android: colour every status from one palette
A successful stage read amber in the Timeline because a visit's chip was coloured from the graph's outcome palette (`graphColors`/`outcomeColor`) while every other surface used the run-status palette, so the same word meant two colours. This makes `RunStatusPalette` the single source of truth: - `RunState` gains the server's own `Waiting`/`Blocked`/`Skipped` words, each with a deliberate palette entry, a distinct material glyph and a label, so a status is never colour alone and success is green / failure red everywhere. - `graphColors()` takes success/error from `runStateColor(Succeeded/Failed)`; `outcomeColor()` returns the shared status colour for any word that resolves to a `RunState` and leaves `GraphPalette` only the graph-only flow outcomes (`rejected`/`exhausted`/`retry`/`approved`/`fast`/`missing`; `blocked`/ `skipped`/`done` removed). The Timeline's `TimelineRow` uses the same factory. - A visit's *outcome* stays distinct from the run's *status* by the chip's own label and the row's state glyph, never a second colour. - The runs-list failure diagnostic uses `runStateColor(Failed)` instead of a scheme role that could drift from the chip above it; the status filter gains `waiting`. Tests: new `StatusColorConsistencyTest` (timeline colour comes from the runs-list source; every state maps to exactly one colour) and extended `GraphPaletteTest`/ `RunStatusTest`. `gradle --offline --no-daemon :app:testDebugUnitTest --rerun-tasks` -> 516 tests, 0 failures, 0 errors, 0 skipped. Docs check: the root README and docs/ do not describe the Android status colours; the packaged templates and internal/author/skill/references cover the authoring surface and are unrelated, so nothing there needed updating. android/README.md did enumerate the run states and claimed the graph outcome palette was unchanged, so its features bullets were updated and a new "One status colour everywhere" section added, with the old bullet marked superseded. APK published to the run's artifacts as pipelines-debug-wip-d13f359.apk. (cherry picked from commit a3caa734cd4769f42883b518d877dd0132ef57ae)
This commit is contained in:
+56
-2
@@ -253,7 +253,12 @@ stops it.
|
||||
Nothing is removed, and the visit tabs still switch the selected visit.
|
||||
- Steps render as a timeline in run detail: a leading status glyph connected to
|
||||
the next step by an outcome-coloured line (kept aligned with the step title),
|
||||
the stage with its sequence and an outcome chip. A step's metadata is a set of
|
||||
the stage with its sequence and an outcome chip. A step's colour comes from the
|
||||
one status source, so a word that is a run state (`success`/`error`/`blocked`/
|
||||
`skipped`/`waiting`/…) is the same colour the runs list draws; only a graph-only
|
||||
flow outcome (`approved`, `retry`, …) keeps its curated graph colour. A visit's
|
||||
*outcome* is still distinguished from the run's *status* by the chip's own label
|
||||
and the row's state glyph, never by a second colour. A step's metadata is a set of
|
||||
aligned label/value rows (`KeyValueRow`) — paired side by side in two columns on
|
||||
a wide window and stacked in one column on a narrow one — with a single
|
||||
consistent vertical rhythm (one bottom gap per step, no doubled gap when a step
|
||||
@@ -267,7 +272,8 @@ stops it.
|
||||
via `formatDuration`, and colour-coded succeeded/failed/canceled/interrupted/
|
||||
active counts). Each card shows the pipeline name with a version chip, a
|
||||
colour-coded status chip with a distinct icon per state
|
||||
(running/queued/succeeded/failed/canceled/interrupted/active/unknown), a meta
|
||||
(running/waiting/queued/succeeded/failed/canceled/interrupted/active/unknown),
|
||||
a meta
|
||||
row (run id, start time, duration) and the diagnostic only when non-blank,
|
||||
clamped to two lines. The raw `resultPreview` is no longer printed, and
|
||||
progress is shown honestly (completed visits + current stage, with an
|
||||
@@ -2703,6 +2709,10 @@ command targeted `emulator-5556`; lane A's `emulator-5554` was not used).
|
||||
call the shared `graphColors(scheme)` factory (extracted from `WorkflowGraph`,
|
||||
which uses it too) and `outcomeColor`, so a step chip agrees with the graph.
|
||||
The run header and runs-list cards keep the run-status palette.
|
||||
*(Superseded 17 Oct 2026: the graph's terminal roles and the Timeline chip now
|
||||
also take the one run-status colour, so "the graph outcome palette is unchanged"
|
||||
no longer holds — see "One status colour everywhere" below. `RunStatusPalette`
|
||||
stays the single status source.)*
|
||||
- **Shared helper.** `ui/components/RunStatus.kt` gained `ColoredChip(label,
|
||||
colour, icon, …)` — the single pill layout now used by both `StatusChip` (run
|
||||
status) and the Timeline's outcome chip, instead of a second copy.
|
||||
@@ -2785,6 +2795,50 @@ tree (JDK 17 from Homebrew `openjdk@17`, Gradle 8.11.1, `--offline`):
|
||||
`HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
|
||||
`Content-Length: 18009527`, and a streamed `GET | shasum -a 256` matched.
|
||||
|
||||
## One status colour everywhere (17 Oct 2026)
|
||||
|
||||
A successful stage in the Timeline read amber, because a visit's chip was coloured
|
||||
from the graph's outcome palette while every other surface used the run-status
|
||||
palette, so the same word meant two colours. `android/` only; nothing in the
|
||||
Pipelines server, its Go source, the Docker/compose files or the installer was
|
||||
touched, no dependency was added beyond the already-declared
|
||||
`material-icons-extended`, and no run was started from the app.
|
||||
|
||||
- **One source of truth.** `ui/components/RunStatusPalette.kt`, with `RunState` /
|
||||
`runStateOf` / `runStateColor` / `runStateIcon` in `ui/components/RunStatus.kt`,
|
||||
owns a status colour. `RunState` gained the server's own `Waiting`/`Blocked`/
|
||||
`Skipped` words (`waiting` corroborated by `internal/tui/run_progress.go`), each
|
||||
with a deliberate palette entry, a distinct material glyph
|
||||
(`HourglassEmpty`/`Block`/`SkipNext`) and a label, so status is never colour
|
||||
alone.
|
||||
- **The graph and timeline route through it.** `graphColors(scheme)` sets
|
||||
`success`/`error` from `runStateColor(Succeeded/Failed)`, and `outcomeColor`
|
||||
returns the shared status colour for any word that resolves to a `RunState`,
|
||||
falling back to `GraphPalette` only for the graph-only flow outcomes
|
||||
(`rejected`, `exhausted`, `retry`, `approved`, `fast`, `missing`; `blocked`/
|
||||
`skipped`/`done` were removed from the graph palette). The Timeline's
|
||||
`TimelineRow` uses the same factory, so a successful visit is green and a failure
|
||||
red. A visit's *outcome* stays distinct from the run's *status* by the chip's own
|
||||
label and the row's state glyph, never a second colour. The runs list's failure
|
||||
diagnostic uses `runStateColor(Failed)` rather than a scheme role that could
|
||||
drift from the chip above it, and the list's status filter gained `waiting`.
|
||||
- **Tests.** `GraphPaletteTest` asserts every status word's graph colour equals the
|
||||
runs-list colour and that the graph-only outcomes stay distinct and borrow no
|
||||
status colour; `ui/graph/StatusColorConsistencyTest` asserts the timeline maps
|
||||
through the same source and that every state maps to exactly one colour, the one
|
||||
deliberate alias being Running/Active.
|
||||
|
||||
Evidence obtained on this tree (macOS, JDK 17 from Homebrew `openjdk@17`, Gradle
|
||||
8.11.1, `ANDROID_HOME=/Users/alan/Library/Android/sdk`, `--offline`,
|
||||
`--no-daemon`):
|
||||
|
||||
- `gradle :app:testDebugUnitTest --rerun-tasks` → **516 tests, 0 failures, 0
|
||||
errors, 0 skipped** (including the new `StatusColorConsistencyTest`, 2 cases, and
|
||||
the extended `GraphPaletteTest`, 12 cases, and `RunStatusTest`, 3 cases).
|
||||
- **APK publish.** The run's debug APK is
|
||||
`…/artifacts/282/1/pipelines-debug-wip-d13f359.apk` (18,486,624 bytes, sha256
|
||||
`b11481889b2894efb5fb6b17bcb62af819fe4b6ffb0196f5e27834b4736a5e1c`).
|
||||
|
||||
## Last-run facts on every pipeline row (16 Oct 2026)
|
||||
|
||||
`android/` only. No server field was added: the whole run history already arrives
|
||||
|
||||
@@ -4,17 +4,20 @@ import androidx.compose.ui.graphics.Color
|
||||
import net.awan.pipelines.ui.theme.DarkError
|
||||
|
||||
/**
|
||||
* The app-owned run-status palette.
|
||||
* The app-owned status palette, the single source of truth for the colour of a
|
||||
* status or stage-outcome word.
|
||||
*
|
||||
* Run status is a *different vocabulary* from the graph's stage outcomes
|
||||
* ([net.awan.pipelines.ui.graph.GraphPalette]): a run that is `running` is not a
|
||||
* `skipped` stage, and a `succeeded` run is not the amber the theme uses for a
|
||||
* positive *stage* outcome. Borrowing Material roles therefore put the wrong hue
|
||||
* on the two states that matter most — `primary` (mint) made a *running* run read
|
||||
* green and `tertiary` (amber) made a *succeeded* run read yellow.
|
||||
* Borrowing Material roles put the wrong hue on the two states that matter most —
|
||||
* `primary` (mint) made a *running* run read green and `tertiary` (amber) made a
|
||||
* *succeeded* run read yellow — so every entry below is a deliberate, fixed
|
||||
* colour with an explicit meaning. The stage outcomes that share a word with a
|
||||
* run state (`success`/`done`→[Succeeded], `error`→[Failed], `blocked`,
|
||||
* `skipped`, `waiting`) resolve here too, through [runStateOf], so the timeline,
|
||||
* the graph, the runs list, the stage sheet and the peek all draw one word in one
|
||||
* colour. Only genuinely graph-only flow outcomes (`approved`, `retry`, …) keep
|
||||
* their own curated colour in [net.awan.pipelines.ui.graph.GraphPalette].
|
||||
*
|
||||
* Every entry below is instead a deliberate, fixed colour with an explicit
|
||||
* meaning, tuned for the dark Pipelines surface (`DarkSurface 0xFF0E1513`,
|
||||
* Every entry is tuned for the dark Pipelines surface (`DarkSurface 0xFF0E1513`,
|
||||
* over which the chip label is drawn). The contrast of each colour against that
|
||||
* surface is *measured* by `RunStatusPaletteTest`, never judged by eye. Status is
|
||||
* never colour-only: every entry keeps its own material glyph ([runStateIcon])
|
||||
@@ -29,6 +32,13 @@ internal object RunStatusPalette {
|
||||
private val Running =
|
||||
Entry(Color(0xFF7FB2F0), "blue: in progress; green would read as already finished")
|
||||
|
||||
/**
|
||||
* Waiting for a person (a human decision): a distinct cyan, matching the TUI's
|
||||
* accent for a paused run, so it is neither the running blue nor a failure.
|
||||
*/
|
||||
private val Waiting =
|
||||
Entry(Color(0xFF8EDFF5), "cyan: paused for a person; distinct from running and from failure")
|
||||
|
||||
/** Finished well: the conventional green. Amber/tertiary would read as a warning. */
|
||||
private val Succeeded =
|
||||
Entry(Color(0xFF7FE0A8), "green: completed successfully; amber would read as a warning")
|
||||
@@ -55,6 +65,13 @@ internal object RunStatusPalette {
|
||||
*/
|
||||
private val Waiting =
|
||||
Entry(Color(0xFFC0A3F5), "violet: parked for the operator's decision; not running, not a stop")
|
||||
/** Blocked: a stage that could not proceed — a warm amber/orange, never failure red. */
|
||||
private val Blocked =
|
||||
Entry(Color(0xFFF0A35E), "orange: a blocked stage could not proceed; not the failure red")
|
||||
|
||||
/** Skipped: a stage deliberately not run — a cool muted grey-blue, quiet and distinct. */
|
||||
private val Skipped =
|
||||
Entry(Color(0xFFA8B8C8), "muted grey-blue: a stage deliberately not run; quiet, not a status")
|
||||
|
||||
/** Unknown/blank status: the safe, low-key fallback. */
|
||||
private val Unknown =
|
||||
@@ -67,12 +84,15 @@ internal object RunStatusPalette {
|
||||
*/
|
||||
fun of(state: RunState): Entry = when (state) {
|
||||
RunState.Running, RunState.Active -> Running
|
||||
RunState.Waiting -> Waiting
|
||||
RunState.Succeeded -> Succeeded
|
||||
RunState.Failed -> Failed
|
||||
RunState.Interrupted -> Interrupted
|
||||
RunState.Canceled -> Canceled
|
||||
RunState.Queued -> Queued
|
||||
RunState.Waiting -> Waiting
|
||||
RunState.Blocked -> Blocked
|
||||
RunState.Skipped -> Skipped
|
||||
RunState.Unknown -> Unknown
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,15 @@ import kotlin.math.min
|
||||
import kotlin.math.pow
|
||||
|
||||
/**
|
||||
* The curated graph colour palette.
|
||||
* The curated palette for the graph-only flow outcomes.
|
||||
*
|
||||
* Every distinct outcome gets its own deliberate entry (no `hashCode() % 4`
|
||||
* A stage outcome that is also a run state (`success`/`done`/`error`/`blocked`/
|
||||
* `skipped`/`waiting`) is coloured from the one owned status palette
|
||||
* ([net.awan.pipelines.ui.components.RunStatusPalette], through [outcomeColor]),
|
||||
* so the graph, the timeline and the runs list never disagree. This palette
|
||||
* covers only the words with no status meaning — the loop/choice outcomes a
|
||||
* pipeline defines (`rejected`, `exhausted`, `retry`, `approved`, `fast`,
|
||||
* `missing`) — giving each its own deliberate entry (no `hashCode() % 4`
|
||||
* collisions): the mapping is pure and deterministic, so a given outcome name is
|
||||
* the same colour across runs and recompositions, and an unknown/new name gets a
|
||||
* stable reserved fallback colour instead of silently borrowing a known one.
|
||||
@@ -19,46 +25,35 @@ import kotlin.math.pow
|
||||
* over which the outcome label is drawn on a ~0.92-alpha chip). Every entry is
|
||||
* bright enough to be legible both as a 3px edge stroke and as the small 11sp
|
||||
* label text: contrast is *measured* by [GraphPaletteTest], not asserted by eye.
|
||||
*
|
||||
* The two terminal outcomes stay theme roles in [GraphColors] (`error`→error,
|
||||
* `success`→tertiary) so their meaning is preserved; everything else uses
|
||||
* [colors].
|
||||
*/
|
||||
internal object GraphPalette {
|
||||
|
||||
/**
|
||||
* The fixed palette. Deliberately fixed (rather than scheme-derived) so an
|
||||
* outcome is the same colour on every device; the two terminal roles above
|
||||
* remain scheme roles.
|
||||
* outcome is the same colour on every device.
|
||||
*/
|
||||
val colors: List<Color> = listOf(
|
||||
Color(0xFF8FE0A0), // 0 blocked - green
|
||||
Color(0xFFF5A3A3), // 1 rejected - red
|
||||
Color(0xFF8FB4F5), // 2 skipped - blue
|
||||
Color(0xFFF5B37A), // 3 exhausted - orange
|
||||
Color(0xFF7FD4E8), // 4 retry - cyan
|
||||
Color(0xFFC0A3F5), // 5 approved - violet
|
||||
Color(0xFFF0E07A), // 6 fast - yellow
|
||||
Color(0xFFF5A3D0), // 7 missing - pink
|
||||
Color(0xFFD6B08C), // 8 done - sand
|
||||
Color(0xFFF5A3A3), // 0 rejected - red
|
||||
Color(0xFFF5B37A), // 1 exhausted - orange
|
||||
Color(0xFF7FD4E8), // 2 retry - cyan
|
||||
Color(0xFFC0A3F5), // 3 approved - violet
|
||||
Color(0xFFF0E07A), // 4 fast - yellow
|
||||
Color(0xFFF5A3D0), // 5 missing - pink
|
||||
// Reserved fallback region for names not in [KNOWN], kept distinct from
|
||||
// the known entries so an unknown outcome never borrows a known colour.
|
||||
Color(0xFFD8C98A), // 9 fallback - khaki
|
||||
Color(0xFF9FD8C0), // 10 fallback - sea
|
||||
Color(0xFFD8A8C0), // 11 fallback - dusty rose
|
||||
Color(0xFFD8C98A), // 6 fallback - khaki
|
||||
Color(0xFF9FD8C0), // 7 fallback - sea
|
||||
Color(0xFFD8A8C0), // 8 fallback - dusty rose
|
||||
)
|
||||
|
||||
/** The known outcome names and their fixed palette index, in display order. */
|
||||
/** The known graph-only outcome names and their fixed palette index, in display order. */
|
||||
private val KNOWN: Map<String, Int> = linkedMapOf(
|
||||
"blocked" to 0,
|
||||
"rejected" to 1,
|
||||
"skipped" to 2,
|
||||
"exhausted" to 3,
|
||||
"retry" to 4,
|
||||
"approved" to 5,
|
||||
"fast" to 6,
|
||||
"missing" to 7,
|
||||
"done" to 8,
|
||||
"rejected" to 0,
|
||||
"exhausted" to 1,
|
||||
"retry" to 2,
|
||||
"approved" to 3,
|
||||
"fast" to 4,
|
||||
"missing" to 5,
|
||||
)
|
||||
|
||||
/** First palette index reserved for names that are not in [KNOWN]. */
|
||||
@@ -67,8 +62,9 @@ internal object GraphPalette {
|
||||
/**
|
||||
* The palette index for [outcome]. Pure and deterministic for every input
|
||||
* (including blank): known names get their curated slot, everything else a
|
||||
* stable slot inside the reserved fallback region. `success`/`error` resolve
|
||||
* to the theme roles in [outcomeColor] but still return a stable index here.
|
||||
* stable slot inside the reserved fallback region. A word that resolves to a
|
||||
* run state is coloured from the status palette by [outcomeColor] and does not
|
||||
* reach this palette.
|
||||
*/
|
||||
fun outcomeColorIndex(outcome: String): Int {
|
||||
KNOWN[outcome]?.let { return it }
|
||||
|
||||
@@ -85,8 +85,11 @@ import net.awan.pipelines.data.protocol.GraphSemantics
|
||||
import net.awan.pipelines.data.protocol.Protocol
|
||||
import net.awan.pipelines.data.protocol.RunGraphState
|
||||
import net.awan.pipelines.data.protocol.edges
|
||||
import net.awan.pipelines.ui.components.RunState
|
||||
import net.awan.pipelines.ui.components.hostResumed
|
||||
import net.awan.pipelines.ui.components.rememberLiveNowMillis
|
||||
import net.awan.pipelines.ui.components.runStateColor
|
||||
import net.awan.pipelines.ui.components.runStateOf
|
||||
import net.awan.pipelines.ui.formatDuration
|
||||
import net.awan.pipelines.ui.secondsSince
|
||||
import net.awan.pipelines.ui.theme.GRAPH_ACTIVE_HALO_GAP
|
||||
@@ -534,44 +537,51 @@ internal class GraphColors(
|
||||
/**
|
||||
* The graph's colours for [scheme], built in one place so every surface that must
|
||||
* agree with the graph (the graph itself and the timeline's step-outcome chips)
|
||||
* uses the same palette. The two terminal roles stay scheme roles so their
|
||||
* meaning is kept; every other outcome uses the one curated, legible
|
||||
* [GraphPalette] for both a stroke and its label text.
|
||||
* uses the same palette. The two terminal roles take the one owned run-status
|
||||
* colour (success green, failure red) so they can never disagree with the runs
|
||||
* list; every other status word is coloured by the status palette in
|
||||
* [outcomeColor], and the remaining graph-only flow outcomes use the one curated,
|
||||
* legible [GraphPalette] for both a stroke and its label text.
|
||||
*
|
||||
* Node and label surfaces are *tonal*: a raised surface tone ([scheme]'s
|
||||
* `surfaceContainerHigh`/`surfaceContainerHighest`) blended with a subtle tint of
|
||||
* the node's semantic colour (see [tonalFill]) rather than a flat fill, so a node
|
||||
* reads as raised card, not a terminal cell.
|
||||
*/
|
||||
internal fun graphColors(scheme: ColorScheme): GraphColors = GraphColors(
|
||||
// The two terminal roles stay scheme roles so their meaning is kept.
|
||||
success = scheme.tertiary,
|
||||
error = scheme.error,
|
||||
// Every other outcome uses the one curated, legible palette for both its
|
||||
// stroke and its label text, so a curve and its label always agree.
|
||||
palette = GraphPalette.colors,
|
||||
// Node fills differ by kind (see [GraphNodeKind]): model (neutral), ntfy
|
||||
// (amber), other/custom (green), and the two terminals (success/error). Each
|
||||
// is a tonal surface carrying a subtle tint of that kind's semantic hue.
|
||||
nodeFill = tonalFill(scheme.surfaceContainerHigh, scheme.onSurfaceVariant, NEUTRAL_TINT),
|
||||
nodeNtfyFill = tonalFill(scheme.surfaceContainerHigh, scheme.tertiary, KIND_TINT),
|
||||
nodeCustomFill = tonalFill(scheme.surfaceContainerHigh, scheme.primary, KIND_TINT),
|
||||
// A selected node inverts (light fill / dark text) plus a stronger border, so
|
||||
// selection reads in either appearance and never relies on colour.
|
||||
nodeFillActive = scheme.inverseSurface,
|
||||
nodeTextActive = scheme.inverseOnSurface,
|
||||
// The stage border is deliberately soft (a low-contrast outline variant), not
|
||||
// the hard original outline; terminals carry their outcome hue instead.
|
||||
nodeBorder = scheme.outlineVariant,
|
||||
nodeBorderActive = scheme.primary,
|
||||
nodeText = scheme.onSurface,
|
||||
terminalFill = tonalFill(scheme.surfaceContainerHigh, scheme.tertiary, TERMINAL_TINT),
|
||||
terminalErrorFill = tonalFill(scheme.surfaceContainerHigh, scheme.error, TERMINAL_TINT),
|
||||
// Edge outcome labels sit on a tonal chip (drawn as a rounded rect) rather than
|
||||
// raw text over the canvas.
|
||||
labelBackground = scheme.surfaceContainerHighest,
|
||||
labelText = scheme.onSurfaceVariant,
|
||||
)
|
||||
internal fun graphColors(scheme: ColorScheme): GraphColors {
|
||||
// The two terminal outcomes take the shared run-status colours so the graph
|
||||
// and the runs list can never disagree about success/failure.
|
||||
val success = runStateColor(RunState.Succeeded)
|
||||
val error = runStateColor(RunState.Failed)
|
||||
return GraphColors(
|
||||
success = success,
|
||||
error = error,
|
||||
// Every other graph-only outcome uses the one curated, legible palette for
|
||||
// both its stroke and its label text, so a curve and its label always agree.
|
||||
palette = GraphPalette.colors,
|
||||
// Node fills differ by kind (see [GraphNodeKind]): model (neutral), ntfy
|
||||
// (amber), other/custom (green), and the two terminals (success/error). Each
|
||||
// is a tonal surface carrying a subtle tint of that kind's semantic hue.
|
||||
nodeFill = tonalFill(scheme.surfaceContainerHigh, scheme.onSurfaceVariant, NEUTRAL_TINT),
|
||||
nodeNtfyFill = tonalFill(scheme.surfaceContainerHigh, scheme.tertiary, KIND_TINT),
|
||||
nodeCustomFill = tonalFill(scheme.surfaceContainerHigh, scheme.primary, KIND_TINT),
|
||||
// A selected node inverts (light fill / dark text) plus a stronger border, so
|
||||
// selection reads in either appearance and never relies on colour.
|
||||
nodeFillActive = scheme.inverseSurface,
|
||||
nodeTextActive = scheme.inverseOnSurface,
|
||||
// The stage border is deliberately soft (a low-contrast outline variant), not
|
||||
// the hard original outline; terminals carry their outcome hue instead.
|
||||
nodeBorder = scheme.outlineVariant,
|
||||
nodeBorderActive = scheme.primary,
|
||||
nodeText = scheme.onSurface,
|
||||
terminalFill = tonalFill(scheme.surfaceContainerHigh, success, TERMINAL_TINT),
|
||||
terminalErrorFill = tonalFill(scheme.surfaceContainerHigh, error, TERMINAL_TINT),
|
||||
// Edge outcome labels sit on a tonal chip (drawn as a rounded rect) rather than
|
||||
// raw text over the canvas.
|
||||
labelBackground = scheme.surfaceContainerHighest,
|
||||
labelText = scheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* [surface] blended with a [fraction] (0..1) of [accent], so a node/label fill
|
||||
@@ -1602,17 +1612,19 @@ private fun DrawScope.drawActiveHalo(
|
||||
}
|
||||
|
||||
/**
|
||||
* The colour for an outcome: the theme error role for `error`, a clearly
|
||||
* positive theme colour for `success`, and the curated [GraphPalette] entry for
|
||||
* everything else. One colour is used for both the edge stroke and its label
|
||||
* text (the palette is legible on the surface), so a curve and its label always
|
||||
* agree. `success`/`error` are the terminal roles and are never colour-only
|
||||
* signals (their labels name them). Pure and deterministic.
|
||||
* The colour for an outcome or stage status, from the one owned source: a word
|
||||
* that is a run state (`success`/`done`/`error`/`blocked`/`skipped`/`waiting`/
|
||||
* `running`/…) takes the shared status colour the operator already learned from
|
||||
* the runs list, so the same word is the same colour in the timeline, the graph,
|
||||
* the stage sheet and the peek; a graph-only flow outcome (`approved`, `retry`, …)
|
||||
* takes its curated [GraphPalette] entry. One colour serves both the edge stroke
|
||||
* and its label text (the palette is legible on the surface), so a curve and its
|
||||
* label always agree. Pure and deterministic.
|
||||
*/
|
||||
internal fun outcomeColor(outcome: String, colors: GraphColors): Color = when (outcome) {
|
||||
"error" -> colors.error
|
||||
"success" -> colors.success
|
||||
else -> colors.palette[GraphPalette.outcomeColorIndex(outcome)]
|
||||
internal fun outcomeColor(outcome: String, colors: GraphColors): Color {
|
||||
val state = runStateOf(outcome)
|
||||
if (state != RunState.Unknown) return runStateColor(state)
|
||||
return colors.palette[GraphPalette.outcomeColorIndex(outcome)]
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,13 +46,15 @@ enum class RunPresence(val label: String, val storageKey: String) {
|
||||
|
||||
/**
|
||||
* The statuses a run filter can select. The server's own run vocabulary
|
||||
* (internal/pipeline/runs.go: queued/running/succeeded/failed/canceled/
|
||||
* interrupted); the app-only `active` usage bucket and the `unknown` fallback
|
||||
* are deliberately not offered, so a status filter always names a real state.
|
||||
* (internal/pipeline/runs.go: queued/running/waiting/succeeded/failed/canceled/
|
||||
* interrupted); the app-only `active` usage bucket, the stage-outcome words
|
||||
* (`blocked`/`skipped`) and the `unknown` fallback are deliberately not offered,
|
||||
* so a status filter always names a real run state.
|
||||
*/
|
||||
internal val RUN_STATUS_FILTERS: List<RunState> = listOf(
|
||||
RunState.Queued,
|
||||
RunState.Running,
|
||||
RunState.Waiting,
|
||||
RunState.Succeeded,
|
||||
RunState.Failed,
|
||||
RunState.Canceled,
|
||||
|
||||
@@ -585,8 +585,10 @@ private fun RunRow(
|
||||
Text(
|
||||
run.diagnostic,
|
||||
style = text.meta,
|
||||
// The one status colour for a failure, never a scheme role that
|
||||
// could drift from the chip above it.
|
||||
color = if (state == RunState.Failed) {
|
||||
MaterialTheme.colorScheme.error
|
||||
runStateColor(RunState.Failed)
|
||||
} else {
|
||||
MaterialTheme.colorScheme.onSurfaceVariant
|
||||
},
|
||||
|
||||
@@ -11,14 +11,18 @@ class RunStatusTest {
|
||||
assertEquals(RunState.Queued, runStateOf("queued"))
|
||||
assertEquals(RunState.Waiting, runStateOf("waiting"))
|
||||
assertEquals(RunState.Active, runStateOf("active"))
|
||||
assertEquals(RunState.Waiting, runStateOf("waiting"))
|
||||
assertEquals(RunState.Succeeded, runStateOf("succeeded"))
|
||||
// Step/outcome words map onto the same states.
|
||||
// Step/outcome words map onto the same states, so one word is one colour.
|
||||
assertEquals(RunState.Succeeded, runStateOf("completed"))
|
||||
assertEquals(RunState.Succeeded, runStateOf("success"))
|
||||
assertEquals(RunState.Succeeded, runStateOf("done"))
|
||||
assertEquals(RunState.Failed, runStateOf("failed"))
|
||||
assertEquals(RunState.Failed, runStateOf("error"))
|
||||
assertEquals(RunState.Canceled, runStateOf("canceled"))
|
||||
assertEquals(RunState.Interrupted, runStateOf("interrupted"))
|
||||
assertEquals(RunState.Blocked, runStateOf("blocked"))
|
||||
assertEquals(RunState.Skipped, runStateOf("skipped"))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -5,6 +5,9 @@ import net.awan.pipelines.data.protocol.GraphEdge
|
||||
import net.awan.pipelines.data.protocol.GraphRoute
|
||||
import net.awan.pipelines.data.protocol.Protocol
|
||||
import net.awan.pipelines.data.protocol.RunGraphState
|
||||
import net.awan.pipelines.ui.components.RunState
|
||||
import net.awan.pipelines.ui.components.runStateColor
|
||||
import net.awan.pipelines.ui.components.runStateOf
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
@@ -15,9 +18,9 @@ class GraphPaletteTest {
|
||||
/** The dark Pipelines surface the outcome label chip is drawn on. */
|
||||
private val darkSurface = Color(0xFF0E1513)
|
||||
|
||||
/** The two terminal roles as the dark scheme supplies them. */
|
||||
private val successRole = Color(0xFFF2C879)
|
||||
private val errorRole = Color(0xFFFFB4AB)
|
||||
/** The two terminal roles are the shared run-status colours. */
|
||||
private val successRole = runStateColor(RunState.Succeeded)
|
||||
private val errorRole = runStateColor(RunState.Failed)
|
||||
|
||||
private fun colors() = GraphColors(
|
||||
success = successRole,
|
||||
@@ -43,11 +46,39 @@ class GraphPaletteTest {
|
||||
"exhausted", "retry", "approved", "fast", "missing", "done",
|
||||
)
|
||||
|
||||
/** The outcomes with no run-status meaning that the graph palette owns. */
|
||||
private val graphOnlyOutcomes = listOf(
|
||||
"rejected", "exhausted", "retry", "approved", "fast", "missing",
|
||||
)
|
||||
|
||||
/**
|
||||
* A word that is a run state resolves to exactly the colour the runs list
|
||||
* draws for it: the graph factory and [outcomeColor] share one source.
|
||||
*/
|
||||
@Test
|
||||
fun everyRealisticOutcomeGetsADistinctColour() {
|
||||
fun statusOutcomesTakeTheSharedRunStatusColour() {
|
||||
val colors = colors()
|
||||
val mapped = realisticOutcomes.map { outcomeColor(it, colors) }
|
||||
assertEquals(realisticOutcomes.size, mapped.toSet().size)
|
||||
listOf(
|
||||
"success", "completed", "done", "error", "failed",
|
||||
"blocked", "skipped", "waiting", "running", "queued",
|
||||
"canceled", "interrupted",
|
||||
).forEach { word ->
|
||||
assertEquals(
|
||||
"outcomeColor($word) must equal the runs-list colour",
|
||||
runStateColor(runStateOf(word)),
|
||||
outcomeColor(word, colors),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** The graph-only outcomes keep distinct curated colours, none a status colour. */
|
||||
@Test
|
||||
fun graphOnlyOutcomesGetDistinctColours() {
|
||||
val colors = colors()
|
||||
val mapped = graphOnlyOutcomes.map { outcomeColor(it, colors) }
|
||||
assertEquals(graphOnlyOutcomes.size, mapped.toSet().size)
|
||||
val statusColours = RunState.entries.map { runStateColor(it) }.toSet()
|
||||
mapped.forEach { assertFalse("$it borrowed a run-status colour", it in statusColours) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -74,10 +105,8 @@ class GraphPaletteTest {
|
||||
assertEquals(unknown, outcomeColor("something-brand-new", colors))
|
||||
// A blank name is just another unknown: stable and non-throwing.
|
||||
assertEquals(outcomeColor("", colors), outcomeColor("", colors))
|
||||
// The fallback comes from the reserved region, not a known outcome slot.
|
||||
val knownIndices = realisticOutcomes
|
||||
.filter { it != "success" && it != "error" }
|
||||
.map { GraphPalette.outcomeColorIndex(it) }
|
||||
// The fallback comes from the reserved region, not a known graph-only slot.
|
||||
val knownIndices = graphOnlyOutcomes.map { GraphPalette.outcomeColorIndex(it) }
|
||||
assertFalse(GraphPalette.outcomeColorIndex("something-brand-new") in knownIndices)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package net.awan.pipelines.ui.graph
|
||||
|
||||
import net.awan.pipelines.ui.components.RunState
|
||||
import net.awan.pipelines.ui.components.runStateColor
|
||||
import net.awan.pipelines.ui.components.runStateOf
|
||||
import net.awan.pipelines.ui.theme.PipelinesDarkColors
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
/**
|
||||
* The one-colour contract behind the status brief: whatever draws a status or a
|
||||
* stage outcome — the runs list, the timeline's step chips, the graph, the stage
|
||||
* sheet — resolves a word through one owned source, so a word means one colour
|
||||
* everywhere and never a second colour for the same meaning.
|
||||
*/
|
||||
class StatusColorConsistencyTest {
|
||||
|
||||
private val colors = graphColors(PipelinesDarkColors)
|
||||
|
||||
/**
|
||||
* Every word the timeline can show that is a run state resolves, through the
|
||||
* graph factory the timeline uses, to exactly the runs-list colour.
|
||||
*/
|
||||
@Test
|
||||
fun theTimelineColourComesFromTheRunsListSource() {
|
||||
listOf(
|
||||
"success", "completed", "done", "error", "failed",
|
||||
"blocked", "skipped", "waiting", "running", "queued",
|
||||
"canceled", "cancelled", "interrupted", "active",
|
||||
).forEach { word ->
|
||||
assertEquals(
|
||||
"timeline colour for '$word' must be the runs-list colour",
|
||||
runStateColor(runStateOf(word)),
|
||||
outcomeColor(word, colors),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Every state maps to exactly one colour: the lookup is deterministic, and no
|
||||
* two states collide except the one deliberate alias (a live run and the
|
||||
* server's `active` usage bucket are the same in-progress state).
|
||||
*/
|
||||
@Test
|
||||
fun everyStateMapsToExactlyOneColour() {
|
||||
RunState.entries.forEach { state ->
|
||||
assertEquals(runStateColor(state), runStateColor(state))
|
||||
}
|
||||
val shared = RunState.entries
|
||||
.groupBy { runStateColor(it) }
|
||||
.filterValues { it.size > 1 }
|
||||
.values
|
||||
.map { it.toSet() }
|
||||
.toSet()
|
||||
assertEquals(setOf(setOf(RunState.Running, RunState.Active)), shared)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user