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

Open
opened 2026-11-26 21:20:51 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2329
Author: @syfyra
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: feat/viewer-follow-cam-link


📝 Commits (1)

  • 0370dc2 viewer: follow a camera link opened in the open page (VIEWER-FOLLOW-CAM-LINK)

📊 Changes

2 files changed (+56 additions, -2 deletions)

View changed files

📝 tests/test_viewer_streaming.cjs (+48 -0)
📝 viewer/index.html (+8 -2)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2329 **Author:** [@syfyra](https://github.com/syfyra) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/viewer-follow-cam-link` --- ### 📝 Commits (1) - [`0370dc2`](https://github.com/ubiquitarianism/leonida/commit/0370dc2a170179f7e11f3bd01cd44e6026a408db) viewer: follow a camera link opened in the open page (VIEWER-FOLLOW-CAM-LINK) ### 📊 Changes **2 files changed** (+56 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_viewer_streaming.cjs` (+48 -0) 📝 `viewer/index.html` (+8 -2) </details> ### 📄 Description 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#2331
No description provided.