Skip to content

Follow #job changes on the review page - #172

Merged
A21-devs merged 2 commits into
mainfrom
fix/review-page-hashchange
Dec 4, 2026
Merged

A21-devs merged 2 commits into
mainfrom
fix/review-page-hashchange

Conversation

@A21-devs

@A21-devs A21-devs commented Dec 4, 2026

Copy link
Copy Markdown
Owner

Closes #97.

What

  • hashchange listener: if the hash names a different job than the one shown, it calls watchFromHash(). That's the old startup function pulled out: the hash's job, or the newest job when the hash is empty (and a cleared view when the server has none).
  • watch(id, push): starting a job from the form and the "open the newer run" link now push a history entry. Before, every watch() used replaceState, so after starting two jobs there was only one entry and Back left the page instead of going to the first job. Startup and hash changes still replace. Neither call fires hashchange, so the listener only sees outside changes.
  • poll() keeps the id it asked about and drops the answer (and doesn't reschedule) if the shown job changed while the request was out. Without that, a request for job A still in flight could paint A over B after a switch, and restart A's timer.
  • Unknown job in the hash: it used to set the error and leave the previous job's status and clips on the page under "that job is gone". It now clears them (clearJob()) and shows the error with the job id. That case only came up on load before, when nothing else was shown.

Testing

  • uv run ruff check src tests, uv run pytest -q: 728 passed. New test_review_page_follows_the_hash checks the listener, the two pushing call sites and the stale-poll guards are in the page.
  • In a browser against a real serve instance, two jobs started from the form (syn60.mp4, then a copy named second.mp4, 1 clip each, no captions). History length went to 4.
    • Back: hash went to job A, status line syn60.mp4 - done, card syn60_clip01.mp4. Forward: back to second.mp4 and its clip.
    • Setting the hash to A by hand switched to A. An empty hash went to the newest job (B).
    • #nosuchjob: on the first try the error showed but B's card was still there. That's what the clearJob() change is for. After it: 0 cards, summary hidden, status job nosuchjob with the error. Setting a real id afterwards showed that job normally.
    • Started a third job and switched to A 0.7 s later, while it was still starting. Over the next 4 s the page kept showing syn60.mp4 - done, and a wrapped fetch counted 0 requests for the running job after the switch.

A hashchange listener switches to the job in the address bar, or the
newest one for an empty hash. Starting a job and the newer-run link
push a history entry so Back returns to the job shown before. A poll
that answers after a switch is dropped, and an unknown job clears the
previous job's clips instead of leaving them under the error.
@A21-devs A21-devs added the ui label Dec 4, 2026

@A21-devs A21-devs left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked the history handling: pushState/replaceState don't fire hashchange, so watch() can't loop through the listener, and the listener's !== currentJob check makes a hash set to the shown job a no-op. The stale-poll guard covers both the success and the error path, and neither one reschedules the old job's timer. Back to the page's first entry (no hash) goes to the newest job and rewrites that entry with its id, which is reasonable.

One real problem with the new paths:

}

// nothing to show: no job yet, or the hash was cleared and the server has none
function clearJob() {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither clearJob() nor the "no such job" branch re-enables the form's submit button. Only poll() does, when the shown job isn't active. So: start a job (button disabled), then paste #<old id> from before a server restart. The page says "that job is gone ... start a new one", but Make shorts stays disabled until a reload. Reproduced it: disabled right after submitting, still disabled 1.5 s and 20 s after switching to #nosuchjob. Before this PR that branch only ran on load, when the button had never been disabled. With nothing shown there's nothing to double-submit, so clearJob() should enable it.

@A21-devs

A21-devs commented Dec 4, 2026

Copy link
Copy Markdown
Owner Author

Fixed in the latest commit: clearJob() re-enables the form's button. It's called for an unknown job and when the hash is cleared on a server with no jobs. The page test now checks that clearJob does it.

Same browser check as in the review: submitted a job (button disabled), switched to #nosuchjob 0.6 s later. The button is enabled 1.5 s after the switch, 0 cards, and the "start a new one" error shows. Full suite 728 passed.

@A21-devs A21-devs left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second pass on 69eaf9b. The finding is fixed: clearJob() now enables the button, and both places that leave the page with no job (unknown id, and an empty hash on a server with no jobs) go through it. The submit handler disables the button again on the next start, so double-submit protection for a job that is shown is unchanged. Because the fix lives in clearJob, the no-jobs case is covered too, not just the unknown-id path from the repro. Nothing else changed. Clean.

@A21-devs
A21-devs merged commit 73fe558 into main Dec 4, 2026
4 checks passed
@A21-devs
A21-devs deleted the fix/review-page-hashchange branch December 4, 2026 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Review page ignores a changed #job id until reload

1 participant