Give run status an app-owned palette with correct hues

Run status was mapped onto Material roles, so a succeeded run read amber
(tertiary) and a running run read mint (primary). Replace that mapping with an
app-owned RunStatusPalette: Running/Active blue, Succeeded green, Failed the app
error red, Interrupted amber, Canceled muted grey, Queued neutral grey and
Unknown a low-key surface grey, each with a one-line rationale. runStateColor is
now a pure lookup over the palette.

Keep each state's distinct material glyph and text label so status is never
colour-only, and add a WCAG-AA contrast test for every status colour against the
dark surface plus hue-specific assertions.

Leave the graph's stage-outcome palette untouched. The timeline's step chips are
a stage outcome, not a run status, so point them at the shared graphColors/
outcomeColor factory (extracted from WorkflowGraph) to agree with the graph, and
factor the shared ColoredChip pill out of StatusChip so neither repeats the
layout. Document the change and its evidence in android/README.md.
This commit is contained in:
2026-10-16 02:04:30 +01:00
parent cd85f6954b
commit 24584d820f
6 changed files with 305 additions and 42 deletions
+78
View File
@@ -1268,3 +1268,81 @@ has exactly three pane levels (`MasterPane.List/Detail/Stage`, `MAX_PANE_DEPTH =
`SlidingPaneStackTest` cases instead; a long covered detail title wraps to three
centred lines and ellipsizes (e.g. `Pipelines maintenance - plan implem…`) rather
than being rotated.
## An app-owned run-status palette (16 Oct 2026)
Run status had the wrong hue for its two most important states because it was
mapped onto Material roles: `primary` (mint) made a **running** run read green and
`tertiary` (amber) made a **succeeded** run read yellow. `android/` only; nothing
in the Pipelines server, its Go source, the Docker/compose files or the installer
was touched, no dependency was added, no run was started from the app, and the
attached Pixel 10 Pro Fold was never installed on or driven (every `adb`/emulator
command targeted `emulator-5556`; lane A's `emulator-5554` was not used).
- **A new app-owned palette.** `ui/components/RunStatusPalette.kt` defines one
`Entry(colour, rationale)` per status, fixed (not scheme-derived) so a status
reads the same on every device, with a one-line reason each: Running/Active
blue, Succeeded green, Failed the app error red, Interrupted amber, Canceled
muted grey, Queued neutral grey, Unknown the low-key surface grey.
`runStateColor` is now a pure function over this palette (no `MaterialTheme`), so
it is asserted in a plain JVM test. Each state keeps its distinct material glyph
and text label, so status is never colour alone.
- **The graph outcome palette is unchanged.** `GraphPalette` and the terminal
`success`/`error` roles are untouched; run status and stage outcome stay
different vocabularies. The runs-list **Timeline** step chips (and their leading
glyphs) previously rendered through `runStateOf`/`StatusChip`, i.e. the run-status
mapping, so they were pointed at the graph's outcome palette instead: they now
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.
- **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.
Evidence (macOS, JDK 17 from Homebrew `openjdk@17`, Gradle 8.11.1,
`ANDROID_HOME=/Users/alan/Library/Android/sdk`, `ANDROID_SDK_ROOT` set,
`--offline`):
- `gradle :app:testDebugUnitTest` reported **143 tests, 0 failures, 0 errors**
(new `RunStatusPaletteTest`: WCAG-AA contrast ≥ 4.5:1 for every status colour
against `DarkSurface 0xFF0E1513`, Succeeded green and ≠ `DarkTertiary`, Running/
Active blue and ≠ `DarkPrimary`, Failed = `DarkError`, Interrupted amber and ≠
Failed, Queued near-grey and ≠ Running, and a non-blank rationale per status).
`gradle :app:assembleDebug` succeeded (18,009,527-byte debug APK, sha256
`17f52f23e40f4ba0c524ac2929adfd6a8f39353e68ccdeedb2e029019225e350`).
- On `emulator-5556` (`FoldB_API_36`, 2208x1840, density 420) in dark mode
(`adb shell cmd uimode night yes`) against the live server
`ws://10.0.2.2:8080/connect`, driven with `adb shell input` and `uiautomator
dump`. Every capture below was written with `android/scripts/capture_png.sh -s
emulator-5556` (which names the SurfaceFlinger display id and validates the PNG
magic bytes), and a validated screenshot was pixel-sampled to read the rendered
colour back:
- **Before** (pre-change tree, `git stash` build): runs-list usage values were
Succeeded `#F2C879` (amber), Running card `#6FD3B8` (mint); a run header read
`#F2C879` (succeeded) and `#6FD3B8` (running) — the reported bug, `captures` in
`runs_list_before.png`, `run_header_before.png`, `run_header_running_before.png`.
- **After**: runs-list usage values were Succeeded `#7FE0A8` (green), Failed
`#FFB4AB` (error red), Canceled `#889391` (muted), Interrupted `#E8C06A`
(amber), Active `#7FB2F0` (blue); the running card was `#7FB2F0` and the
succeeded card `#7FE0A8` (`runs_list_after.png`). A run header read `#7FE0A8`
(succeeded) and `#7FB2F0` (running) (`run_header_after.png`,
`run_header_running_after.png`).
- **Timeline agrees with the graph**: before, a graph-only outcome still went
through the run-status mapping — an `approved` step chip sampled `#BEC9C5`
(the run-status `Unknown` grey). After, the `success` step chip sampled
`#F2C879` (the graph's tertiary terminal role) and the `approved` chip
`#C0A3F5` (`GraphPalette` index 5), both equal to the graph's `outcomeColor`
(`run_timeline_before.png`, `run_timeline_after.png`).
- `adb -s emulator-5556 logcat -d` contained 0 `FATAL EXCEPTION` / `E
AndroidRuntime` lines (the only app-matched lines were expected
`InputDispatcher … Consumer closed input channel` warnings from the
force-stop/reinstall).
- **APK publish.** `app/build/outputs/apk/debug/app-debug.apk` was copied to
`…/artifacts/69/1/pipelines-debug-wip-cd85f69.apk` (`cd85f69` = `git rev-parse
--short HEAD`); `shasum -a 256` matched. `curl -I
http://10.0.0.249:8080/artifacts/69/1/pipelines-debug-wip-cd85f69.apk` (LAN
address from `ipconfig getifaddr en0`) returned `HTTP/1.1 200 OK`,
`Content-Type: application/vnd.android.package-archive`, `Content-Length:
18009527`; a streamed `GET | shasum -a 256` equalled the local file. At 17.2 MiB
it exceeds the server's 8 MiB per-file inventory cap, so it is served by direct
URL only.
@@ -16,7 +16,6 @@ import androidx.compose.material.icons.filled.Error
import androidx.compose.material.icons.filled.PauseCircle
import androidx.compose.material.icons.filled.Schedule
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
@@ -63,15 +62,12 @@ fun runStateOf(status: String): RunState = when (status.trim().lowercase()) {
else -> RunState.Unknown
}
/** Colour family for a state, sourced from the app-owned scheme (never colour-only). */
@Composable
fun runStateColor(state: RunState): Color = when (state) {
RunState.Running, RunState.Active -> MaterialTheme.colorScheme.primary
RunState.Queued -> MaterialTheme.colorScheme.secondary
RunState.Succeeded -> MaterialTheme.colorScheme.tertiary
RunState.Failed, RunState.Interrupted -> MaterialTheme.colorScheme.error
RunState.Canceled, RunState.Unknown -> MaterialTheme.colorScheme.onSurfaceVariant
}
/**
* Colour family for a state, from the app-owned [RunStatusPalette] (never
* colour-only: every chip also carries its glyph and label). Pure, so it can be
* asserted in a plain JVM unit test.
*/
fun runStateColor(state: RunState): Color = RunStatusPalette.of(state).color
/** A distinct glyph per state, all from the standard filled material icon set. */
fun runStateIcon(state: RunState): ImageVector = when (state) {
@@ -106,14 +102,20 @@ fun RunStatusIcon(
)
}
/** A colour-coded chip pairing a state glyph with its text label. */
/**
* A pill pairing a glyph with its text label, coloured by the caller. Shared by
* the run-status chip and the timeline's step-outcome chip so both render one
* shape and neither repeats the layout. The glyph always carries a
* [contentDescription], so state/outcome is never colour alone.
*/
@Composable
fun StatusChip(
internal fun ColoredChip(
label: String,
state: RunState,
color: Color,
icon: ImageVector,
contentDescription: String? = label,
modifier: Modifier = Modifier,
) {
val color = runStateColor(state)
Row(
modifier = modifier
.clip(RoundedCornerShape(50))
@@ -122,7 +124,12 @@ fun StatusChip(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(4.dp),
) {
RunStatusIcon(state, contentDescription = label, modifier = Modifier.size(14.dp), tint = color)
Icon(
imageVector = icon,
contentDescription = contentDescription,
tint = color,
modifier = Modifier.size(14.dp),
)
Text(
text = label,
color = color,
@@ -132,6 +139,21 @@ fun StatusChip(
}
}
/** A colour-coded chip pairing a state glyph with its text label. */
@Composable
fun StatusChip(
label: String,
state: RunState,
modifier: Modifier = Modifier,
) {
ColoredChip(
label = label,
color = runStateColor(state),
icon = runStateIcon(state),
modifier = modifier,
)
}
/** Convenience: the run's own status word plus its colour-coded chip. */
@Composable
fun RunStatusChip(state: RunState, modifier: Modifier = Modifier) {
@@ -0,0 +1,70 @@
package net.awan.pipelines.ui.components
import androidx.compose.ui.graphics.Color
import net.awan.pipelines.ui.theme.DarkError
/**
* The app-owned run-status palette.
*
* 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.
*
* Every entry below is instead a deliberate, fixed colour with an explicit
* meaning, 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])
* and its text label ([RunState.label]).
*/
internal object RunStatusPalette {
/** One status colour plus the one-line reason it is that hue. */
data class Entry(val color: Color, val rationale: String)
/** In progress: the conventional blue. Green would read as already finished. */
private val Running =
Entry(Color(0xFF7FB2F0), "blue: in progress; green would read as already finished")
/** 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")
/** Failure: the app's error red, the one alarm colour the scheme already owns. */
private val Failed =
Entry(DarkError, "the app error red: an explicit failure, never a soft warning hue")
/** Stopped by the operator mid-flight: amber, a warning that is not a failure. */
private val Interrupted =
Entry(Color(0xFFE8C06A), "amber: stopped by the operator, a warning distinct from failure red")
/** Operator-cancelled: muted grey so a deliberate stop is quiet, not alarming. */
private val Canceled =
Entry(Color(0xFF889391), "muted grey: an operator cancel is quiet, not the failure red")
/** Waiting to start: neutral grey, deliberately not a hue that reads as running. */
private val Queued =
Entry(Color(0xFF9AA6A2), "neutral grey: waiting, clearly not the in-progress blue")
/** Unknown/blank status: the safe, low-key fallback. */
private val Unknown =
Entry(Color(0xFFBEC9C5), "neutral surface grey: an unrecognised status stays low-key")
/**
* The entry for [state]. [RunState.Active] shares [Running] (it is the server's
* `active` usage bucket, i.e. work in progress). Pure, so the palette is
* unit-testable without the Compose runtime.
*/
fun of(state: RunState): Entry = when (state) {
RunState.Running, RunState.Active -> Running
RunState.Succeeded -> Succeeded
RunState.Failed -> Failed
RunState.Interrupted -> Interrupted
RunState.Canceled -> Canceled
RunState.Queued -> Queued
RunState.Unknown -> Unknown
}
}
@@ -18,6 +18,7 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.FitScreen
import androidx.compose.material.icons.filled.Fullscreen
import androidx.compose.material.icons.filled.FullscreenExit
import androidx.compose.material3.ColorScheme
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
@@ -166,32 +167,7 @@ fun WorkflowGraph(
val description = remember(graph, runState) { graphDescription(graph, runState) }
val scheme = MaterialTheme.colorScheme
val colors = remember(scheme) {
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.
nodeFill = scheme.surfaceVariant,
nodeNtfyFill = scheme.tertiaryContainer,
nodeCustomFill = scheme.primaryContainer,
// A selected node inverts (light fill / dark text) plus a 4px border,
// so selection reads in either appearance and never relies on colour.
nodeFillActive = scheme.inverseSurface,
nodeTextActive = scheme.inverseOnSurface,
nodeBorder = scheme.outline,
nodeBorderActive = scheme.primary,
nodeText = scheme.onSurface,
terminalFill = scheme.secondaryContainer,
terminalErrorFill = scheme.errorContainer,
labelBackground = scheme.surface,
labelText = scheme.onSurfaceVariant,
)
}
val colors = remember(scheme) { graphColors(scheme) }
// node key -> stage type, derived once per graph (never per frame) so node
// kind/colour and the spoken description share one lookup.
val stageTypeByKey = remember(graph) { graph.stages.associate { it.key to it.type } }
@@ -381,6 +357,38 @@ internal class GraphColors(
val labelText: Color,
)
/**
* 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.
*/
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.
nodeFill = scheme.surfaceVariant,
nodeNtfyFill = scheme.tertiaryContainer,
nodeCustomFill = scheme.primaryContainer,
// A selected node inverts (light fill / dark text) plus a 4px border, so
// selection reads in either appearance and never relies on colour.
nodeFillActive = scheme.inverseSurface,
nodeTextActive = scheme.inverseOnSurface,
nodeBorder = scheme.outline,
nodeBorderActive = scheme.primary,
nodeText = scheme.onSurface,
terminalFill = scheme.secondaryContainer,
terminalErrorFill = scheme.errorContainer,
labelBackground = scheme.surface,
labelText = scheme.onSurfaceVariant,
)
/** The accessibility label for one node, naming its type when it is a stage. */
private fun nodeDescription(node: NodeLayout, type: String?): String {
if (node.terminal) return "Terminal ${node.label}, tap for details"
@@ -51,6 +51,7 @@ import net.awan.pipelines.data.protocol.SessionEvidence
import net.awan.pipelines.ui.AppViewModel
import net.awan.pipelines.ui.LoadState
import net.awan.pipelines.ui.components.CodeBlock
import net.awan.pipelines.ui.components.ColoredChip
import net.awan.pipelines.ui.components.DetailTabBody
import net.awan.pipelines.ui.components.DetailTabs
import net.awan.pipelines.ui.components.ErrorState
@@ -62,12 +63,15 @@ import net.awan.pipelines.ui.components.StatusChip
import net.awan.pipelines.ui.components.collapsibleSection
import net.awan.pipelines.ui.components.rememberSectionExpansion
import net.awan.pipelines.ui.components.runDetailTabs
import net.awan.pipelines.ui.components.runStateIcon
import net.awan.pipelines.ui.components.runStateOf
import net.awan.pipelines.ui.displayText
import net.awan.pipelines.ui.formatDuration
import net.awan.pipelines.ui.artifactsEmptyMessage
import net.awan.pipelines.ui.graph.ArtifactGallery
import net.awan.pipelines.ui.graph.WorkflowGraph
import net.awan.pipelines.ui.graph.graphColors
import net.awan.pipelines.ui.graph.outcomeColor
import net.awan.pipelines.ui.runArtifactGroups
import net.awan.pipelines.ui.theme.pipelinesText
import net.awan.pipelines.ui.visitCount
@@ -615,6 +619,13 @@ private fun TimelineRow(entry: TimelineEntry, onClick: () -> Unit) {
val text = pipelinesText()
val state = runStateOf(entry.step.outcome.ifBlank { entry.step.status })
val chipLabel = entry.outcomeLabel.ifBlank { state.label }
// A visit's chip and glyph are a *stage outcome*, not the run status, so they
// take the graph's outcome palette and agree with the workflow graph instead
// of being mapped through the run-status colours (the two are different
// vocabularies). Built once per scheme, from the same factory the graph uses.
val scheme = MaterialTheme.colorScheme
val outcomeColors = remember(scheme) { graphColors(scheme) }
val outcomeTint = outcomeColor(entry.step.outcome.ifBlank { entry.step.status }, outcomeColors)
Row(
modifier = Modifier
.fillMaxWidth()
@@ -627,6 +638,7 @@ private fun TimelineRow(entry: TimelineEntry, onClick: () -> Unit) {
state = state,
contentDescription = "Visit ${entry.visit} ${entry.stageKey}: ${state.label}",
modifier = Modifier.size(18.dp),
tint = outcomeTint,
)
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(2.dp)) {
Row(
@@ -640,7 +652,7 @@ private fun TimelineRow(entry: TimelineEntry, onClick: () -> Unit) {
overflow = TextOverflow.Ellipsis,
modifier = Modifier.weight(1f),
)
StatusChip(label = chipLabel, state = state)
ColoredChip(label = chipLabel, color = outcomeTint, icon = runStateIcon(state))
if (hasArtifacts(entry.step)) {
Icon(
imageVector = Icons.Default.AttachFile,
@@ -0,0 +1,73 @@
package net.awan.pipelines.ui.components
import androidx.compose.ui.graphics.Color
import net.awan.pipelines.ui.graph.contrastRatio
import net.awan.pipelines.ui.theme.DarkError
import net.awan.pipelines.ui.theme.DarkPrimary
import net.awan.pipelines.ui.theme.DarkTertiary
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotEquals
import org.junit.Assert.assertTrue
import org.junit.Test
class RunStatusPaletteTest {
/** The dark Pipelines surface every status chip/label is drawn on. */
private val darkSurface = Color(0xFF0E1513)
@Test
fun everyStatusColourMeetsWcagAaOnTheDarkSurface() {
RunState.entries.forEach { state ->
val ratio = contrastRatio(runStateColor(state), darkSurface)
assertTrue("$state contrast $ratio < 4.5", ratio >= 4.5)
}
}
@Test
fun succeededIsGreenNotTheOldAmberTertiary() {
val green = runStateColor(RunState.Succeeded)
assertTrue("green must dominate: $green", green.green > green.red && green.green > green.blue)
assertNotEquals(DarkTertiary, green)
}
@Test
fun runningAndActiveAreTheSameBlueNotTheOldMintPrimary() {
listOf(RunState.Running, RunState.Active).forEach { state ->
val blue = runStateColor(state)
assertTrue("blue must dominate: $blue", blue.blue > blue.red && blue.blue > blue.green)
assertNotEquals(DarkPrimary, blue)
}
assertEquals(runStateColor(RunState.Running), runStateColor(RunState.Active))
}
@Test
fun failedIsTheAppErrorRed() {
assertEquals(DarkError, runStateColor(RunState.Failed))
}
@Test
fun interruptedIsAmberAndDistinctFromFailure() {
val amber = runStateColor(RunState.Interrupted)
assertTrue(
"amber needs red>blue and green>blue: $amber",
amber.red > amber.blue && amber.green > amber.blue,
)
assertNotEquals(DarkError, amber)
}
@Test
fun queuedIsNeutralNotRunningBlue() {
val queued = runStateColor(RunState.Queued)
assertNotEquals(runStateColor(RunState.Running), queued)
val spread = maxOf(queued.red, queued.green, queued.blue) -
minOf(queued.red, queued.green, queued.blue)
assertTrue("queued should be near-grey: $queued", spread < 0.1f)
}
@Test
fun everyEntryHasARationale() {
RunState.entries.forEach { state ->
assertTrue("$state needs a rationale", RunStatusPalette.of(state).rationale.isNotBlank())
}
}
}