Make pass/fail edges the loudest lines in the run graph
Treat `success` and `error` as the emphasised outcomes so pass/fail is obvious at a glance and from a distance. An executed pass/fail edge now uses PASSFAIL_EDGE_STROKE=7f (was 3f), a same-hue, more saturated stroke (PASSFAIL_SATURATION=1.6f via the new pure boostSaturation helper) and a matched PASSFAIL_ARROW_HEAD_SIZE=20f arrowhead. Other executed outcomes keep EDGE_STROKE=3f and not-executed routes the finer INACTIVE_EDGE_STROKE=2.5f, so the two decisive outcomes dominate. All widths, the arrowhead size and the saturation factor are named tokens chosen by edgeStrokeWidth/edgeArrowHeadSize/edgeStrokeColor; the old 12f arrowhead literal at the call site is gone (drawArrowHead now takes the size as a parameter). Outcome hues are unchanged; the boosted stroke keeps the original hue and value. The run Graph tab help line notes that executed success and failure routes are drawn thickest, and the definition-only view gets the same emphasis since every route counts as executed there. New unit tests cover the saturation maths (hue/value/alpha preserved, safe and clamped) and the per-edge width/arrowhead/colour choices.
This commit is contained in:
+94
-3
@@ -111,8 +111,10 @@ stops it.
|
|||||||
fallback), loops and branches, pan/zoom, and run highlighting (under a run the
|
fallback), loops and branches, pan/zoom, and run highlighting (under a run the
|
||||||
executed stage/route is a solid full-colour stroke with an arrowhead and a
|
executed stage/route is a solid full-colour stroke with an arrowhead and a
|
||||||
filled, normal-bordered node, while a not-executed one is a dashed, arrowless
|
filled, normal-bordered node, while a not-executed one is a dashed, arrowless
|
||||||
muted stroke with a hollow, dashed-bordered node and a muted label, plus a
|
muted stroke with a hollow, dashed-bordered node and a muted label; an executed
|
||||||
one-line legend; the definition-only view is unchanged) plus a screen-reader
|
`success`/`error` route is drawn noticeably heavier with a stronger same-hue
|
||||||
|
stroke and a larger arrowhead so pass/fail dominates; a one-line legend names
|
||||||
|
both states) plus a screen-reader
|
||||||
description. Edges are drawn as
|
description. Edges are drawn as
|
||||||
axis-aligned orthogonal polylines like the TUI (`routePoints` computes the
|
axis-aligned orthogonal polylines like the TUI (`routePoints` computes the
|
||||||
path once per layout and stores it on `EdgeLayout.points`), and each arrowhead
|
path once per layout and stores it on `EdgeLayout.points`), and each arrowhead
|
||||||
@@ -1796,7 +1798,8 @@ on or driven).
|
|||||||
- **The definition-only view is untouched.** With no `runState` every
|
- **The definition-only view is untouched.** With no `runState` every
|
||||||
stage/route is executed, so the graph renders exactly as before (solid, filled,
|
stage/route is executed, so the graph renders exactly as before (solid, filled,
|
||||||
arrowed) and the legend is not composed — confirmed against the pipeline Graph
|
arrowed) and the legend is not composed — confirmed against the pipeline Graph
|
||||||
tab.
|
tab. (Superseded later the same day: the pass/fail change below now widens an
|
||||||
|
executed `success`/`error` route in this view too.)
|
||||||
- The run-detail Graph tab's help line was updated from "highlighted … dimmed" to
|
- The run-detail Graph tab's help line was updated from "highlighted … dimmed" to
|
||||||
"solid … dashed and outlined".
|
"solid … dashed and outlined".
|
||||||
|
|
||||||
@@ -1861,3 +1864,91 @@ Not verified in this pass: `:app:lintDebug`, the light theme, and a real hardwar
|
|||||||
fold (the wide/narrow layouts were produced with `wm size`/`wm density`); the
|
fold (the wide/narrow layouts were produced with `wm size`/`wm density`); the
|
||||||
on-device captures used the debug build of this source, while the published APK
|
on-device captures used the debug build of this source, while the published APK
|
||||||
is a clean rebuild of the same source.
|
is a clean rebuild of the same source.
|
||||||
|
|
||||||
|
## Pass/fail edges are the loudest lines (16 Oct 2026)
|
||||||
|
|
||||||
|
`android/` only. Nothing outside `android/` was touched, no dependency was added,
|
||||||
|
no run was started from the app, and every `adb`/emulator command targeted
|
||||||
|
`emulator-5556` (lane A's `emulator-5554` was never used; the attached device was
|
||||||
|
never installed on or driven).
|
||||||
|
|
||||||
|
- **Two decisive outcomes, drawn heavier.** `ui/graph/WorkflowGraph.kt` now
|
||||||
|
treats `success` (pass) and `error` (fail) as the emphasised outcomes
|
||||||
|
(`isPassFailOutcome`). An executed pass/fail edge is drawn at
|
||||||
|
`PASSFAIL_EDGE_STROKE = 7f` — noticeably heavier than the previous `3f` — with
|
||||||
|
a stronger, more saturated stroke and a matching `PASSFAIL_ARROW_HEAD_SIZE =
|
||||||
|
20f` arrowhead, so pass/fail is obvious at a glance and from a distance.
|
||||||
|
- **Other lines stay finer.** Every other executed outcome keeps `EDGE_STROKE =
|
||||||
|
3f`, and a not-executed edge uses the finer `INACTIVE_EDGE_STROKE = 2.5f`, so
|
||||||
|
the two emphasised outcomes dominate. No outcome hue changed.
|
||||||
|
- **Stronger, same-hue stroke.** `boostSaturation(color, factor)` in
|
||||||
|
`ui/graph/GraphPalette.kt` scales HSV saturation by `PASSFAIL_SATURATION =
|
||||||
|
1.6f`, clamping at 1 while preserving hue, value and alpha. On the dark theme
|
||||||
|
the executed `success` stroke moves from `#F2C879` (hue 39.2°) to a vivid
|
||||||
|
`#F2AF30`-ish core (hue 39.3°, measured pixel `(242,175,48)`) and the executed
|
||||||
|
`error` stroke from `#FFB4AB` (hue 6.4°) to a stronger `(255,135,121)` (hue
|
||||||
|
6.3°); the measured pixel hues match their unboosted originals, so meaning is
|
||||||
|
not conveyed by a new colour. A non-pass/fail or not-executed edge keeps its
|
||||||
|
exact outcome colour.
|
||||||
|
- **Widths come from named tokens, not call sites.** `edgeStrokeWidth`,
|
||||||
|
`edgeArrowHeadSize` and `edgeStrokeColor` pick the token for an edge; the old
|
||||||
|
`12f` arrowhead literal is gone (the draw scope takes the size as a
|
||||||
|
parameter). The legend swatch keeps the base `EDGE_STROKE`/`ARROW_HEAD_SIZE`
|
||||||
|
because it names the generic executed/not-executed states, not pass/fail.
|
||||||
|
- **Definition-only view.** With no run selected every route counts as executed,
|
||||||
|
so the definition graph now shows the same pass/fail emphasis (still no
|
||||||
|
legend). The run Graph tab help line now adds "Executed success and failure
|
||||||
|
routes are drawn thickest."
|
||||||
|
|
||||||
|
Verification (macOS; Homebrew `openjdk@17`,
|
||||||
|
`JAVA_HOME=/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home`,
|
||||||
|
Gradle 8.11.1 at
|
||||||
|
`~/.gradle/wrapper/dists/gradle-8.11.1-bin/…/gradle-8.11.1/bin/gradle`,
|
||||||
|
`ANDROID_HOME=/Users/alan/Library/Android/sdk`, `--offline`):
|
||||||
|
|
||||||
|
- `gradle --offline clean :app:testDebugUnitTest :app:assembleDebug` →
|
||||||
|
**193 tests, 0 failures, 0 errors**; `WorkflowGraphTest` **36** (2 new: the
|
||||||
|
executed pass/fail edge is the widest and its arrowhead scales, and only
|
||||||
|
`success`/`error` are pass/fail outcomes) and `GraphPaletteTest` **10** (3 new:
|
||||||
|
`boostSaturation` raises saturation while keeping hue/value/alpha, is safe and
|
||||||
|
clamped at the edges, and only executed pass/fail strokes are saturated
|
||||||
|
further). The clean `:app:assembleDebug` produced `app-debug.apk`
|
||||||
|
**17,912,489 bytes**, sha256
|
||||||
|
`ce63722b851ce26322da69fa47bdc91958c3d7db3e339c1340efc3e04b6780f8`.
|
||||||
|
- **Before/after on a run with both a success and an error edge.** Run 77
|
||||||
|
(pipeline 11 "Focused tweak - implement review commit", failed at `ui_reviewer`
|
||||||
|
with `error`) was opened in the app against the live server
|
||||||
|
`ws://10.0.2.2:8080/connect` in dark mode; its taken routes include a `success`
|
||||||
|
and an `error` edge. "Before" is HEAD `9c47527` (the six edited files stashed,
|
||||||
|
rebuilt, installed; verified by the help line without "thickest"); "after" is
|
||||||
|
this change. Captures were written with
|
||||||
|
`android/scripts/capture_png.sh -s emulator-5556`:
|
||||||
|
- **Wide** 2208x1840 @ density 420 (≈841dp): `before_wide_1x.png` /
|
||||||
|
`after_wide_1x.png`. At the panel's fit scale the executed success/error
|
||||||
|
stroke's saturated core measures **1px before, 3px after** (sampled at the
|
||||||
|
same x), while the dashed non-pass/fail routes stay ~1px.
|
||||||
|
- **Wide 2x** 4416x3680 @ density 840: `before_wide_2x.png` /
|
||||||
|
`after_wide_2x.png`.
|
||||||
|
- Cropped graph panes `before_wide_{1x,2x}_graphcrop.png` /
|
||||||
|
`after_wide_{1x,2x}_graphcrop.png` and stacked before/after sheets
|
||||||
|
`compare_wide_1x.png` / `compare_wide_2x.png` show the two amber `success`
|
||||||
|
edges and the red `error` edge as the boldest lines after the change, with
|
||||||
|
the dashed `blocked`/`rejected`/`approved`/`skipped` routes and the
|
||||||
|
not-executed `committer`/`SUCCESS` edges unchanged.
|
||||||
|
- `adb -s emulator-5556 logcat -d` contained 0 `FATAL EXCEPTION` and 0
|
||||||
|
`E AndroidRuntime` lines.
|
||||||
|
- **APK publish.** `app-debug.apk` copied to
|
||||||
|
`…/artifacts/98/1/pipelines-debug-wip-9c47527.apk` (`9c47527` = `git rev-parse
|
||||||
|
--short HEAD`); `shasum -a 256` matched. `curl -I
|
||||||
|
http://10.0.0.249:8080/artifacts/98/1/pipelines-debug-wip-9c47527.apk` (`10.0.0.249`
|
||||||
|
from `ipconfig getifaddr en0`) returned `HTTP/1.1 200 OK`,
|
||||||
|
`Content-Type: application/vnd.android.package-archive`, `Content-Length:
|
||||||
|
17912489`, and a streamed `GET | shasum -a 256` equalled the local file. The
|
||||||
|
APK exceeds the server's per-file inventory cap, so it is served by direct URL
|
||||||
|
only.
|
||||||
|
|
||||||
|
Not verified in this pass: `:app:lintDebug`, the light theme, and a real hardware
|
||||||
|
fold (the wide layout was produced with `wm size`/`wm density`); the on-device
|
||||||
|
captures used the debug build of this source, while the published APK is a clean
|
||||||
|
rebuild of the same source.
|
||||||
|
|
||||||
|
|||||||
@@ -94,6 +94,36 @@ internal fun graphNodeKind(terminal: Boolean, key: String, type: String?): Graph
|
|||||||
else -> GraphNodeKind.Custom
|
else -> GraphNodeKind.Custom
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A more vivid version of [color] with the same hue, value and alpha: the HSV
|
||||||
|
* saturation is scaled by [factor] and clamped to 1. Used to make an executed
|
||||||
|
* pass/fail edge stroke stronger without changing its outcome hue, so both
|
||||||
|
* terminal colours get more punch while staying recognisably success/failure.
|
||||||
|
*
|
||||||
|
* Pure sRGB maths. A non-finite/non-positive [factor], an achromatic colour or
|
||||||
|
* one already at full saturation returns [color] unchanged, so callers never get
|
||||||
|
* NaN and every input is safe.
|
||||||
|
*/
|
||||||
|
internal fun boostSaturation(color: Color, factor: Float): Color {
|
||||||
|
if (!factor.isFinite() || factor <= 0f) return color
|
||||||
|
val r = color.red
|
||||||
|
val g = color.green
|
||||||
|
val b = color.blue
|
||||||
|
val max = maxOf(r, g, b)
|
||||||
|
val min = minOf(r, g, b)
|
||||||
|
val delta = max - min
|
||||||
|
if (max <= 0f || delta <= 0f) return color
|
||||||
|
val current = delta / max
|
||||||
|
val saturation = (current * factor).coerceAtMost(1f)
|
||||||
|
if (saturation <= current) return color
|
||||||
|
val hue = (when (max) {
|
||||||
|
r -> ((g - b) / delta + 6f) % 6f
|
||||||
|
g -> (b - r) / delta + 2f
|
||||||
|
else -> (r - g) / delta + 4f
|
||||||
|
}) * 60f
|
||||||
|
return Color.hsv(hue, saturation, max, color.alpha)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WCAG relative luminance of [color] (sRGB), the building block of the WCAG
|
* WCAG relative luminance of [color] (sRGB), the building block of the WCAG
|
||||||
* contrast ratio. Pure so the palette's legibility is measured in a unit test
|
* contrast ratio. Pure so the palette's legibility is measured in a unit test
|
||||||
|
|||||||
@@ -145,8 +145,11 @@ internal data class ZoomResult(val offset: Offset, val scale: Float)
|
|||||||
* not-executed one is dashed and arrowless (nodes hollow with a muted, legible
|
* not-executed one is dashed and arrowless (nodes hollow with a muted, legible
|
||||||
* label), so the two states differ in shape, fill and border style rather than
|
* label), so the two states differ in shape, fill and border style rather than
|
||||||
* by a faded tint and survive a screenshot, a dim screen and a colour-blind
|
* by a faded tint and survive a screenshot, a dim screen and a colour-blind
|
||||||
* reader; a one-line legend names both states. When [runState] is null the full
|
* reader; a one-line legend names both states. An executed `success`/`error`
|
||||||
* definition is shown, unchanged.
|
* edge is drawn noticeably heavier with a stronger, same-hue stroke and a larger
|
||||||
|
* arrowhead, so the two decisive outcomes are the loudest lines in the graph.
|
||||||
|
* When [runState] is null the full definition is shown, with the same pass/fail
|
||||||
|
* emphasis (every route counts as executed) and no legend.
|
||||||
*
|
*
|
||||||
* A tap that lands inside a node (stage or terminal) calls [onStageTap] with the
|
* A tap that lands inside a node (stage or terminal) calls [onStageTap] with the
|
||||||
* node key; tapping empty space does nothing. Pan/zoom keep working because the
|
* node key; tapping empty space does nothing. Pan/zoom keep working because the
|
||||||
@@ -405,7 +408,7 @@ private fun LegendSwatch(executed: Boolean, colors: GraphColors) {
|
|||||||
strokeWidth = EDGE_STROKE,
|
strokeWidth = EDGE_STROKE,
|
||||||
pathEffect = if (executed) null else INACTIVE_DASH_EFFECT,
|
pathEffect = if (executed) null else INACTIVE_DASH_EFFECT,
|
||||||
)
|
)
|
||||||
if (executed) drawArrowHead(listOf(from, to), color)
|
if (executed) drawArrowHead(listOf(from, to), color, ARROW_HEAD_SIZE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1074,16 +1077,25 @@ private fun DrawScope.drawEdgePaths(
|
|||||||
// Executed = solid full-colour stroke plus an arrowhead; not executed =
|
// Executed = solid full-colour stroke plus an arrowhead; not executed =
|
||||||
// dashed muted stroke with no arrowhead. The difference is carried by line
|
// dashed muted stroke with no arrowhead. The difference is carried by line
|
||||||
// style and arrowhead presence, never by opacity alone, so it survives a
|
// style and arrowhead presence, never by opacity alone, so it survives a
|
||||||
// screenshot, a dim screen and a colour-blind reader.
|
// screenshot, a dim screen and a colour-blind reader. An executed
|
||||||
|
// `success`/`error` edge uses the heavier pass/fail width, a stronger
|
||||||
|
// (same-hue) stroke and a matched arrowhead, so pass/fail dominates.
|
||||||
if (edgeIsExecuted(edge.edge, runState)) {
|
if (edgeIsExecuted(edge.edge, runState)) {
|
||||||
val color = outcomeColor(edge.edge.outcome, colors)
|
val color = edgeStrokeColor(edge.edge, runState, colors)
|
||||||
drawPath(path, color = color, style = Stroke(width = EDGE_STROKE))
|
drawPath(
|
||||||
drawArrowHead(points, color)
|
path,
|
||||||
|
color = color,
|
||||||
|
style = Stroke(width = edgeStrokeWidth(edge.edge, runState)),
|
||||||
|
)
|
||||||
|
drawArrowHead(points, color, edgeArrowHeadSize(edge.edge, runState))
|
||||||
} else {
|
} else {
|
||||||
drawPath(
|
drawPath(
|
||||||
path,
|
path,
|
||||||
color = colors.labelText,
|
color = colors.labelText,
|
||||||
style = Stroke(width = EDGE_STROKE, pathEffect = INACTIVE_DASH_EFFECT),
|
style = Stroke(
|
||||||
|
width = edgeStrokeWidth(edge.edge, runState),
|
||||||
|
pathEffect = INACTIVE_DASH_EFFECT,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1128,17 +1140,18 @@ private fun DrawScope.drawEdgeLabels(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws an arrowhead at the tip of [points], oriented along the final segment's
|
* Draws an arrowhead of length [size] at the tip of [points], oriented along the
|
||||||
* direction (see [arrowDirection]) instead of the from-to chord, so a route that
|
* final segment's direction (see [arrowDirection]) instead of the from-to chord,
|
||||||
* turns a corner still gets an arrow pointing the way it actually travels.
|
* so a route that turns a corner still gets an arrow pointing the way it
|
||||||
|
* actually travels. [size] is passed by the caller from the matching named token
|
||||||
|
* (see [edgeArrowHeadSize]) rather than written here.
|
||||||
*/
|
*/
|
||||||
private fun DrawScope.drawArrowHead(points: List<Offset>, color: Color) {
|
private fun DrawScope.drawArrowHead(points: List<Offset>, color: Color, size: Float) {
|
||||||
if (points.size < 2) return
|
if (points.size < 2) return
|
||||||
val to = points.last()
|
val to = points.last()
|
||||||
val direction = arrowDirection(points)
|
val direction = arrowDirection(points)
|
||||||
if (direction.x == 0f && direction.y == 0f) return
|
if (direction.x == 0f && direction.y == 0f) return
|
||||||
val angle = kotlin.math.atan2(direction.y.toDouble(), direction.x.toDouble())
|
val angle = kotlin.math.atan2(direction.y.toDouble(), direction.x.toDouble())
|
||||||
val size = 12f
|
|
||||||
val left = Offset(
|
val left = Offset(
|
||||||
x = to.x - size * kotlin.math.cos(angle - 0.5).toFloat(),
|
x = to.x - size * kotlin.math.cos(angle - 0.5).toFloat(),
|
||||||
y = to.y - size * kotlin.math.sin(angle - 0.5).toFloat(),
|
y = to.y - size * kotlin.math.sin(angle - 0.5).toFloat(),
|
||||||
@@ -1263,6 +1276,46 @@ internal fun stageIsExecuted(key: String, runState: RunGraphState?): Boolean =
|
|||||||
internal fun edgeIsExecuted(edge: GraphEdge, runState: RunGraphState?): Boolean =
|
internal fun edgeIsExecuted(edge: GraphEdge, runState: RunGraphState?): Boolean =
|
||||||
runState == null || GraphRoute(edge.source, edge.outcome, edge.target) in runState.takenRoutes
|
runState == null || GraphRoute(edge.source, edge.outcome, edge.target) in runState.takenRoutes
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True for the two decisive outcomes the graph emphasises: `success` (pass) and
|
||||||
|
* `error` (fail). These are the protocol's terminal outcomes, the only two whose
|
||||||
|
* stroke is widened. Pure, so drawing and the tests share one definition.
|
||||||
|
*/
|
||||||
|
internal fun isPassFailOutcome(outcome: String): Boolean =
|
||||||
|
outcome == "success" || outcome == "error"
|
||||||
|
|
||||||
|
/** True for an executed pass/fail edge: the edges drawn heaviest. */
|
||||||
|
internal fun isEmphasizedEdge(edge: GraphEdge, runState: RunGraphState?): Boolean =
|
||||||
|
isPassFailOutcome(edge.outcome) && edgeIsExecuted(edge, runState)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The named stroke-width token for [edge]: the heavier pass/fail width for an
|
||||||
|
* executed `success`/`error`, the base width for any other executed outcome, and
|
||||||
|
* the finest width for a not-executed edge. Pure, so the widths are asserted in a
|
||||||
|
* unit test and no call site writes a stroke literal.
|
||||||
|
*/
|
||||||
|
internal fun edgeStrokeWidth(edge: GraphEdge, runState: RunGraphState?): Float = when {
|
||||||
|
!edgeIsExecuted(edge, runState) -> INACTIVE_EDGE_STROKE
|
||||||
|
isPassFailOutcome(edge.outcome) -> PASSFAIL_EDGE_STROKE
|
||||||
|
else -> EDGE_STROKE
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The named arrowhead-size token for [edge], scaled to match [edgeStrokeWidth]. */
|
||||||
|
internal fun edgeArrowHeadSize(edge: GraphEdge, runState: RunGraphState?): Float =
|
||||||
|
if (isEmphasizedEdge(edge, runState)) PASSFAIL_ARROW_HEAD_SIZE else ARROW_HEAD_SIZE
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The stroke colour for an executed [edge]: its outcome colour, made more
|
||||||
|
* saturated when pass/fail so it is stronger without changing its hue (see
|
||||||
|
* [boostSaturation]). A not-executed edge is drawn muted elsewhere.
|
||||||
|
*/
|
||||||
|
internal fun edgeStrokeColor(edge: GraphEdge, runState: RunGraphState?, colors: GraphColors): Color =
|
||||||
|
if (isEmphasizedEdge(edge, runState)) {
|
||||||
|
boostSaturation(outcomeColor(edge.outcome, colors), PASSFAIL_SATURATION)
|
||||||
|
} else {
|
||||||
|
outcomeColor(edge.outcome, colors)
|
||||||
|
}
|
||||||
|
|
||||||
/** A screen-reader description so meaning is never conveyed by colour alone. */
|
/** A screen-reader description so meaning is never conveyed by colour alone. */
|
||||||
private fun graphDescription(graph: Graph, runState: RunGraphState?): String {
|
private fun graphDescription(graph: Graph, runState: RunGraphState?): String {
|
||||||
if (graph.stages.isEmpty()) return "Empty workflow graph"
|
if (graph.stages.isEmpty()) return "Empty workflow graph"
|
||||||
@@ -1290,12 +1343,38 @@ private val FIT_PADDING = 16.dp
|
|||||||
private val MIN_VISIBLE = 48.dp
|
private val MIN_VISIBLE = 48.dp
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Line-style tokens shared by the graph and its legend. An executed stroke is
|
* Line-style tokens shared by the graph and its legend. Widths and the arrowhead
|
||||||
* solid; a not-executed stroke is dashed with [INACTIVE_DASH_INTERVALS] on/off
|
* size are named here so no call site writes a stroke literal. An executed route
|
||||||
|
* is solid; a not-executed route is dashed with [INACTIVE_DASH_INTERVALS] on/off
|
||||||
* pixels, so the two states differ by shape, not by a faded tint.
|
* pixels, so the two states differ by shape, not by a faded tint.
|
||||||
|
*
|
||||||
|
* The two decisive outcomes (`success`/`error`) use the heavier
|
||||||
|
* [PASSFAIL_EDGE_STROKE] with the matching [PASSFAIL_ARROW_HEAD_SIZE] and a
|
||||||
|
* stronger [PASSFAIL_SATURATION] stroke, so pass/fail reads at a glance and from
|
||||||
|
* a distance, while every other outcome keeps the finer [EDGE_STROKE] and a
|
||||||
|
* not-executed route the finer still [INACTIVE_EDGE_STROKE].
|
||||||
*/
|
*/
|
||||||
private const val EDGE_STROKE = 3f
|
private const val EDGE_STROKE = 3f
|
||||||
|
|
||||||
|
/** Stroke width for an executed `success`/`error` edge; heavier than [EDGE_STROKE]. */
|
||||||
|
private const val PASSFAIL_EDGE_STROKE = 7f
|
||||||
|
|
||||||
|
/** Stroke width for a not-executed edge; finer than either executed width. */
|
||||||
|
private const val INACTIVE_EDGE_STROKE = 2.5f
|
||||||
|
|
||||||
|
/** Arrowhead length for a normal executed edge. */
|
||||||
|
private const val ARROW_HEAD_SIZE = 12f
|
||||||
|
|
||||||
|
/** Arrowhead length for an executed pass/fail edge, scaled with its heavier stroke. */
|
||||||
|
private const val PASSFAIL_ARROW_HEAD_SIZE = 20f
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How much more saturated an executed pass/fail stroke is than its outcome
|
||||||
|
* colour: hue and value are preserved (see [boostSaturation]) so the meaning of
|
||||||
|
* the colour does not change.
|
||||||
|
*/
|
||||||
|
private const val PASSFAIL_SATURATION = 1.6f
|
||||||
|
|
||||||
/** The dash pattern (on/off, px) for every not-executed stroke; pure data. */
|
/** The dash pattern (on/off, px) for every not-executed stroke; pure data. */
|
||||||
internal val INACTIVE_DASH_INTERVALS = floatArrayOf(14f, 10f)
|
internal val INACTIVE_DASH_INTERVALS = floatArrayOf(14f, 10f)
|
||||||
|
|
||||||
|
|||||||
@@ -385,7 +385,7 @@ private fun RunGraphTab(
|
|||||||
Text("This server did not include the run graph.", style = text.meta)
|
Text("This server did not include the run graph.", style = text.meta)
|
||||||
} else {
|
} else {
|
||||||
Text(
|
Text(
|
||||||
"Executed stages and routes are solid; not-executed ones are dashed and outlined. Pinch to zoom, drag to pan, tap a stage for details.",
|
"Executed stages and routes are solid; not-executed ones are dashed and outlined. Executed success and failure routes are drawn thickest. Pinch to zoom, drag to pan, tap a stage for details.",
|
||||||
style = text.meta,
|
style = text.meta,
|
||||||
)
|
)
|
||||||
WorkflowGraph(
|
WorkflowGraph(
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
package net.awan.pipelines.ui.graph
|
package net.awan.pipelines.ui.graph
|
||||||
|
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
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.Protocol
|
||||||
|
import net.awan.pipelines.data.protocol.RunGraphState
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Assert.assertFalse
|
import org.junit.Assert.assertFalse
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
@@ -98,6 +101,87 @@ class GraphPaletteTest {
|
|||||||
assertTrue(contrastRatio(errorRole, darkSurface) >= 4.5)
|
assertTrue(contrastRatio(errorRole, darkSurface) >= 4.5)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The emphasis helper keeps the outcome hue and value and only raises
|
||||||
|
* saturation, so a stronger pass/fail stroke is still recognisably the same
|
||||||
|
* success/failure colour.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
fun boostSaturationRaisesSaturationButKeepsHueValueAndAlpha() {
|
||||||
|
val base = successRole
|
||||||
|
val boosted = boostSaturation(base, 1.6f)
|
||||||
|
assertTrue(saturationOf(boosted) > saturationOf(base))
|
||||||
|
assertEquals(hueOf(base), hueOf(boosted), 1f)
|
||||||
|
assertEquals(valueOf(base), valueOf(boosted), 0.001f)
|
||||||
|
assertEquals(base.alpha, boosted.alpha, 0.001f)
|
||||||
|
// A second hue is left on its own hue, not shifted toward the first.
|
||||||
|
val red = errorRole
|
||||||
|
assertEquals(hueOf(red), hueOf(boostSaturation(red, 1.6f)), 1f)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun boostSaturationIsSafeAndClampedAtTheEdges() {
|
||||||
|
val base = successRole
|
||||||
|
// A no-op factor, and invalid factors, return the colour unchanged.
|
||||||
|
assertEquals(base, boostSaturation(base, 1f))
|
||||||
|
assertEquals(base, boostSaturation(base, 0f))
|
||||||
|
assertEquals(base, boostSaturation(base, -1f))
|
||||||
|
assertEquals(base, boostSaturation(base, Float.NaN))
|
||||||
|
// Achromatic colours have no saturation to raise.
|
||||||
|
assertEquals(Color.Gray, boostSaturation(Color.Gray, 2f))
|
||||||
|
// An already fully-saturated colour clamps at 1 instead of overshooting.
|
||||||
|
assertEquals(Color.Red, boostSaturation(Color.Red, 2f))
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only an executed pass/fail edge is emphasised: its stroke is the stronger
|
||||||
|
* same-hue colour, while a non-pass/fail edge and a not-executed edge keep
|
||||||
|
* their exact outcome colour.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
fun onlyExecutedPassFailStrokesAreSaturatedFurther() {
|
||||||
|
val colors = colors()
|
||||||
|
val success = GraphEdge(1, "a", "success", Protocol.SUCCESS_END, "success")
|
||||||
|
val blocked = GraphEdge(2, "a", "blocked", Protocol.FAILURE_END, "blocked")
|
||||||
|
val error = GraphEdge(3, "b", "error", Protocol.FAILURE_END, "error")
|
||||||
|
val executed = RunGraphState(
|
||||||
|
visitedStages = setOf("a"),
|
||||||
|
takenRoutes = setOf(GraphRoute("a", "success", Protocol.SUCCESS_END)),
|
||||||
|
currentStage = "a",
|
||||||
|
)
|
||||||
|
|
||||||
|
val baseSuccess = outcomeColor("success", colors)
|
||||||
|
val strokeSuccess = edgeStrokeColor(success, executed, colors)
|
||||||
|
assertEquals(hueOf(baseSuccess), hueOf(strokeSuccess), 1f)
|
||||||
|
assertTrue(saturationOf(strokeSuccess) > saturationOf(baseSuccess))
|
||||||
|
|
||||||
|
// A non-pass/fail edge and a not-executed pass/fail edge are untouched.
|
||||||
|
assertEquals(outcomeColor("blocked", colors), edgeStrokeColor(blocked, executed, colors))
|
||||||
|
assertEquals(outcomeColor("error", colors), edgeStrokeColor(error, executed, colors))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Hue in degrees, matching the conversion [boostSaturation] uses. */
|
||||||
|
private fun hueOf(color: Color): Float {
|
||||||
|
val max = maxOf(color.red, color.green, color.blue)
|
||||||
|
val min = minOf(color.red, color.green, color.blue)
|
||||||
|
val delta = max - min
|
||||||
|
if (delta == 0f) return 0f
|
||||||
|
val h = when (max) {
|
||||||
|
color.red -> ((color.green - color.blue) / delta + 6f) % 6f
|
||||||
|
color.green -> (color.blue - color.red) / delta + 2f
|
||||||
|
else -> (color.red - color.green) / delta + 4f
|
||||||
|
}
|
||||||
|
return h * 60f
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun saturationOf(color: Color): Float {
|
||||||
|
val max = maxOf(color.red, color.green, color.blue)
|
||||||
|
val min = minOf(color.red, color.green, color.blue)
|
||||||
|
return if (max <= 0f) 0f else (max - min) / max
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun valueOf(color: Color): Float = maxOf(color.red, color.green, color.blue)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun nodeKindIsDeterministicAndCoversEveryKind() {
|
fun nodeKindIsDeterministicAndCoversEveryKind() {
|
||||||
assertEquals(GraphNodeKind.Model, graphNodeKind(false, "planner", null))
|
assertEquals(GraphNodeKind.Model, graphNodeKind(false, "planner", null))
|
||||||
|
|||||||
@@ -518,6 +518,56 @@ class WorkflowGraphTest {
|
|||||||
assertFalse(edgeIsExecuted(notTaken, runState))
|
assertFalse(edgeIsExecuted(notTaken, runState))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The emphasis contract: an executed `success`/`error` edge uses the widest
|
||||||
|
* named stroke token, every other executed outcome a finer one and a
|
||||||
|
* not-executed edge the finest, with the arrowhead scaled to match. The
|
||||||
|
* definition-only view applies the same pass/fail emphasis.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
fun executedPassFailEdgesAreTheWidest() {
|
||||||
|
val graph = sampleGraph()
|
||||||
|
val success = graph.edges().first { it.outcome == "success" }
|
||||||
|
val error = graph.edges().first { it.outcome == "error" }
|
||||||
|
val other = graph.edges().first { it.outcome == "blocked" }
|
||||||
|
val untaken = graph.edges().first { it.outcome == "rejected" }
|
||||||
|
val runState = RunGraphState(
|
||||||
|
visitedStages = setOf("planner", "implementer", "reviewer"),
|
||||||
|
takenRoutes = setOf(
|
||||||
|
GraphRoute(success.source, success.outcome, success.target),
|
||||||
|
GraphRoute(error.source, error.outcome, error.target),
|
||||||
|
GraphRoute(other.source, other.outcome, other.target),
|
||||||
|
),
|
||||||
|
currentStage = "reviewer",
|
||||||
|
)
|
||||||
|
|
||||||
|
val passFailWidth = edgeStrokeWidth(success, runState)
|
||||||
|
assertEquals(passFailWidth, edgeStrokeWidth(error, runState), 0.001f)
|
||||||
|
assertTrue(edgeStrokeWidth(other, runState) < passFailWidth)
|
||||||
|
assertTrue(edgeStrokeWidth(untaken, runState) < edgeStrokeWidth(other, runState))
|
||||||
|
assertTrue(edgeStrokeWidth(untaken, runState) > 0f)
|
||||||
|
|
||||||
|
// The arrowhead scales with the heavier stroke.
|
||||||
|
assertEquals(edgeArrowHeadSize(success, runState), edgeArrowHeadSize(error, runState), 0.001f)
|
||||||
|
assertTrue(edgeArrowHeadSize(success, runState) > edgeArrowHeadSize(other, runState))
|
||||||
|
|
||||||
|
// The definition-only view emphasises the same pass/fail edges.
|
||||||
|
assertEquals(passFailWidth, edgeStrokeWidth(success, null), 0.001f)
|
||||||
|
assertTrue(isEmphasizedEdge(success, runState))
|
||||||
|
assertFalse(isEmphasizedEdge(other, runState))
|
||||||
|
assertFalse(isEmphasizedEdge(untaken, runState))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Only `success` and `error` are the decisive, emphasised outcomes. */
|
||||||
|
@Test
|
||||||
|
fun onlySuccessAndErrorArePassFailOutcomes() {
|
||||||
|
assertTrue(isPassFailOutcome("success"))
|
||||||
|
assertTrue(isPassFailOutcome("error"))
|
||||||
|
for (outcome in listOf("blocked", "rejected", "skipped", "exhausted", "approved", "done", "")) {
|
||||||
|
assertFalse(outcome, isPassFailOutcome(outcome))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The not-executed dash pattern is a real on/off rhythm, not a faded tint: a
|
* The not-executed dash pattern is a real on/off rhythm, not a faded tint: a
|
||||||
* positive, even-length interval list so a dashed stroke reads differently
|
* positive, even-length interval list so a dashed stroke reads differently
|
||||||
|
|||||||
Reference in New Issue
Block a user