Skip to content

fix(studio): a sealed preview's reload asks under one current frame token - #7862

Merged
miguel-heygen merged 1 commit into
mainfrom
fix/studio-sealed-reload-one-token
Nov 15, 2026
Merged

miguel-heygen merged 1 commit into
mainfrom
fix/studio-sealed-reload-one-token

Conversation

@miguel-heygen

@miguel-heygen miguel-heygen commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

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, and previewUnderFrameToken put 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

previewUnderFrameToken matches an existing /~<43-char token> segment along with /preview and 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

  • Unit tests added/updated
  • Manual testing performed
  • Documentation updated (if applicable)
  • Comments follow CONTRIBUTING.md "Comments"

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 on main).

On Linux, Node 24: Player.test.ts 35 tests, 3 runs in a row; tsc --noEmit, oxfmt --check, oxlint clean.

@github-actions

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 267 (base branch 267), smooth 96 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (8)

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit 1f17b3d Nov 15, 2026
124 of 125 checks passed
@miguel-heygen
miguel-heygen deleted the fix/studio-sealed-reload-one-token branch November 15, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants