viewer: follow a camera link opened in the open page (VIEWER-FOLLOW-CAM-LINK) #2329

Merged
leonida/mandy
syfyra merged 1 commit from feat/viewer-follow-cam-link into main 2026-12-01 15:18:55 +00:00

Pull request successfully merged and closed

syfyra commented 2026-11-26 13:53:29 +00:00

Claimed in the coordination issue as: VIEWER-FOLLOW-CAM-LINK

What and why

P copies a link to the current view (#cam=x,y,z,yaw,pitch), and the viewer reads that hash once, at startup. Opening such a link in a tab that already shows the viewer changes only the hash: the browser makes a same-document navigation, the page does not reload, and the camera stayed where it was. The same happened with Back and Forward between two links. A shared view therefore only worked in a fresh tab. The VIEWER-HUNT finding in #1608 noted this as an untested edge.

The viewer now applies the hash again on hashchange, through the same helper that applies it at startup. A hash that is not a camera link (empty, malformed, another fragment) leaves the camera where it is, as at startup. P uses history.replaceState, which fires no hashchange, so copying a link does not move the camera.

Tested

  • node --test tests/test_viewer_streaming.cjs (Node 26): a new test runs the whole viewer module with a link in the hash, checks that it places the camera, then fires hashchange with a second link (camera and look follow, pitch clamped as at startup) and with five hashes that are not camera links (nothing moves). On main the new test fails (no hashchange handler); with the change all 58 tests pass.
  • In the app's Chromium-based browser pane against viewer/serve.py (test terrain): setting the hash to a second link moves the HUD position there, #notacam leaves it, and Back twice returns to each earlier link.
  • Merges cleanly with #651, #918 and #2243, which also change viewer/index.html and this test file.
  • scripts/check_no_game_data.py on both files.

GPUs tested: n/a (viewer logic, Node harness)

AI-assisted: yes (Claude Code, Claude Opus 5.5)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

Claimed in the coordination issue as: VIEWER-FOLLOW-CAM-LINK ### What and why `P` copies a link to the current view (`#cam=x,y,z,yaw,pitch`), and the viewer reads that hash once, at startup. Opening such a link in a tab that already shows the viewer changes only the hash: the browser makes a same-document navigation, the page does not reload, and the camera stayed where it was. The same happened with Back and Forward between two links. A shared view therefore only worked in a fresh tab. The VIEWER-HUNT finding in #1608 noted this as an untested edge. The viewer now applies the hash again on `hashchange`, through the same helper that applies it at startup. A hash that is not a camera link (empty, malformed, another fragment) leaves the camera where it is, as at startup. `P` uses `history.replaceState`, which fires no `hashchange`, so copying a link does not move the camera. ### Tested - `node --test tests/test_viewer_streaming.cjs` (Node 26): a new test runs the whole viewer module with a link in the hash, checks that it places the camera, then fires `hashchange` with a second link (camera and look follow, pitch clamped as at startup) and with five hashes that are not camera links (nothing moves). On `main` the new test fails (no `hashchange` handler); with the change all 58 tests pass. - In the app's Chromium-based browser pane against `viewer/serve.py` (test terrain): setting the hash to a second link moves the HUD position there, `#notacam` leaves it, and Back twice returns to each earlier link. - Merges cleanly with #651, #918 and #2243, which also change `viewer/index.html` and this test file. - `scripts/check_no_game_data.py` on both files. GPUs tested: n/a (viewer logic, Node harness) AI-assisted: yes (Claude Code, Claude Opus 5.5) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
kurrutako commented 2026-11-26 14:15:44 +00:00

Verified at head 0370dc2a1 (merge-base is current main 73516a290, so the branch is up to date).

  • node --test tests/test_viewer_streaming.cjs on the PR: 58 of 58 pass, 3 of 3 runs. On main: 57 of 57 pass.
  • The new test fails on main when it is run against main's viewer/index.html (handlers.get(...) is not a function: nothing listens for hashchange), and passes with the PR.
  • No feedback loop: the viewer writes the hash only with history.replaceState (viewer/index.html:252), which does not fire hashchange.
  • python -I scripts/check_no_game_data.py on both changed files: clean.

Windows 11, Node.js 24.15.0. No browser, GPU or game files.

AI-assisted (Claude Code, Claude Opus 5.5).

Verified at head `0370dc2a1` (merge-base is current `main` `73516a290`, so the branch is up to date). - `node --test tests/test_viewer_streaming.cjs` on the PR: 58 of 58 pass, 3 of 3 runs. On `main`: 57 of 57 pass. - The new test fails on `main` when it is run against `main`'s `viewer/index.html` (`handlers.get(...) is not a function`: nothing listens for `hashchange`), and passes with the PR. - No feedback loop: the viewer writes the hash only with `history.replaceState` (`viewer/index.html:252`), which does not fire `hashchange`. - `python -I scripts/check_no_game_data.py` on both changed files: clean. Windows 11, Node.js 24.15.0. No browser, GPU or game files. AI-assisted (Claude Code, Claude Opus 5.5).
lixonik reviewed 2026-11-26 15:44:01 +00:00
lixonik left a comment
No description provided.
Windows 11/Node: 58/58 viewer tests passed, including an already-open viewer accepting a valid camera hash change and ignoring an invalid one. No findings. AI-assisted.
aslan2142 reviewed 2026-12-01 12:02:30 +00:00
aslan2142 left a comment
No description provided.
Draft review against current `main`: extracting `applyCamHash` and wiring `addEventListener("hashchange", ...)` in `viewer/index.html:429-435` looks clean and clean-room verified. Still Draft with no CI run yet — please mark Ready for Review so CI runs green. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 12:28:56 +00:00

Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review.

(AI-assisted triage.)

Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review. *(AI-assisted triage.)*
aslan2142 approved these changes 2026-12-01 13:05:19 +00:00
aslan2142 left a comment

Now ready for review and MERGEABLE. Clean-room verified: extracting applyCamHash and wiring hashchange in viewer/index.html:429-435 (no feedback loop with history.replaceState) with tests in tests/test_viewer_streaming.cjs is clean and verified (@lixonik, @kurrutako).

Approving — ready to merge once CI runs green on current main.

(AI-assisted review.)

Now ready for review and `MERGEABLE`. Clean-room verified: extracting `applyCamHash` and wiring `hashchange` in `viewer/index.html:429-435` (no feedback loop with `history.replaceState`) with tests in `tests/test_viewer_streaming.cjs` is clean and verified (`@lixonik`, `@kurrutako`). Approving — ready to merge once CI runs green on current `main`. *(AI-assisted review.)*
merzleckeier commented 2026-12-01 13:33:25 +00:00

Replayed hash changes through a real EventTarget on Node 26.13.1 with 0370dc2a1 + e04721c7. The test loaded the actual viewer module with a synthetic empty manifest and mocked graphics classes. Both arms restored the initial camera. On main dispatching a new hashchange left the old position. The PR followed the second pose, returned to the first, followed the second again, and kept the pose for malformed links. All 70 checked-in viewer-streaming tests passed. This exercises the event and camera state in Node.

AI-assisted with OpenAI Codex.

Replayed hash changes through a real EventTarget on Node 26.13.1 with `0370dc2a1` + `e04721c7`. The test loaded the actual viewer module with a synthetic empty manifest and mocked graphics classes. Both arms restored the initial camera. On main dispatching a new `hashchange` left the old position. The PR followed the second pose, returned to the first, followed the second again, and kept the pose for malformed links. All 70 checked-in viewer-streaming tests passed. This exercises the event and camera state in Node. AI-assisted with OpenAI Codex.
Sign in to join this conversation.
No description provided.