Modernise the workflow graph's visual language

Replace the old terminal-diagram look on the Graph tab with a tonal
surface language, keeping the same information and every outcome hue.

- Nodes: stages are rounded rectangles from MaterialTheme.shapes.medium,
  terminals become pills (height/2). Fills are tonal surfaces via the new
  pure tonalFill(surface, accent, fraction) with a soft outlineVariant
  border instead of a flat fill plus hard outline.
- Type: node names use the cardTitle role and outcome labels the label
  role, with theme line height/letter spacing; the [brackets] and all-caps
  are gone (nodeDisplayLabel renders Success/Failure title-cased in colour).
- Edges: StrokeCap.Round/StrokeJoin.Round, bends rounded by one
  ROUTE_CORNER_RADIUS (cornerCutRadius clamps short segments), filled
  arrowheads scaled as edgeStrokeWidth * ARROW_HEAD_SCALE, and labels on
  a shared DrawScope tonal chip.
- Spacing: named dp tokens instead of ad-hoc literals.

Adds pure-logic unit tests (WorkflowGraphTest, GraphPaletteTest) and
documents the change in android/README.md.

Verified: :app:assembleDebug and :app:testDebugUnitTest both BUILD
SUCCESSFUL (207 tests, 0 failures) with no Kotlin warnings.
This commit is contained in:
2026-10-16 11:50:08 +01:00
parent 8b39c087fd
commit e5bde981ee
4 changed files with 644 additions and 84 deletions
+278 -3
View File
@@ -122,7 +122,17 @@ stops it.
zoom is anchored to the gesture centroid: the pure `zoomAbout` keeps the
content point under the fingers fixed (clamped to `MIN_SCALE`/`MAX_SCALE`) and
the existing pan clamp is applied afterwards, so the content no longer slides
away from the fingers.
away from the fingers. The visual language is a modern surface, not a terminal
diagram: a stage is a rounded rectangle (the theme's `shapes.medium`) and a
terminal a pill, both filled with a tonal surface tinted with the node's
semantic hue behind a soft border (not a flat fill plus hard outline); the node
name and the outcome labels use the app's type scale (`cardTitle`/`label`, no
ad-hoc sizes, no all-caps, terminal `Success`/`Failure` in their own colour);
edges draw with round caps/joins and every right-angle bend is rounded by one
`ROUTE_CORNER_RADIUS` control offset over the unchanged stored polyline, with a
filled arrowhead proportional to its stroke and the outcome label on a rounded
tonal chip rather than raw text over the canvas; node and per-edge-track spacing
are named dp tokens.
- One shared graph-panel height (`collapsedGraphHeight`/`expandedGraphHeight`)
replaces the former 360.dp and 340.dp literals, so both detail screens render
the graph at the same size: about 58% of the window height floored at a height
@@ -1876,8 +1886,10 @@ never installed on or driven).
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.
a stronger, more saturated stroke and a filled arrowhead proportional to its
own width (`edgeArrowHeadSize`, i.e. `strokeWidth * ARROW_HEAD_SCALE` with
`ARROW_HEAD_SCALE = 4`: 28f for this 7f pass/fail stroke, 12f for a normal
executed route), 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.
@@ -1952,3 +1964,266 @@ 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.
## A modern visual language for the workflow graph (16 Oct 2026)
The graph read like an old terminal diagram (flat fills, hard outlines, sharp
right angles, `[bracketed]` all-caps labels, small arrowheads, raw text over the
canvas). This pass gives it a modern surface language without changing any
information or any hue. `android/` only; no dependency was added (the graph's
corner comes from the theme's own shape scale), 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 only modified tracked files are the four under `android/` shown in
`git status --short` below; the capture runs also leave untracked scratch
directories at the repo root (`.ui_review*/`), so a bare `git status --short` is
not clean and the "nothing outside `android/` touched" claim is only about the
change itself, not those untracked captures.
- **Nodes are rounded and tonal, terminals are pills.** `WorkflowGraph.kt` reads
`MaterialTheme.shapes.medium` once per composition for a stage's corner and
gives a terminal a full pill (`height/2`), so a terminal is visibly not a stage.
The fill is a *tonal surface*: the new pure `tonalFill(surface, accent,
fraction)` blends a raised `surfaceContainerHigh` with a subtle fraction of the
node's semantic colour (`NEUTRAL_TINT`/`KIND_TINT` for a stage by kind,
`TERMINAL_TINT` for a terminal's success/error hue), and the hard outline is
replaced by a soft `outlineVariant` border (`NODE_BORDER`, strengthened for a
selected stage with `NODE_BORDER_SELECTED`). Every kind's hue survives; the
terminal fill now genuinely tints the outcome hue.
- **Type comes from the app's scale.** The node name uses the app's `cardTitle`
role and the outcome labels its `label` role (no ad-hoc `13.sp`/`11.sp`), with
the theme's own line height and letter spacing; the `[brackets]` and the
all-caps `SUCCESS`/`FAILURE` are gone — the graph shows `Success`/`Failure` in
the terminal's own colour (the new pure `nodeDisplayLabel`; the shared
`GraphSemantics.nodeLabel` the TUI-mirroring panes use is untouched).
- **Edges are smoother, with one control offset and matched arrowheads.** The
stored route is still the axis-aligned polyline (`routePoints`, and its layout
tests, are unchanged), but drawing now rounds every right-angle bend with the
single `ROUTE_CORNER_RADIUS` control offset (the pure `cornerCutRadius` clamps a
short adjacent segment to half its length so two cut-backs can never meet),
uses `StrokeCap.Round`/`StrokeJoin.Round`, and scales the filled arrowhead to
the line with one `ARROW_HEAD_SCALE` (`edgeArrowHeadSize = edgeStrokeWidth *
ARROW_HEAD_SCALE`). Labels sit on a rounded *tonal chip* (`tonalFill` of the
raised surface with the label's own colour) instead of raw text over the canvas.
- **More breathing room, from named tokens.** Node width/height, the horizontal
gap, the graph padding, the per-edge lane spacing and track step, and the
terminal-row gap are now named dp tokens (no inline geometry literals); the
values grew so nodes and the per-edge tracks have visibly more room, and the
collapsed-panel floor grew to `320.dp` to still fit a 4-stage graph with its
terminal row.
- **Nothing semantic changed.** The executed/not-executed structural split (solid
full-colour + arrowhead vs dashed muted + no arrowhead; filled vs hollow/dashed
node), the pass/fail emphasis (heavier, same-hue, more-saturated stroke with the
largest head), the selected-stage invert, ntfy/custom/model kind tints, the
`error*` fallback label, the legend, the active halo/elapsed badge, the flow
dots and the screen-reader description are all kept. `graphColors` and
`outcomeColor` keep their field names, so the Timeline step chips that share
them still agree with the graph.
Verification (macOS, Homebrew JDK 25 `openjdk@25`, Gradle 9.7.1,
`ANDROID_HOME=/Users/alan/Library/Android/sdk`, `--offline`):
- `gradle --offline :app:testDebugUnitTest --rerun-tasks` → `BUILD SUCCESSFUL`;
the test-result XMLs aggregate to **207 tests, 0 failures, 0 errors, 0
skipped** (4 new: `WorkflowGraphTest` for the readable node labels, the
arrowhead proportional to its stroke and the corner-cut clamp, and
`GraphPaletteTest` for `tonalFill`). `compileDebugKotlin` emitted no warnings
(the deprecated `quadraticBezierTo` was replaced by `quadraticTo`).
- `gradle --offline :app:assembleDebug` → `BUILD SUCCESSFUL`; `app-debug.apk` is
**17,928,873 bytes**, sha256
`ba5bcc467989425b69aad2ae70799c0cf4d9eaf54be30243b4631fb7e94916b3`.
- On `emulator-5556` (`FoldB_API_36`, dark mode) against the live server
`ws://10.0.2.2:8080/connect`, driven with `adb shell input` and `uiautomator
dump`. Every capture was written with `android/scripts/capture_png.sh -s
emulator-5556` (validated PNG magic bytes, named display id) into
`~/.local/share/pipelines/data/artifacts/108/1/`. The three cases are a
definition-only graph (pipeline 3 "Plan, implement, review", 4 stages), a
partly executed run (run 94, failed at `committer`: `implementer`/`reviewer`/
`ui_reviewer` and the failed `committer` executed, `Success` not) and its
selected (current) stage. Widths: **wide** 2208x1840 @ density 420 (≈841dp) and **narrow**
1080x1920 @ density 480 (≈360dp); **2x** doubles the pixel size and density
(4416x3680 @840 and 2160x3840 @960), so the same dp layout is rendered at
double the pixels. "Before" is a clean `git archive 8b39c08` tree (never a
working-tree stash) built and installed; "after" is this tree.
- `{before,after}_wide_1x_definition.png`, `{before,after}_wide_2x_definition.png`,
`{before,after}_narrow_1x_definition.png`, `{before,after}_narrow_2x_definition.png`
— the definition graph; before shows `[planner]`/`[FAILURE]` rectangular
nodes with hard 90° routes and raw labels, after shows rounded, tonal nodes,
pill terminals and chipped labels.
- `{before,after}_wide_1x_run.png`, `{before,after}_wide_2x_run.png`,
`{before,after}_narrow_1x_run.png`, `{before,after}_narrow_2x_run.png` — run
94; `implementer`/`reviewer`/`ui_reviewer` were visited and the failed
`committer` was visited too (it was entered and then failed), so all four
stages are filled and the selected `committer` inverts (light `inverseSurface`
fill, solid primary border); the executed `success`/`error` routes are the
boldest lines, and the not-executed `Success` terminal is hollow with a dashed
border (the `Failure` terminal, reached by the executed `error` edge, is
filled). The invert applies only to an *executed* stage; a selected
*not-executed* stage is instead drawn hollow with a dashed primary border
(`drawNodes`' not-executed branch), so selection is legible in either state.
- `{before,after}_{wide,narrow}_{1x,2x}_selected.png` — a 2x crop of the
selected `committer` node (its primary border and rounded shape after vs the
sharper `[committer]` before).
- `compare_wide_1x_definition.png`, `compare_wide_1x_run.png`,
`compare_narrow_1x_definition.png`, `compare_narrow_1x_run.png` — stacked
before/after sheets for the 1x narrow and wide cases.
- `adb -s emulator-5556 logcat -d` contained 0 `FATAL EXCEPTION` and 0 `E
AndroidRuntime` lines after a fresh launch and a Runs/Graph sweep; no run was
started from the app. The emulator's display was reset to its native
2208x1840 @420 afterwards.
- **APK publish.** `app-debug.apk` was copied to
`~/.local/share/pipelines/data/artifacts/108/1/pipelines-debug-wip-8b39c08.apk`
(`8b39c08` = `git rev-parse --short HEAD`); `shasum -a 256` matched. `curl -I
http://10.0.0.249:8080/artifacts/108/1/pipelines-debug-wip-8b39c08.apk` (LAN
address from `ipconfig getifaddr en0`) returned `HTTP/1.1 200 OK`,
`Content-Type: application/vnd.android.package-archive`, `Content-Length:
17928873`, and a streamed `GET | shasum -a 256` returned the same `ba5bcc46…`
as the local file. At 17.1 MiB it 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` (its only reported issues are the two
pre-existing `NewApi` errors for `android:windowLightNavigationBar`); the light
theme; the active/animating halo, elapsed badge and flow dots (the run 94 graph
is a finished run, so it renders settled — those live-run visuals are unchanged
by this pass and are covered by `GraphMotionTest`); a real hardware fold
(narrow/wide were produced with `wm size`/`wm density`); and a greyscale pass (the
executed/not-executed distinction is still structural, but only colour captures
were taken). The crops are derived from the full captures with PIL; the
full-size PNGs above are the primary evidence.
### Review follow-up and re-verification (16 Oct 2026)
A follow-up pass addressed the review findings on the code above. The rendered
surface is unchanged (the token conversion maps the former pixel literals onto the
same device-scaled geometry), and `android/` is still the only modified tree; the
untracked `.ui_review*/` scratch captures at the repo root are not part of it.
- **Duplication.** The two near-identical rounded tonal chips (the edge outcome
labels and the active-stage elapsed badge) are now one
`DrawScope.drawTonalChip(textTopLeft, textSize, color)` helper; both call sites
pass the accent tinted into `labelBackground`, so the chip geometry lives once.
- **Redundant geometry.** `cornerCutRadius` now takes the adjacent segment lengths
the caller has already measured (`cornerCutRadius(inLength, outLength, radius)`),
so `roundedRoutePath` computes each corner's two `hypot`s once instead of twice.
- **Redundant width.** The new pure `arrowHeadSizeFor(strokeWidth)` is the one
arrowhead-from-stroke mapping; `drawEdgePaths` passes the width it has just
computed (`arrowHeadSizeFor(width)`) instead of re-deriving it, and
`edgeArrowHeadSize` delegates to the same function.
- **Geometry tokens.** `ROUTE_CORNER_RADIUS` (`7.dp`) and the chip
`EDGE_CHIP_PAD_X`/`EDGE_CHIP_PAD_Y`/`EDGE_CHIP_CORNER` (`2.dp`/`1.dp`/`2.dp`) are
dp tokens like the rest of the new graph geometry, not raw pixel literals.
Re-run checks (same environment as above):
- `gradle --offline :app:testDebugUnitTest` → `BUILD SUCCESSFUL`; the test-result
XMLs aggregate to **207 tests, 0 failures, 0 errors, 0 skipped** (the
`cornerCutRadius` test now exercises the length-based clamp).
- `gradle --offline :app:compileDebugKotlin --rerun-tasks` → `BUILD SUCCESSFUL`
with no `w:` warnings.
- `gradle --offline :app:assembleDebug --rerun-tasks` → `BUILD SUCCESSFUL`;
`app-debug.apk` is **17,928,873 bytes**, sha256
`ab99e734b0b190294ebfad8d342caf599286cefda23a0faf39f0244496e3af1a`. (A full
`--rerun-tasks` rebuild is byte-reproducible — two consecutive runs produced
this same hash — whereas incremental packaging is not, so the published APK is
the `--rerun-tasks` one.)
- Smoke captures on `emulator-5556` (native 2208x1840 @420) with the rebuilt APK
(`adb -s emulator-5556 install -r app/build/outputs/apk/debug/app-debug.apk`),
written via `android/scripts/capture_png.sh -s emulator-5556`:
`followup_wide_1x_definition.png` (the pipeline 3 definition graph) and
`followup_wide_1x_run106.png` (run 106, all four stages visited) in
`~/.local/share/pipelines/data/artifacts/108/3/`. Both render the rounded tonal
nodes, pill terminals and chipped labels; run 106 shows the executed stages
filled, the selected `committer` inverted (light fill, solid primary border) and
the not-executed `Failure` terminal hollow with a dashed border — the same
structural executed/not-executed split, unchanged. `adb -s emulator-5556 logcat
-d | grep -cE 'FATAL EXCEPTION|E AndroidRuntime'` is `0`; the display was not
resized (still native 2208x1840 @420).
- **APK publish (this pass).** The rebuilt APK was copied to
`~/.local/share/pipelines/data/artifacts/108/3/pipelines-debug-wip-8b39c08.apk`
(`8b39c08` = `git rev-parse --short HEAD`). `curl -I
http://10.0.0.249:8080/artifacts/108/3/pipelines-debug-wip-8b39c08.apk` returned
`HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
`Content-Length: 17928873`, and a streamed `GET | shasum -a 256` returned the
same `ab99e734…` as the local file.
### Second review follow-up (16 Oct 2026)
Two remaining findings on the modernised graph were fixed. The rendered surface is
unchanged — the first is a same-value refactor, the second a doc-only correction —
so the before/after captures above still describe the output.
- **One label colour, not two.** `drawEdgeLabels` declared `accent` and
`textColor` holding the identical value (both `outcomeColor(...)` when the edge
executed, else `colors.labelText`); they are now the single `labelColor`, used for
both the label text and its chip tint. No pixel changes.
- **README cites the live arrowhead token.** The dated "Pass/fail edges" section
cited the removed `PASSFAIL_ARROW_HEAD_SIZE = 20f`; it now describes the current
mapping (`edgeArrowHeadSize` = `strokeWidth * ARROW_HEAD_SCALE`, i.e. 28f
pass/fail and 12f normal), matching `WorkflowGraph.kt`.
Re-verified (Homebrew `openjdk@25`, Gradle 9.7.1,
`ANDROID_HOME=/Users/alan/Library/Android/sdk`, `--offline`):
- `gradle --offline :app:compileDebugKotlin --rerun-tasks` → `BUILD SUCCESSFUL`
with no `w:` warnings.
- `gradle --offline :app:testDebugUnitTest --rerun-tasks` → `BUILD SUCCESSFUL`;
the test-result XMLs aggregate to **207 tests, 0 failures, 0 errors, 0 skipped**.
- `gradle --offline :app:assembleDebug --rerun-tasks` → `BUILD SUCCESSFUL`;
`app-debug.apk` is **17,928,873 bytes**, sha256
`c95fab884d392a2b3df6170ec2e16ccc4fdf6f1fef4e946425f5dcda56c881a7`, reproducibly
(two consecutive `--rerun-tasks` rebuilds matched).
- Smoke captures on `emulator-5556` (native 2208x1840 @420) with this APK, written
via `android/scripts/capture_png.sh -s emulator-5556`:
`followup2_wide_1x_launch.png`, `followup2_wide_1x_definition.png` (pipeline 3)
and `followup2_wide_1x_run.png` (run 109, partly executed) in
`~/.local/share/pipelines/data/artifacts/108/5/`. The definition graph renders
rounded tonal stages, pill terminals (filled `Failure`/`Success`) and chipped
labels; run 109 fills the visited stages, inverts the selected `committer`
(light fill, solid primary border) and leaves the not-executed `Failure` terminal
hollow with a dashed border. `adb -s emulator-5556 logcat -d | grep -cE 'FATAL
EXCEPTION|E AndroidRuntime'` is `0`.
- **APK publish (this pass).** The rebuilt APK was copied to
`~/.local/share/pipelines/data/artifacts/108/5/pipelines-debug-wip-8b39c08.apk`
(`8b39c08` = `git rev-parse --short HEAD`); `curl -I
http://10.0.0.249:8080/artifacts/108/5/pipelines-debug-wip-8b39c08.apk` returned
`HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
`Content-Length: 17928873`.
### Re-verification with a fresh before/after capture set (run 117, 16 Oct 2026)
The source is unchanged from the sections above; this pass re-ran every check on
it and produced a fresh, complete before/after capture set in
`~/.local/share/pipelines/data/artifacts/117/1/`. `android/` remains the only
modified tree (the untracked `.caps117/` scratch captures at the repo root and the
older `.ui_review*/` directories are not part of the change). No run was started
from the app, only `emulator-5556` was ever addressed, and its display was reset to
native 2208x1840 @420 at the end.
- `gradle --offline :app:assembleDebug --rerun-tasks` → `BUILD SUCCESSFUL`;
`app-debug.apk` is **17,928,873 bytes**, sha256
`c95fab884d392a2b3df6170ec2e16ccc4fdf6f1fef4e946425f5dcda56c881a7` (identical to
the "Second review follow-up" build above).
- `gradle --offline :app:testDebugUnitTest --rerun-tasks` → `BUILD SUCCESSFUL`;
the test-result XMLs aggregate to **207 tests, 0 failures, 0 errors, 0 skipped**
(the new `tonalFill`, `nodeDisplayLabel`, `arrowHeadScalesWithTheStrokeItTerminates`
and `cornerCutNeverExceedsHalfTheShorterSegment` tests included).
- **Captures.** The same four display configurations as the first pass
(`wm size`/`wm density`: wide 2208x1840 @420 and its 2x 4416x3680 @840; narrow
1080x1920 @420 and its 2x 2160x3840 @840), each for the pipeline 3
definition-only graph and the partly executed run 109 (the selected `committer`),
written with `android/scripts/capture_png.sh -s emulator-5556`:
`{before,after}_{wide,narrow}_{1x,2x}_{definition,run}.png`, the 2x-upscaled
`{before,after}_{wide,narrow}_{1x,2x}_selected.png` node crops, and the stacked
`compare_{wide,narrow}_1x_{definition,run}.png` sheets. The `before` images were
rebuilt from `HEAD` (the four tracked files stashed, `assembleDebug`, captured,
then the stash popped and the after build reproduced the same sha256); they show
the sharp-cornered flat fills, `[bracketed]` all-caps labels and thin raw-text
routes, while the `after` images show the rounded tonal stages, pill terminals
(`Failure` hollow/dashed when not executed, `Success` filled) and chipped labels.
`adb -s emulator-5556 logcat -d | grep -cE 'FATAL EXCEPTION|E AndroidRuntime'`
is `0`.
- **APK publish (this pass).** Copied to
`~/.local/share/pipelines/data/artifacts/117/1/pipelines-debug-wip-8b39c08.apk`;
`curl -I http://10.0.0.249:8080/artifacts/117/1/pipelines-debug-wip-8b39c08.apk`
returned `HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
`Content-Length: 17928873`.