Drop cube turns queued before a Reset or Show
In a task that names the cube explainer, run() in web/cube-view.js applies each queued turn when its swing ends, to whatever cube is current by then, while Reset and Show replaced the cube at once without cancelling those turns. Pressing either while a turn was still swinging therefore did not stick: R U R' U' interrupted by Reset ended scrambled on 21375642212111, and 21653471111312 shown the same way ended on 12673452213311, each with the old moves listed as its history. With this change both stay on the cube they asked for.



A generation counter records which cube a turn was asked for. Reset, and a Show whose code parses, bump it; a queued run checks it before it starts and again after each swing, the only wait inside its loop, and drops its remaining turns once it has moved. Dropping the turns rather than queueing Reset behind them keeps Reset immediate, and a code that cannot be read replaces nothing, so it still cancels nothing.
The new test in tests/browser/task-workspace.test.js stops the page's clock once the cube is up, so a swing ends only when the test moves the clock. It starts R U R' U' swinging, queues nine turns behind it, which run() applies at once, and interrupts both, first with Reset and then with Show, before running the clock on. It fails on main with every queued turn landing after the press (actual: "Moves so far: R U R' U' R U R U R U R U F U") and with either of the two checks removed, and with a 1.5 s stall inserted before the press it still catches the post-swing check removed, which the earlier real-time version of the test let pass.
Validation: the new test failed on 3bbbcf5 and passed 5 runs out of 5 on this branch; node --test tests/browser/task-workspace.test.js tests/browser/cube.test.js passed 112 of 112; ./scripts/test.sh browser passed 2411 of 2412, the one failure being a shorter caption after page scrolling leaves Jim below the toolbar, which fails the same way on 3bbbcf5 on this machine. The Rust lane does not build here (webrtc-sys); this pull request's CI passed on the previous head, which differs from this one only in the test (https://github.com/sysprog21/codetrial/actions/runs/41080247852), and so did a run on the fork before it was opened (https://github.com/YEH-YU-YANG/codetrial/actions/runs/41076128780). The captures come from Chromium through the task-workspace test harness, on 3bbbcf5 and on this branch.
Close #558
Summary by cubic
Fixes queued cube turns so they no longer land on a cube replaced by Reset or Show. Previously, turns queued mid-swing applied to whatever cube was current afterward, so R U R' U' interrupted by Reset ended scrambled and a shown code ended on a different code. Now turns asked before Reset or Show are dropped.
Bug Fixes
- Reset and Show bump a generation counter; a queued run checks it before starting and after each swing and drops its remaining turns.
- Dropping turns keeps Reset immediate, and a code that cannot be read replaces nothing, so it cancels nothing.
- Adds a browser test with a stopped clock that interrupts both swinging and instantly applied turns with Reset and Show.