diff --git a/android/README.md b/android/README.md index 9fabf032..1a5ac8db 100644 --- a/android/README.md +++ b/android/README.md @@ -108,8 +108,12 @@ stops it. declaration order, with `#failure`/`#success` terminals sharing a lower row and arrows entering their top borders (an `error -> #failure` route leaves its source's bottom); labelled outcome edges (`error*` marks the implicit - fallback), loops and branches, pan/zoom, and run highlighting (executed routes - highlighted, others dimmed) plus a screen-reader description. Edges are drawn as + 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 + 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 + one-line legend; the definition-only view is unchanged) plus a screen-reader + description. Edges are drawn as axis-aligned orthogonal polylines like the TUI (`routePoints` computes the path once per layout and stores it on `EdgeLayout.points`), and each arrowhead points along its route's final segment rather than the from-to chord. Pinch @@ -1757,3 +1761,103 @@ has both pipelines and runs, `list_runs` is not workspace-scoped, and the task forbids touching the server's data, so there was no empty source to render them against; the branch is unit-covered only indirectly. A real hardware fold and `:app:lintDebug` were again not exercised. + +## Executed vs not-executed is structural, with a legend (16 Oct 2026) + +`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 every `adb`/emulator command targeted `emulator-5556` +(lane A's `emulator-5554` was never used; the attached Pixel was never installed +on or driven). + +- **The two states differ by shape, fill and border style, not by a faded tint.** + `ui/graph/WorkflowGraph.kt` now draws an executed route as a solid full-colour + stroke **with** its arrowhead, and a not-executed route as a dashed muted + stroke **without** an arrowhead. A node the run visited is filled with its + normal border; a node it did not is hollow (no fill) with a dashed muted border + and a muted-but-legible `onSurfaceVariant` label. The old `alpha = 0.25f` / + `0.3f` dimming is gone, so the distinction survives a screenshot, a dim screen + and a colour-blind reader. +- **Shared, testable predicates.** `stageIsExecuted(key, runState)` and + `edgeIsExecuted(edge, runState)` (both `runState == null` ⇒ executed) replace + the private `EdgeLayout.isExecuted` and the inline `visitedStages` check, so + drawing and the screen-reader `graphDescription` share one definition. +- **Dash token.** `INACTIVE_DASH_INTERVALS = floatArrayOf(14f, 10f)` is the one + line-style token; `INACTIVE_DASH_EFFECT` is the lazily-built `PathEffect` used + by both the not-executed edges and the not-executed node borders, so it is + never rebuilt per frame. Node/edge geometry keeps the existing layout + tokens/insets — the only new literals are the dash rhythm and the compact + legend swatch, not graph geometry. +- **Compact legend.** `GRAPH_LEGEND` (a solid, arrowed swatch labelled + `Executed`; a dashed, arrowless swatch labelled `Not executed`) is drawn as a + one-line `Row` pinned to the graph's top-start, opposite the Fit/expand + controls, so it stays visible with the top of the panel even on a short/narrow + window. It renders only when a run is selected. +- **The definition-only view is untouched.** With no `runState` every + 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 + tab. +- The run-detail Graph tab's help line was updated from "highlighted … dimmed" to + "solid … dashed and outlined". + +Verification (macOS; Homebrew `openjdk@17` at +`JAVA_HOME=/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home`, +Gradle 8.11.1, `ANDROID_HOME=/Users/alan/Library/Android/sdk`, `--offline`): + +- `gradle --offline clean :app:testDebugUnitTest :app:assembleDebug` → + **188 tests, 0 failures, 0 errors**; `WorkflowGraphTest` **34** tests (3 new: + the executed predicates over the definition view and a `RunGraphState`, the + dash pattern being a positive even-length rhythm, and the legend naming both + states with executed first). The clean `:app:assembleDebug` produced + `app-debug.apk` **17,912,489 bytes**, sha256 + `49631a3a2763bf1d9232eb9e7c8f9ff3edd719355ac0a99b7c91f7f40c3a1cc5` (two clean + rebuilds were byte-identical; this is the published artifact). +- A partly-executed run (run 77, pipeline id 11 "Focused tweak - implement review + commit": `implementer`, `reviewer`, `ui_reviewer` ran, `committer` did not) was + opened in the app against the live server `ws://10.0.2.2:8080/connect` in dark + mode, driven with `adb shell input`, and every capture below was written with + `android/scripts/capture_png.sh -s emulator-5556` (validated PNG magic bytes; + the fold emulator has two displays, so a `screencap` redirect must never be + used). Captures are in `…/artifacts/93/1/`: + - **Narrow** 1080x1920 @ density 480 (≈360dp): `[implementer]`, `[reviewer]`, + `[ui_reviewer]` and `[FAILURE]` are filled with solid, arrowed routes between + the visited stages and into `#failure`; `[committer]` and `[SUCCESS]` are + hollow with dashed borders, and every other route is dashed with no arrowhead + (`graph_partly_exec_narrow_1x.png`). + - **Narrow, 2x** at 2160x3840 @ density 960 (same 360dp): the same graph at + double the pixel density, dashes and arrowheads clearly resolved + (`graph_partly_exec_narrow_2x.png`). + - **Wide** 2208x1840 @ density 420 (≈841dp): `graph_partly_exec_wide_1x.png`; + **wide 2x** at 4416x3680 @ density 840: `graph_partly_exec_wide_2x.png`; a + colour 2x crop of the graph and legend `graph_partly_exec_wide_1x_zoom.png`. + - **Grayscale check.** Greyscale conversions (`PIL` `Image.convert('L')`) of + the narrow-2x and wide-1x captures, plus a 2x greyscale crop, keep the + distinction: the executed routes are continuous solid lines with arrowheads + and the nodes fill, while the not-executed routes are broken dashed lines and + the nodes are hollow outlines (`graph_partly_exec_narrow_2x_gray.png`, + `graph_partly_exec_wide_1x_gray.png`, + `graph_partly_exec_wide_1x_gray_zoom.png`). + - **Definition-only view unchanged.** Captured the pipeline Graph tab (no run) + on a pre-change build (a `54af453` worktree) and on this build; the graph pane + is pixel-identical (no legend on either side). A + `PIL ImageChops.difference` over the graph pane (`x 1150–2208, y 150–1500`) + reported `bbox None` / `0` differing pixels of 1,428,300 / max channel diff + `0`. Before/after pair: `def_before_p8.png` / `def_after_p8.png` (pipeline 8 + Graph tab); the same source's pipeline-11 Graph tab after is + `graph_definition_only_wide_1x.png`. + - `adb -s emulator-5556 logcat -d` contained 0 `FATAL EXCEPTION` and 0 + `E AndroidRuntime` lines. +- **APK publish.** `app-debug.apk` copied to + `…/artifacts/93/1/pipelines-debug-wip-54af453.apk` (`54af453` = `git rev-parse + --short HEAD`); `shasum -a 256` matched. `curl -I + http://10.0.0.249:8080/artifacts/93/1/pipelines-debug-wip-54af453.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. At + ~17.1 MiB the APK exceeds the server's 8 MiB 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/narrow layouts were 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. diff --git a/android/app/src/main/java/net/awan/pipelines/ui/graph/WorkflowGraph.kt b/android/app/src/main/java/net/awan/pipelines/ui/graph/WorkflowGraph.kt index 2b72c411..84940fcc 100644 --- a/android/app/src/main/java/net/awan/pipelines/ui/graph/WorkflowGraph.kt +++ b/android/app/src/main/java/net/awan/pipelines/ui/graph/WorkflowGraph.kt @@ -5,6 +5,7 @@ import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.background import androidx.compose.foundation.gestures.detectTapGestures import androidx.compose.foundation.gestures.detectTransformGestures +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize @@ -22,6 +23,7 @@ import androidx.compose.material3.ColorScheme import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -39,6 +41,7 @@ import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Size import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Path +import androidx.compose.ui.graphics.PathEffect import androidx.compose.ui.graphics.TransformOrigin import androidx.compose.ui.graphics.drawscope.DrawScope import androidx.compose.ui.graphics.drawscope.Stroke @@ -137,8 +140,13 @@ internal data class ZoomResult(val offset: Offset, val scale: Float) * Node/edge/outcome semantics come from [GraphSemantics] and [edges], mirroring * internal/tui/graph.go: content-sized stage nodes, labelled outcome edges with * the `error*` fallback marker, `#success`/`#failure` terminals and loop routes. - * When [runState] is supplied, executed stages/routes are highlighted and the - * rest dimmed; when it is null the full definition is shown. + * When [runState] is supplied, an executed stage/route is drawn solid and + * full-colour with an arrowhead (nodes filled with a normal border) while a + * 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 + * 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 + * definition is shown, unchanged. * * 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 @@ -302,6 +310,33 @@ fun WorkflowGraph( ) } } + // A compact one-line legend, only under a run (never the definition-only + // view): a solid, arrowed swatch means "executed", a dashed, arrowless + // one means "not executed", matching what the graph draws. It is pinned + // to the top-start (opposite the Fit/expand controls) so it stays visible + // with the top of the panel on a short/narrow window, and its surface + // background keeps it legible wherever the panned/zoomed graph sits. + if (runState != null) { + Row( + modifier = Modifier + .align(Alignment.TopStart) + .padding(4.dp) + .background(MaterialTheme.colorScheme.surface.copy(alpha = 0.85f)) + .padding(horizontal = 6.dp, vertical = 3.dp), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(10.dp), + ) { + GRAPH_LEGEND.forEach { entry -> + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(4.dp), + ) { + LegendSwatch(entry.executed, colors) + Text(entry.label, style = MaterialTheme.typography.labelSmall) + } + } + } + } Row( modifier = Modifier.align(Alignment.TopEnd).padding(4.dp), ) { @@ -339,6 +374,41 @@ fun WorkflowGraph( } } +/** + * One legend entry: the [label] a reader sees and whether it names the executed + * state. Pure data so the legend's content is asserted in a plain JVM test. + */ +internal data class GraphLegendEntry(val label: String, val executed: Boolean) + +/** The two execution states the legend names, executed first. */ +internal val GRAPH_LEGEND: List = listOf( + GraphLegendEntry("Executed", executed = true), + GraphLegendEntry("Not executed", executed = false), +) + +/** + * A small line swatch for one legend entry, drawn with the same stroke style the + * graph uses: a solid, arrowed line when [executed], a dashed, arrowless line + * otherwise. + */ +@Composable +private fun LegendSwatch(executed: Boolean, colors: GraphColors) { + Canvas(Modifier.size(LEGEND_SWATCH_WIDTH, LEGEND_SWATCH_HEIGHT)) { + val y = size.height / 2f + val from = Offset(0f, y) + val to = Offset(size.width, y) + val color = if (executed) colors.nodeText else colors.labelText + drawLine( + color = color, + start = from, + end = to, + strokeWidth = EDGE_STROKE, + pathEffect = if (executed) null else INACTIVE_DASH_EFFECT, + ) + if (executed) drawArrowHead(listOf(from, to), color) + } +} + internal class GraphColors( val success: Color, val error: Color, @@ -992,9 +1062,6 @@ private fun DrawScope.drawEdgePaths( runState: RunGraphState?, ) { for (edge in layout.edges) { - val executed = edge.isExecuted(runState) - val color = outcomeColor(edge.edge.outcome, colors) - val alpha = if (executed) 1f else 0.25f // Routing already happened once in layoutGraph; drawing only replays the // stored polyline, so there is no per-frame recompute. val points = if (edge.points.isEmpty()) routePoints(edge) else edge.points @@ -1004,8 +1071,21 @@ private fun DrawScope.drawEdgePaths( for (i in 1 until points.size) { path.lineTo(points[i].x, points[i].y) } - drawPath(path, color = color.copy(alpha = alpha), style = Stroke(width = 3f)) - drawArrowHead(points, color.copy(alpha = alpha)) + // Executed = solid full-colour stroke plus an arrowhead; not executed = + // dashed muted stroke with no arrowhead. The difference is carried by line + // style and arrowhead presence, never by opacity alone, so it survives a + // screenshot, a dim screen and a colour-blind reader. + if (edgeIsExecuted(edge.edge, runState)) { + val color = outcomeColor(edge.edge.outcome, colors) + drawPath(path, color = color, style = Stroke(width = EDGE_STROKE)) + drawArrowHead(points, color) + } else { + drawPath( + path, + color = colors.labelText, + style = Stroke(width = EDGE_STROKE, pathEffect = INACTIVE_DASH_EFFECT), + ) + } } } @@ -1013,10 +1093,10 @@ private fun DrawScope.drawEdgePaths( * Draws every outcome label in a second pass, after all curves, so a * neighbouring edge can never be drawn across a label. Each label sits on its * own edge's stored [EdgeLayout.labelPoint] (the edge's own lane/track), so - * distinct outcomes never overprint. Executed edges use a legible on-surface - * variant of their outcome colour (see [outcomeLabelColor]); dimmed edges use a - * muted colour on a near-opaque background instead of inheriting the curve's - * 0.25 alpha, which left the text unreadable. + * distinct outcomes never overprint. An executed edge's label uses its legible + * outcome colour (see [outcomeColor]); a not-executed edge's label uses a muted + * colour on a near-opaque background, matching its dashed stroke rather than + * inheriting a faded curve alpha, which left the text unreadable. */ private fun DrawScope.drawEdgeLabels( layout: GraphLayout, @@ -1025,7 +1105,7 @@ private fun DrawScope.drawEdgeLabels( textMeasurer: TextMeasurer, ) { for (edge in layout.edges) { - val executed = edge.isExecuted(runState) + val executed = edgeIsExecuted(edge.edge, runState) val textColor = if (executed) outcomeColor(edge.edge.outcome, colors) else colors.labelText val measured = textMeasurer.measure(edge.edge.label, TextStyle(fontSize = 11.sp, color = textColor)) val labelTopLeft = Offset( @@ -1085,42 +1165,61 @@ private fun DrawScope.drawNodes( textMeasurer: TextMeasurer, ) { for (node in layout.nodes) { - val executed = runState == null || node.key in runState.visitedStages + val executed = stageIsExecuted(node.key, runState) val selected = node.key == selectedStage - val alpha = if (executed) 1f else 0.3f val kind = graphNodeKind(node.terminal, node.key, stageTypeByKey[node.key]) - val fill = when { - kind == GraphNodeKind.TerminalFailure -> colors.terminalErrorFill - kind == GraphNodeKind.TerminalSuccess -> colors.terminalFill - selected -> colors.nodeFillActive - kind == GraphNodeKind.Ntfy -> colors.nodeNtfyFill - kind == GraphNodeKind.Custom -> colors.nodeCustomFill - else -> colors.nodeFill - }.copy(alpha = alpha) - val border = when (kind) { - GraphNodeKind.TerminalFailure -> colors.error - GraphNodeKind.TerminalSuccess -> colors.success - else -> if (selected) colors.nodeBorderActive else colors.nodeBorder - }.copy(alpha = alpha) - val textColor = if (!node.terminal && selected) colors.nodeTextActive else colors.nodeText val topLeft = Offset(node.x, node.y) - drawRoundRect( - color = fill, - topLeft = topLeft, - size = Size(node.width, node.height), - cornerRadius = androidx.compose.ui.geometry.CornerRadius(14f, 14f), - ) - drawRoundRect( - color = border, - topLeft = topLeft, - size = Size(node.width, node.height), - cornerRadius = androidx.compose.ui.geometry.CornerRadius(14f, 14f), - style = Stroke(width = if (selected && !node.terminal) 4f else 2f), - ) + val corner = androidx.compose.ui.geometry.CornerRadius(14f, 14f) + val borderWidth = if (selected && !node.terminal) 4f else 2f + val textColor: Color + if (executed) { + // Filled with a normal border, exactly as the definition-only view. + val fill = when { + kind == GraphNodeKind.TerminalFailure -> colors.terminalErrorFill + kind == GraphNodeKind.TerminalSuccess -> colors.terminalFill + selected -> colors.nodeFillActive + kind == GraphNodeKind.Ntfy -> colors.nodeNtfyFill + kind == GraphNodeKind.Custom -> colors.nodeCustomFill + else -> colors.nodeFill + } + val border = when (kind) { + GraphNodeKind.TerminalFailure -> colors.error + GraphNodeKind.TerminalSuccess -> colors.success + else -> if (selected) colors.nodeBorderActive else colors.nodeBorder + } + drawRoundRect( + color = fill, + topLeft = topLeft, + size = Size(node.width, node.height), + cornerRadius = corner, + ) + drawRoundRect( + color = border, + topLeft = topLeft, + size = Size(node.width, node.height), + cornerRadius = corner, + style = Stroke(width = borderWidth), + ) + textColor = if (!node.terminal && selected) colors.nodeTextActive else colors.nodeText + } else { + // Hollow and outlined: no fill (the surface shows through), a dashed + // muted border and a muted but legible label, so "not executed" is a + // shape and border-style difference rather than a faded node. A + // selected not-executed node keeps the stronger border colour. + val border = if (selected && !node.terminal) colors.nodeBorderActive else colors.labelText + drawRoundRect( + color = border, + topLeft = topLeft, + size = Size(node.width, node.height), + cornerRadius = corner, + style = Stroke(width = borderWidth, pathEffect = INACTIVE_DASH_EFFECT), + ) + textColor = colors.labelText + } val label = "[" + node.label + "]" val measured = textMeasurer.measure( label, - TextStyle(fontSize = 13.sp, fontWeight = FontWeight.Medium, color = textColor.copy(alpha = alpha)), + TextStyle(fontSize = 13.sp, fontWeight = FontWeight.Medium, color = textColor), ) // Pre-measured layout avoids the scope-relative width constraint crash and // the redundant re-measure of the string overload. @@ -1148,8 +1247,20 @@ internal fun outcomeColor(outcome: String, colors: GraphColors): Color = when (o else -> colors.palette[GraphPalette.outcomeColorIndex(outcome)] } -/** True when [runState] is null (definition view) or recorded this edge's route. */ -private fun EdgeLayout.isExecuted(runState: RunGraphState?): Boolean = +/** + * True when no run is selected (the definition-only view) or [key] was visited + * by the selected run. Pure, so graph drawing and the unit tests share one + * definition of "executed". + */ +internal fun stageIsExecuted(key: String, runState: RunGraphState?): Boolean = + runState == null || key in runState.visitedStages + +/** + * True when no run is selected (the definition-only view) or the selected run + * recorded [edge]'s route. Pure, so graph drawing and the unit tests share one + * definition of "executed". + */ +internal fun edgeIsExecuted(edge: GraphEdge, runState: RunGraphState?): Boolean = runState == null || GraphRoute(edge.source, edge.outcome, edge.target) in runState.takenRoutes /** A screen-reader description so meaning is never conveyed by colour alone. */ @@ -1157,7 +1268,7 @@ private fun graphDescription(graph: Graph, runState: RunGraphState?): String { if (graph.stages.isEmpty()) return "Empty workflow graph" val builder = StringBuilder("Workflow graph with ${graph.stages.size} stages. ") for (stage in graph.stages) { - val executed = runState == null || stage.key in runState.visitedStages + val executed = stageIsExecuted(stage.key, runState) builder.append("Stage ${stage.key}") if (runState != null) builder.append(if (executed) ", executed" else ", not executed") builder.append(". ") @@ -1178,6 +1289,25 @@ private const val MAX_SCALE = 3f private val FIT_PADDING = 16.dp private val MIN_VISIBLE = 48.dp +/** + * Line-style tokens shared by the graph and its legend. An executed stroke is + * solid; a not-executed stroke is dashed with [INACTIVE_DASH_INTERVALS] on/off + * pixels, so the two states differ by shape, not by a faded tint. + */ +private const val EDGE_STROKE = 3f + +/** The dash pattern (on/off, px) for every not-executed stroke; pure data. */ +internal val INACTIVE_DASH_INTERVALS = floatArrayOf(14f, 10f) + +/** The dashed effect for not-executed strokes, built once, never per frame. */ +private val INACTIVE_DASH_EFFECT: PathEffect by lazy { + PathEffect.dashPathEffect(INACTIVE_DASH_INTERVALS) +} + +/** Legend swatch geometry: a compact line, not a graph-layout token. */ +private val LEGEND_SWATCH_WIDTH = 22.dp +private val LEGEND_SWATCH_HEIGHT = 10.dp + /** * Collapsed graph-panel height, shared by both detail screens (one source for * the former 360.dp / 340.dp literals). ~58% of the window height so the graph diff --git a/android/app/src/main/java/net/awan/pipelines/ui/screens/RunDetailScreen.kt b/android/app/src/main/java/net/awan/pipelines/ui/screens/RunDetailScreen.kt index 1c879a9a..fb1cb472 100644 --- a/android/app/src/main/java/net/awan/pipelines/ui/screens/RunDetailScreen.kt +++ b/android/app/src/main/java/net/awan/pipelines/ui/screens/RunDetailScreen.kt @@ -385,7 +385,7 @@ private fun RunGraphTab( Text("This server did not include the run graph.", style = text.meta) } else { Text( - "Executed stages and routes are highlighted; the rest are dimmed. Pinch to zoom, drag to pan, tap a stage for details.", + "Executed stages and routes are solid; not-executed ones are dashed and outlined. Pinch to zoom, drag to pan, tap a stage for details.", style = text.meta, ) WorkflowGraph( diff --git a/android/app/src/test/java/net/awan/pipelines/ui/graph/WorkflowGraphTest.kt b/android/app/src/test/java/net/awan/pipelines/ui/graph/WorkflowGraphTest.kt index f75ca759..aa643456 100644 --- a/android/app/src/test/java/net/awan/pipelines/ui/graph/WorkflowGraphTest.kt +++ b/android/app/src/test/java/net/awan/pipelines/ui/graph/WorkflowGraphTest.kt @@ -4,9 +4,13 @@ import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Size import androidx.compose.ui.unit.Density import net.awan.pipelines.data.protocol.Graph +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.data.protocol.Stage +import net.awan.pipelines.data.protocol.edges import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse import org.junit.Assert.assertNull import org.junit.Assert.assertTrue import org.junit.Test @@ -484,6 +488,60 @@ class WorkflowGraphTest { } } + /** + * The executed/inactive predicates are the one definition of the two states: + * the definition-only view (no run) is entirely executed, and under a run + * only the visited stages and recorded routes are. + */ + @Test + fun executedPredicatesSeparateDefinitionViewFromaRun() { + val graph = sampleGraph() + val taken = graph.edges().first { it.source == "planner" && it.outcome == "success" } + val notTaken = graph.edges().first { it.source == "planner" && it.outcome == "error" } + + // No run selected: every stage and route is executed (definition view, + // unchanged today). + assertTrue(stageIsExecuted("planner", null)) + assertTrue(stageIsExecuted("ui_reviewer", null)) + assertTrue(edgeIsExecuted(taken, null)) + + val runState = RunGraphState( + visitedStages = setOf("planner", "implementer"), + takenRoutes = setOf(GraphRoute("planner", "success", "implementer")), + currentStage = "implementer", + ) + assertTrue(stageIsExecuted("planner", runState)) + assertTrue(stageIsExecuted("implementer", runState)) + assertFalse(stageIsExecuted("reviewer", runState)) + assertFalse(stageIsExecuted("#success", runState)) + assertTrue(edgeIsExecuted(taken, runState)) + assertFalse(edgeIsExecuted(notTaken, runState)) + } + + /** + * 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 + * from the solid executed one. + */ + @Test + fun inactiveDashPatternIsARealDashRhythm() { + assertTrue(INACTIVE_DASH_INTERVALS.isNotEmpty()) + assertEquals(0, INACTIVE_DASH_INTERVALS.size % 2) + assertTrue(INACTIVE_DASH_INTERVALS.all { it > 0f && it.isFinite() }) + } + + /** + * The one-line legend names both states, executed first, with exactly one + * entry flagged executed so the two swatches cannot both claim solid. + */ + @Test + fun legendNamesBothStatesWithExecutedFirst() { + assertEquals(listOf("Executed", "Not executed"), GRAPH_LEGEND.map { it.label }) + assertTrue(GRAPH_LEGEND.first().executed) + assertFalse(GRAPH_LEGEND.last().executed) + assertEquals(1, GRAPH_LEGEND.count { it.executed }) + } + private fun assertNoSharedRuns(layout: GraphLayout) { val edges = layout.edges for (i in edges.indices) {