Repository navigation
Follow #job changes on the review page - #172
Conversation
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
left a comment
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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.
|
Fixed in the latest commit: Same browser check as in the review: submitted a job (button disabled), switched to |
A21-devs
left a comment
There was a problem hiding this comment.
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.
Closes #97.
What
hashchangelistener: if the hash names a different job than the one shown, it callswatchFromHash(). 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, everywatch()usedreplaceState, 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 fireshashchange, 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.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. Newtest_review_page_follows_the_hashchecks the listener, the two pushing call sites and the stale-poll guards are in the page.serveinstance, two jobs started from the form (syn60.mp4, then a copy namedsecond.mp4, 1 clip each, no captions). History length went to 4.syn60.mp4 - done, cardsyn60_clip01.mp4. Forward: back tosecond.mp4and its clip.#nosuchjob: on the first try the error showed but B's card was still there. That's what theclearJob()change is for. After it: 0 cards, summary hidden, statusjob nosuchjobwith the error. Setting a real id afterwards showed that job normally.starting. Over the next 4 s the page kept showingsyn60.mp4 - done, and a wrappedfetchcounted 0 requests for the running job after the switch.