Show live elapsed time for running runs
A running run now shows how long it has taken so far instead of its start time, kept live: the runs-list meta row, the pipeline list's last-run line and the run detail summary's Duration row all read one shared rule, runDurationText (ui/Format.kt), which reports the elapsed while executing and keeps the stored total once the run has finished. The elapsed is derived from the server's own start timestamp against a single shared clock, rememberLiveNowMillis/hostResumed (ui/components/LiveTime.kt), so it stays correct after a reconnect and never ticks while the app is backgrounded or while no shown run is executing. WorkflowGraph's private lifecycle read and once-a-second loop are replaced by that same shared pair. A missing start omits the value and a future start (clock skew) reads as 0s. Unit tests (FormatTest, PipelineLastRunTest) cover a run that has just started, the minute and hour boundaries, a missing and a future start, and a finished run keeping its stored total duration.
This commit is contained in:
@@ -256,6 +256,16 @@ stops it.
|
||||
clamped to two lines. The raw `resultPreview` is no longer printed, and
|
||||
progress is shown honestly (completed visits + current stage, with an
|
||||
indeterminate indicator while executing; no invented total).
|
||||
- A run still in progress shows the time it has taken so far instead of a
|
||||
finished duration, everywhere a run's time appears: the runs list meta row,
|
||||
the pipeline list's last-run line and the run detail summary's Duration row. A
|
||||
running value is live — recomputed once a second from the server's own
|
||||
`created_at` (never from when the app loaded, so it stays correct after a
|
||||
reconnect), using the shared `runDurationText` and a single ticking clock per
|
||||
screen (`ui/components/LiveTime.kt`) that pauses while the app is backgrounded
|
||||
and while no shown run is executing. Once the run finishes it keeps its stored
|
||||
total duration; a missing start omits the value and a future start (clock skew)
|
||||
reads as `0s` (`FormatTest`, `PipelineLastRunTest`).
|
||||
- One centralised type scale (`ui/theme/Typography.kt`, passed to
|
||||
`MaterialTheme` and exposed as named roles) defines the screen/app-bar title,
|
||||
section header, card title, subtitle/meta, body and monospace data, applied on
|
||||
@@ -1294,6 +1304,101 @@ has exactly three pane levels (`MasterPane.List/Detail/Stage`, `MAX_PANE_DEPTH =
|
||||
centred lines and ellipsizes (e.g. `Pipelines maintenance - plan implem…`) rather
|
||||
than being rotated.
|
||||
|
||||
## Covered panes carry a compact statistics block (16 Oct 2026)
|
||||
|
||||
A covered pane's compact identity is no longer a bare title/subtitle: it now
|
||||
shows a small vertical block of labelled statistics, aggregated client-side from
|
||||
the run history the app already receives, degrading with the strip's width.
|
||||
`android/` only; nothing in the Pipelines server, its Go source, the
|
||||
Docker/compose files or the installer was touched, no dependency was added (the
|
||||
declared `material-icons-extended` is unchanged), no run was started from the app
|
||||
and no server field was added.
|
||||
|
||||
- **Pipeline statistics.** When the covered pane is a pipeline
|
||||
(`PipelineDetailScreen`, and `RunDetailScreen` through its run's pipeline) the
|
||||
block shows the run counts (`runs`/`succeeded`/`failed`/`active`), the last
|
||||
run's status and how long ago it started, and the average duration over the
|
||||
runs that finished. `ui/screens/PaneStats.kt` folds the history in one pass; the
|
||||
counts mirror the server's own vocabulary (`active` = queued/running, per
|
||||
`internal/pipeline/stats.go`) and a still-running run never drags the average.
|
||||
A run pane whose run (and so whose pipeline) has not loaded yet stays
|
||||
title-only: an absent pipeline id is "not known yet", never the whole history,
|
||||
so it can never show the server-wide summary as if it were the run's pipeline.
|
||||
- **List statistics.** When the covered pane is a list, `PipelineListScreen` and
|
||||
`RunHistoryScreen` show the whole history's counts by status and the single most
|
||||
recent run; a runs list scoped to one pipeline shows that pipeline's own
|
||||
numbers.
|
||||
- **Width degradation.** `PaneIdentity` measures its own strip and shows the title
|
||||
only below one peek width, the run counts up to
|
||||
`MIN_COVERED_PANE_WIDTH_DP + PEEK_WIDTH_DP`, and the full block above it, so a
|
||||
thin peek drops whole labelled statistics instead of clipping a number or
|
||||
printing an unlabelled figure. Each statistic is a label above its own value, so
|
||||
the number never shares a line with a label that could clip it. The boundaries
|
||||
reuse the named geometry tokens and the decision is the pure
|
||||
`paneStatTier`/`visiblePaneStats` pair.
|
||||
- **One recency rule.** The "most recent run" comparison is the shared
|
||||
`isMoreRecent` helper, used by the single-pass `latestRunByPipeline` join and by
|
||||
the covered summary's own fold, so the pipeline row's last-run badge, the "most
|
||||
recent run" sort and the covered summary all agree on which run is the latest
|
||||
without grouping the history into intermediate lists.
|
||||
- **Two aggregation entry points.** `ui/screens/PaneStats.kt` exposes
|
||||
`pipelineStatLines(runs, pipelineId, now)` for the pipeline-scoped panes and
|
||||
`listStatLines(runs, now)` for the list panes, so "which statistics, from which
|
||||
history, or none until it has loaded" lives in one place instead of at each
|
||||
call site and a null pipeline id can never be mistaken for the whole history.
|
||||
The fold is a single pass (`RunTally.add` tracks the counts, the finished-run
|
||||
duration total and the most recent run together), so a scoped pipeline summary
|
||||
never allocates a filtered list or walks the history twice.
|
||||
|
||||
Evidence (macOS, JDK 17 from Homebrew `openjdk@17`, the cached Gradle 8.11.1
|
||||
distribution, `ANDROID_HOME=~/Library/Android/sdk`, `--offline`):
|
||||
|
||||
- `:app:testDebugUnitTest :app:assembleDebug --offline --console=plain` →
|
||||
`BUILD SUCCESSFUL in 2s` (41 actionable tasks: 8 executed, 33 up-to-date). The
|
||||
result XMLs total **279 tests, 0 failures, 0 errors, 0 skipped** across 32
|
||||
files; `app/build/outputs/apk/debug/app-debug.apk` is 18,204,486 bytes, sha256
|
||||
`196c9d6f4acbcc75769fd52ecadac66378bad78994056895f26ff65da077718c`. The
|
||||
`PaneStatsTest` (15 cases) covers the per-pipeline counts, queued as active, the
|
||||
last run's state/age, the average over finished runs, zero-duration runs, a
|
||||
pipeline with no runs, an unknown pipeline id, the whole-history list fold and
|
||||
the labelled lines, and that an absent/unknown pipeline id yields no lines
|
||||
rather than the list summary; the `PaneIdentityTest` (5 cases) pins the width
|
||||
tiers, that the counts tier drops only the detail lines, and that every shown
|
||||
statistic keeps its label and value.
|
||||
- **APK publish.** `app-debug.apk` was copied to
|
||||
`~/.local/share/pipelines/data/artifacts/142/3/pipelines-debug-wip-c700b28.apk`
|
||||
(`c700b28` = `git rev-parse --short HEAD`; the tree is uncommitted WIP on top of
|
||||
it); `shasum -a 256` matched the built file (`196c9d6f…`). `curl -I
|
||||
http://10.0.0.249:8080/artifacts/142/3/pipelines-debug-wip-c700b28.apk` returned
|
||||
`HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
|
||||
`Content-Length: 18204486`.
|
||||
- **Device evidence (emulator-5554).** The debug APK was installed with
|
||||
`adb -s emulator-5554 install -r` (never the attached Pixel, never
|
||||
`emulator-5556`) against the live LAN server, and the wide and narrow layouts
|
||||
were captured with `adb -s emulator-5554 shell screencap -p /sdcard/cap.png`
|
||||
then `adb -s emulator-5554 pull`. Captures are in the same artifacts directory:
|
||||
`wide-1-level-runs-list.png`, `wide-2-levels-covered-list-stats.png`,
|
||||
`wide-3-levels-covered-stats.png` (plus `…pane0…`/`…pane1…` crops) and
|
||||
`narrow-runs-list.png`. OCR of the covered strips confirms the block: at two
|
||||
levels the covered runs list reads `Runs / runs 145 / succeeded 90 / failed 39 /
|
||||
active 6 / last running - 4m ago` (Full tier); at three levels its two covered
|
||||
strips (82 dp and 112 dp wide) drop the `last` line and keep only the labelled
|
||||
counts, and the covered run strip reads the run's own pipeline id 11 numbers
|
||||
(`runs 60 / succeeded 37 / failed 14 / active 5`) — clearly not the server-wide
|
||||
145, so an unknown pipeline can no longer borrow the list summary. Four levels
|
||||
remain unreachable: `MAX_PANE_DEPTH = 2` gives exactly three pane levels, so the
|
||||
three-covered degradation is captured instead.
|
||||
- **Device-instruction conflict.** The run's Constraints said use `emulator-5554`
|
||||
exclusively and never the operator's physical device; an appended paragraph said
|
||||
to use the attached Pixel and never an emulator. There is no path that satisfies
|
||||
both, and installing this WIP build on the operator's own phone is forbidden by
|
||||
the task, so the emulator named in the Constraints was used (with the
|
||||
`device.lock` held) and the Pixel and `emulator-5556` were never touched. While
|
||||
capturing, another lane repeatedly overwrote the installed APK on
|
||||
`emulator-5554` (the installed hash reverted from this build to
|
||||
`2adaf03e…`/`5912d38f…` at 16:18 and 16:20 until reinstalled), which is why the
|
||||
APK hash was re-checked immediately before the captures that are reported here.
|
||||
|
||||
## Run stage pane leads with the run's results (16 Oct 2026)
|
||||
|
||||
A stage opened from a run no longer leads with its own definition. The pane now
|
||||
@@ -3441,3 +3546,119 @@ native 2208x1840 @420 at the end.
|
||||
returned `HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
|
||||
`Content-Length: 17928873`.
|
||||
|
||||
|
||||
## Remembering the list scroll position (16 Oct 2026)
|
||||
|
||||
Returning from a pipeline or a run now restores the list to exactly where the
|
||||
operator left it — the same item at the same offset, on either window width — and
|
||||
the position also survives a configuration change, rotation and process death.
|
||||
`android/` only; nothing in the Pipelines server, its Go source, the
|
||||
Docker/compose files or the installer was touched, no dependency was added (the
|
||||
declared `material-icons-extended` is unchanged), no run was started from the app
|
||||
and no server field was added.
|
||||
|
||||
- **Root cause.** A covered pane is a different composition from an open one: when
|
||||
a detail opens on a wide window, pane 0 stops drawing its list and draws its
|
||||
compact identity in a strip instead, so the list screen (and any scroll state it
|
||||
owned) was discarded, and backing out rebuilt it at the top. The runs
|
||||
destination is additionally recreated by the `NavHost` when the app-level runs
|
||||
selection changes. The fix owns each list's scroll state at the app shell, above
|
||||
the `NavHost` (`PipelinesApp`), and passes it into the list screens, so it is
|
||||
never inside the pane that comes and goes.
|
||||
- **One scroll state per list.** `PipelinesApp` holds
|
||||
`pipelineListState`/`runListState` with `rememberSaveable(saver = LazyListState.Saver)`
|
||||
and passes them to `PipelineDestination`/`RunsDestination` and on to
|
||||
`PipelineListScreen`/`RunHistoryScreen` (and `RunHistoryContent`), whose
|
||||
`LazyColumn` now takes that state. The same two screens serve both window widths
|
||||
and both entry points, so the runs list reached from a pipeline gets the same
|
||||
treatment as one opened normally.
|
||||
- **Restore and clamp rule.** `ui/components/ListScroll.kt` holds the pure
|
||||
`ListScrollAnchor(index, offset)` and `restoredScrollAnchor(anchor, itemCount)`
|
||||
(the saved index clamped to the nearest valid item, the offset kept only for the
|
||||
item that survived) plus the `RestoreListScroll(state, itemCount)` composable,
|
||||
which is keyed on the item count so it runs once when the list's size settles
|
||||
and never on the operator's own scrolling. A list that changed underneath (a
|
||||
filter, a sort, a refresh, items removed) therefore clamps to the nearest
|
||||
sensible item instead of jumping to the top or throwing, a scroll after coming
|
||||
back is never overridden, and a list that has not loaded yet is left alone so a
|
||||
restored position is not reset to the top while the data is still arriving.
|
||||
- **Runs list before it has loaded (fixed 16 Oct 2026).** The runs list has no
|
||||
pane-level empty state, so its first frame — before `LaunchedEffect {
|
||||
vm.refreshRuns() }` has set `loading` — was data-less, not-loading and classified
|
||||
as content. `RunHistoryContent` then composed an empty list whose only slot was
|
||||
the "no runs" line, and `RestoreListScroll` clamped the restored index to 0
|
||||
before the real list arrived: the runs list always came back at the top after
|
||||
process death (the pipelines list was spared only because its empty state was
|
||||
classified as a distinct `LoadPhase.Empty`). `listLoadPhase` now takes the
|
||||
pane's `loaded` signal (`LoadState.loaded`) and reads a data-less list that has
|
||||
never loaded as loading rather than empty, so the list — and its restored
|
||||
position — is not composed until the history is actually in hand. Both list
|
||||
screens pass it.
|
||||
- **One source for the runs list body.** `RunHistoryScreen` no longer maintains a
|
||||
second, hand-written copy of the LazyColumn's item count. The pure
|
||||
`runListEntries(...)` builds the slots (the usage block, the single
|
||||
empty-or-grouped body and the optional inline error row) once, in layout order;
|
||||
the column renders exactly that list and `RestoreListScroll` clamps to its size,
|
||||
so the count can never drift from what is drawn. `RunListEntriesTest` pins the
|
||||
slot order, the stable keys and the count.
|
||||
|
||||
Evidence (macOS, JDK 17 from Homebrew `openjdk@17`, cached Gradle 8.11.1
|
||||
distribution, `ANDROID_HOME=~/Library/Android/sdk`, every Gradle command with
|
||||
`--no-daemon --offline --console=plain`):
|
||||
|
||||
- `:app:clean :app:testDebugUnitTest :app:assembleDebug` → `BUILD SUCCESSFUL`;
|
||||
the tests were then re-executed with `:app:testDebugUnitTest --rerun-tasks`
|
||||
(not served from the build cache). The result XMLs total **292 tests, 0
|
||||
failures, 0 errors, 0 skipped** across 34 files. `ListScrollTest` (6 cases)
|
||||
pins the restore/clamp rule (in-range item keeps its index and offset, the last
|
||||
item keeps its offset, a shrunken list clamps to its last item and drops the
|
||||
offset, a negative index clamps to the top, an empty list stays at the top); the
|
||||
two new `LoadPhaseTest` cases pin that a data-less list that has never loaded
|
||||
reads as loading while the default keeps the old rule; and `RunListEntriesTest`
|
||||
(5 cases) pins the runs body's slot order, stable keys and count.
|
||||
`app/build/outputs/apk/debug/app-debug.apk` is 18,011,393 bytes, sha256
|
||||
`13b8d2871e9ad522e0d5a826642cdf467a95939408bed519d952e83d5c8dbb02`.
|
||||
- `:app:lintDebug` aborts on only the two pre-existing `NewApi` errors for
|
||||
`android:windowLightNavigationBar` (minSdk 26) in `res/values/themes.xml` and
|
||||
`res/values-night/themes.xml`, which this change did not modify; no error or
|
||||
warning points at the scroll change.
|
||||
- **APK publish.** `app-debug.apk` was copied to
|
||||
`~/.local/share/pipelines/data/artifacts/157/1/pipelines-debug-wip-c700b28.apk`
|
||||
(`c700b28` = `git rev-parse --short HEAD`; the tree is uncommitted WIP on top of
|
||||
it); `shasum -a 256` matched the built file (`13b8d287…`). `curl -I
|
||||
http://10.0.0.249:8080/artifacts/157/1/pipelines-debug-wip-c700b28.apk` returned
|
||||
`HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
|
||||
`Content-Length: 18011393`.
|
||||
- **Device evidence (operator's Pixel 10 Pro Fold, `adb -s 58281FDCG000JF`, inner
|
||||
2076x2152 at the 330 density override ≈1006dp; narrow override `wm size
|
||||
1080x1920`).** The build was installed with `adb -s 58281FDCG000JF install -r`,
|
||||
driven against the live LAN server (`curl http://127.0.0.1:8080/healthz` →
|
||||
`{"healthy":true}`), and captured with `android/scripts/capture_png.sh -s
|
||||
58281FDCG000JF` (device-side `screencap` to a file, then `pull` — never
|
||||
`exec-out`), written to `~/.local/share/pipelines/data/artifacts/157/1/`. The
|
||||
scroll position is read from `uiautomator dump` as the first `run «id» · …` line
|
||||
(the runs list) or the first `id «n» · v…` line (the pipelines list):
|
||||
|
||||
| case | how driven | result |
|
||||
| --- | --- | --- |
|
||||
| pipelines, wide, open→back | scroll down (first row `id 6`), tap the pipeline, Back | same first row; `01_list_scrolled.png` vs `03_list_restored.png` differ in **no pixel** (`bbox None`) |
|
||||
| runs, wide, open→back | scroll down (first row `run 32 · 13 Oct 17:21`), tap the run, Back | same first row; `05_runs_scrolled.png` vs `06_runs_restored.png` differ in **no pixel** (`bbox None`) |
|
||||
| **runs, process death** | HOME, `adb -s 58281FDCG000JF shell am kill net.awan.pipelines` (`pidof` empty), restore the task from Recents | back on the Runs destination with the same first row `run 41 · 15 Oct 14:35`; `30_runs_before_death.png` vs `31_runs_after_death.png` differ only in the status bar (`bbox (138,67)-(289,95)`) |
|
||||
| runs, rotation | `user_rotation 1`, then `0` | same top row `run 10 · 11 Oct 16:01` after both |
|
||||
| pipelines, rotation | `user_rotation 1`, then `0` | same top row in landscape; the first flip re-laid the anchor onto the adjacent row (`id 6`→`id 11`) and was stable on the second and later flips — the list never returned to the top |
|
||||
| density, config change | `wm density 330`→`340`→`330` | same top row `run 10 · 11 Oct 16:01` |
|
||||
| pipelines, narrow | `wm size 1080x1920`; scroll, open a pipeline, Back | same first row `id 4`; `70_narrow_pipelines_before.png` vs `72_narrow_pipelines_after.png` differ in **no pixel** (`bbox None`) |
|
||||
| runs, narrow | `wm size 1080x1920`; scroll, open a run, Back | same first row `run 8 · 11 Oct 14:44`; only the status bar differs |
|
||||
| list shrank while open | pipelines scrolled to the bottom, then search `quick` | the two matches (`id 9`, `id 10`) are shown — clamped, not blank and not reset to the top — and the process stayed alive with no `FATAL EXCEPTION` in `logcat` |
|
||||
|
||||
For the open→back cases the top row and its pixel offset matched exactly (the
|
||||
screenshot diff isolates only the status-bar clock); rotation, the density
|
||||
change and process death restored the same destination and top row. `device.lock`
|
||||
was held for every `adb` command and released afterwards, and no run was started
|
||||
from the app.
|
||||
- **Not exercised.** `onOpenRun` from a pipeline detail is only reached through
|
||||
`StartRunDialog.onStarted` (after starting a run), which the task forbids, so the
|
||||
runs list reached that way is kept compiling and functional but not driven; it
|
||||
shares the one `runListState`, so it gets the same treatment as the normally
|
||||
opened runs list. A real hardware fold to the cover display was not exercised
|
||||
(narrow was produced with `wm size`).
|
||||
|
||||
Reference in New Issue
Block a user