Repository navigation
fix(studio): a sealed preview's reload asks under one current frame token - #7862
Conversation
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at c01d84b32ffd49eb079a71be25d7b0d7a0b005e0.
For the normal preview URL, the reload helper replaces the existing token segment while retaining the project, composition suffix and query. It uses the same project-token endpoint; server issuance and validation are unchanged. Tokens remain scoped to the existing project preview, not to a single file. A fresh server instance has a new secret, so a previous instance's token is rejected; failed refresh retains the stale URL rather than removing its protection.
Evidence: a gated Node 24 harness over the exact helper and token-middleware sources (type stripping, mocked token fetch and downstream file handler) passes 9/9 controls: plain/current/stale reloads, preserved composition path and query, failed fetch, non-preview input, and stale/other-project rejection before serving. Restoring the previous regex makes the two reload regression cases fail. This is isolated code-path verification, not the full Player suite or a browser/server-restart walk.
Existing limits: already nested token paths are not fully flattened, and the separate visible Retry button reuses its captured URL. This patch fixes the normal shadow reload path; it does not establish universal restart recovery for those paths.
Need: yes · Size: ok · Reuse: existing token endpoint and validator · Simpler: already minimal prefix replacement · Structure: fine (checked Player source construction, reload helper and server token validation; no split)
Risk: low — one URL-rewrite correction without changing token authority.
Verdict: APPROVE
Reasoning: The normal reload replaces its stale token without changing the selected project/path, and unchanged server checks still reject invalid scope and old-instance tokens.
— Rames
What
A sealed preview's reload now loads under one frame token, the current one. Before, a reload started from the frame's own
src, which already held a token, andpreviewUnderFrameTokenput a second one in front:/preview/~<new>/~<old>. A token minted by an earlier Studio server process stayed in that path too.Why
Studio reloads an edited preview from the live frame's
src(refreshPlayer, then the shadow player). With two tokens, each layer of the token route strips one, so it happened to load; with a stale token from before a server restart, the inner one no longer matches and the reload is a 404. Found while checking why the sealed default (#7846) fails Studio's edit gates.How
previewUnderFrameTokenmatches an existing/~<43-char token>segment along with/previewand replaces it, so the path always carries exactly the current token.No visible change
Reachable only from a sealed preview, which Studio does not use by default yet.
Test plan
fails without the fix:
cd packages/studio && vitest run src/player/components/Player.test.ts -t "seals an opaque preview"(the two new rows, a reload under the current token and one under a stale token, get a second token onmain).On Linux, Node 24:
Player.test.ts35 tests, 3 runs in a row;tsc --noEmit,oxfmt --check,oxlintclean.