Files
pipelines/app/notes/live-run-durations.md
T

34 lines
2.0 KiB
Markdown

# Live run durations
Running runs and stages now show durations that update on their own, without a refresh.
- `lib/ui/text/elapsed_clock.dart` has one shared `ElapsedClock`. It runs a single
timer only while some label is watching, and only while the app is visible. The
timer wakes when the shortest watched duration would next change its text: every
second under an hour (`3m 5s`), every minute under a day (`1h 2m`), then every hour.
`ElapsedClockScope` lets tests inject a fake clock (`ElapsedClock(now: ...)`).
- `lib/ui/text/live_elapsed_builder.dart` rebuilds only its own subtree. With a null
`since` it watches nothing. It also stops watching while muted (an offstage tab or a
covered route) and catches up when shown again.
- Runs list: an executing row's fact lines tick (`run_list_row.dart`). The list's memo
no longer keys on the clock.
- Run detail: an executing run's Summary shows a ticking Duration fact
(`detailSummaryRows(run, now:)`). A running Timeline visit's time ticks too
(`DetailVisit.runningSince`).
- Status and finish times already arrive through `run_event` frames. The terminal
frame carries `finished_at`, so a row changes from a ticking duration to the
recorded one without a refresh. A step delta carries no `started_at`, so a stage
start re-reads the open detail (`runDetailLacksStepStart`).
- Bench budget (`test/perf/background_work_bench_test.dart`): with 20 visible running
rows there are 2 active timers (minute labels plus elapsed clock) and 61 timers
per minute. Before this change it was 1 timer, because running rows did not tick.
Evidence: `test/ui/text/elapsed_clock_test.dart` and
`test/features/runs/ui/run_live_duration_test.dart` use fake clocks. The browser
capture used `?running=1` on the full-app fixture, at `/runs` 880x1000. Seven
seconds apart, the row read `release-train · 3m 52s` and then
`release-train · 4m 0s`.
Not covered: the visit pane's Duration fact is still the recorded one. A `waiting`
run does not tick, which matches the list's existing rule.