Skip to content

fix(frontend): keep a newer run on screen when a decision reload lands - #41

Merged
vbabenko97 merged 1 commit into
mainfrom
babenko/stale-run-reload
Sep 25, 2026
Merged

vbabenko97 merged 1 commit into
mainfrom
babenko/stale-run-reload

Conversation

@vbabenko97

Copy link
Copy Markdown
Collaborator

Summary

Fixes the stale-run reload race noted in #40. After an overseer approves or rejects, decideAndRefresh reloads the run that was on screen when they clicked. If a new run is submitted while that reload is in flight, the late response used to replace the new run on screen. Once the new run's polling had finished, the old run stayed there.

Change

  • frontend/app/decision.js: the reloaded run is applied with a functional state update, and only if the same run (same run_id) is still on screen. A newer run, whether still loading or already shown, is kept.
  • frontend/test/decision.test.js: two regression tests hold the reload open with a deferred promise. Meanwhile they submit a run, both still loading and already shown, then let the reload finish and check the newer run stays. The fake page's setRun now accepts updater functions, as React's does. No new dependencies.

Verification

Run locally on 32f2178:

  • npm test: 15/15 passed, including both regression tests
  • npm run build: passed
  • git diff --check: clean

Static trace: with the old direct setRun(reloaded), both new tests fail, because the approved run-1 replaces the newer run. The existing approve/reject tests still reload the displayed run.

decideAndRefresh re-reads the run that was displayed when the overseer
clicked approve/reject. If a new run was submitted while that reload
was in flight, the late response replaced the new run on screen; once
the new run's polling had finished, the old run stayed there.

The reload is now applied with a functional update that only replaces
the run still on screen (same run_id). Two regression tests hold the
reload open with a deferred promise, submit a run meanwhile (still
loading / already shown), and check the newer run is kept.
@vbabenko97
vbabenko97 merged commit f4c6134 into main Sep 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant