Cross-fade loading, empty and error states in data-backed panes

A data-backed pane swapped its loading spinner, empty message, error
message and content with a plain `when`, so content flashed from empty to
full and empty/error states popped.

Introduce a shared presentation model in ui/components/States.kt:
- `LoadPhase` (Loading, Error(message), Empty(message), Content), with
  message-carrying phases capturing their text at classification so a
  fading-out branch never recomposes against cleared error/filter state.
- `listLoadPhase(loading, error, hasData, emptyMessage)` and
  `detailLoadPhase(error, hasData)` pure classifiers preserving the
  existing precedence (failed load with no data, then loading, then
  empty, else content; stale data keeps the pane on content).
- `StateCrossfade(phase)` wraps the branch in a `Crossfade` using the
  existing `MotionStandard` token; both branches share one box so the
  resting layout is unchanged and the outgoing phase fades under the
  incoming one.

Apply to PipelineListScreen, RunHistoryScreen, PipelineDetailScreen and
RunDetailScreen. Detail panes render the fading-out branch from the last
non-null item. The Runs pane keeps its inline empty/error line inside the
list, now fading through animateListItem().

Add LoadPhaseTest covering the classifiers and captured messages, and
document the change and evidence in android/README.md.
This commit is contained in:
2026-10-16 10:45:27 +01:00
parent 934994d7f7
commit b89ad29c41
7 changed files with 454 additions and 123 deletions
+83
View File
@@ -2086,3 +2086,86 @@ Not verified in this pass: a narrow-window frame of the item animation; an item
leaving a list (a run being deleted is not a client action), only the
appear/move halves driven above.
## Loading, empty and error states cross-fade (16 Oct 2026)
A data-backed pane used to swap its loading spinner, empty message, error message
and content with a plain `when`, so content flashed from empty to full and an
empty or error state popped. Every pane now swaps through one shared
`StateCrossfade` (`ui/components/States.kt`) — a `Crossfade` on the pane's
classified state using the already-named `MotionStandard` token. No dependency,
geometry token or literal was added.
- **`LoadPhase`** is the mutually exclusive presentation state: `Loading`,
`Error(message)`, `Empty(message)`, `Content`. The message-carrying phases keep
the text they were classified with, so the branch that is fading out is never
recomposed against a since-cleared error or a since-changed filter.
- **`listLoadPhase(loading, error, hasData, emptyMessage)`** and
**`detailLoadPhase(error, hasData)`** are the pure classifiers. A list pane
reports a failed load with no data, then a load with no data, then empty, else
content; a detail pane has no empty state, so data present is content, then a
reported error, then loading. Stale data keeps a pane on `Content` (the screen
shows the error inline), exactly as before — only the presentation changed.
- **`StateCrossfade(phase)`** wraps the branch in a `Crossfade` with
`MotionStandard.spec()`; both branches are laid out in one box, so the resting
layout is exactly the branch's own layout and the outgoing phase fades under
the incoming one. Applied to `PipelineListScreen`, `RunHistoryScreen`,
`PipelineDetailScreen` and `RunDetailScreen`. `LoadingState`, `ErrorState` and
`EmptyState` themselves are unchanged.
- The detail panes render the fading-out branch from the last non-null item
(`rememberPaneContent`, the same helper the closing pane uses), so selecting
another pipeline/run fades the old content out instead of blanking it.
- The Runs pane has no pane-level empty state — an empty list keeps its usage
block and sticky headers and shows its `No runs have been recorded yet.` line
inside the list, where it now fades in/out through the existing
`animateListItem()`, as does its inline error line.
Evidence (macOS, JDK 17 from Homebrew `openjdk@17`, Gradle 9.7.1,
`ANDROID_HOME=~/Library/Android/sdk`, `--offline`):
- `gradle :app:assembleDebug :app:testDebugUnitTest --console=plain` →
`BUILD SUCCESSFUL`; `--rerun-tasks` re-ran all 23 result XMLs to **184 tests, 0
failures, 0 errors, 0 skipped** (up from 174; the new `LoadPhaseTest` adds 10
pure cases for the classifiers and the message-carrying phases).
`app/build/outputs/apk/debug/app-debug.apk` is 17,913,089 bytes, sha256
`e99bb970…`.
- On `emulator-5554` only (fold AVD, 2076x2152 / 390dpi; **never** the attached
Pixel, never `emulator-5556`), against the live server, each frame captured and
validated with `scripts/capture_png.sh -s emulator-5554`, `animator_duration_scale`
used only to slow the capture:
- **Loading → content** at `animator_duration_scale 10`
(`load-to-content-10x.mp4`, `load-to-content-10x-sheet.png`): selecting a
pipeline shows `Loading pipeline…` and the summary then fades in;
`load-to-content-10x-overlap.png` freezes the cross-fade with the loading text
(`…ding pip…`) and the dimmed summary visible together, instead of a flash.
- **Empty appearing and going away** at scale 10
(`empty-appear-disappear-10x-sheet.png`): typing `zzz` into the pipelines
search makes `No pipelines match "zzz".` fade in, and clearing it fades the
list back.
- **Error → content** at scale 10 (`error-to-content-recovery-10x-sheet.png`):
with the connection down the Runs pane showed the error state; after the
connection returned, pressing Retry fades the error out and the loaded runs
(usage block, day groups) in.
- **Animations disabled** (`animator_duration_scale 0`): `disabled-empty-sheet.png`
(same type/clear) and `disabled-content-sheet.png` (open a pipeline) are each
fully settled on every frame — no ghosted or half-placed state, i.e. the swap
is instant with no special case.
- **Resting layout**: a settled Pipelines list captured at scale 1 and at scale
0 is pixel-identical (`captures/imgdiff.py` → `([0.0, 0.0, 0.0], 0.0)`), so the
cross-fade never alters the settled layout.
- `adb -s emulator-5554 logcat -d` held 0 `FATAL EXCEPTION` / 0
`E AndroidRuntime` lines; `animator_duration_scale` was left at 1; no run was
started from the app.
- **APK publish.** `app-debug.apk` copied to
`~/.local/share/pipelines/data/artifacts/106/1/pipelines-debug-wip-934994d.apk`
(`934994d` = `git rev-parse --short HEAD`; the working tree is uncommitted WIP on
top of it), sha256 `e99bb970…`. `curl
http://10.0.0.75:8080/artifacts/106/1/pipelines-debug-wip-934994d.apk` returned
`HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
`Content-Length: 17913089`, and a streamed `GET | shasum -a 256` returned the
same `e99bb970…` (`10.0.0.249` served it too; at 17.1 MiB it exceeds the 8 MiB
per-file inventory cap, so it is served by direct URL only).
Not verified in this pass: a narrow-window frame (the fold inner display is
851dp wide); the error state's fade-in from loading (the disconnected load failed
before a loading frame could be drawn, only its fade-out was captured).