Skip to content

fix(studio): a sealed preview's failed reload says only what the preview reported - #8194

Merged
miguel-heygen merged 4 commits into
mainfrom
secpub/sealed-u11d
Nov 20, 2026
Merged

miguel-heygen merged 4 commits into
mainfrom
secpub/sealed-u11d

Conversation

@miguel-heygen

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

Copy link
Copy Markdown
Collaborator

What

When a sealed preview (VITE_STUDIO_OPAQUE_PREVIEW_ENABLED=true) fails to reload, Studio's message now says only what the preview actually reported. Before, every sealed failure said the page and its runtime never loaded, and named a page stage (no-page), whatever really happened.

Why

To say how far a failed reload got, Studio reads the new preview's window and document. A sealed preview refuses both reads, so Studio took every sealed preview for a page that never loaded.

How

  • failShadow (player/hooks/useShadowPreviewReload.ts) checks whether the new preview is sealed. If it is, the message relies only on what reached Studio, and it no longer names a page stage.
  • Studio now records when it accepts the new preview's timeline, separately from the restore seek that follows. So the message names the stage reached: waiting for its loaders to clear (the seek painted), waiting for its restore seek to paint (the timeline arrived, the seek never painted), or, with no timeline, waiting for its runtime to report a timeline (sealed) or for its timeline to be ready (open).
  • Open previews gain the restore-seek stage too; their other messages are unchanged.

Test plan

  • fails without the fix: "says only what a sealed shadow reported when it fails to reload" in packages/studio/src/player/hooks/useTimelinePlayer.shadowReload.test.ts, the first commit. It reloads into a frame Studio cannot read, with the real editing agent behind it. On main's code, on a Linux box, the message says the page and its runtime never loaded.
  • With the fix on a Linux box: useTimelinePlayer.shadowReload.test.ts passes 3 of 3 runs (59 tests). The Studio player suite (src/player) passes 211 files, 2,593 tests. Studio typecheck exits 0.
  • Unit tests added/updated
  • Manual testing performed
  • Comments follow CONTRIBUTING.md "Comments"

Before

Studio from main (a1ee4009), built with the preview sealed, opens a project, then its file is saved with a script that holds the new page before its runtime starts, so the reload times out after 15 s: "It was still waiting for the page and its runtime to load. Its page had got to: no-page."

Before: sealed preview reload failure on main

After

The same steps at this branch (fbb6b722; the head since only shortens a test comment): "It was still waiting for its runtime to report a timeline."

After: sealed preview reload failure on this branch

What I did not exercise

  • A sealed preview that fails after its timeline arrived (loaders or restore seek) in a real browser: the unit tests drive those stages.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 271 (base branch 271), smooth 81 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 (0)

Unstable (2)

  • seqplainkeys-none-center-r0-root-z100: tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true
  • seqplainkeys-none-px-r0-root-z100: tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true

@terencecho terencecho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2] A sealed shadow can report that it never sent a timeline after Studio has accepted one. In packages/studio/src/player/hooks/useShadowPreviewReload.ts:209, the diagnostic equates an unset pending commit with an absent timeline. The pending commit is only set after the restore seek at line 342. In Chromium, a sandboxed shadow sent a timeline just before the normal reload deadline and received a seek command, but the failure toast still said it was waiting for the runtime to report a timeline. The original preview stayed visible. Track timeline receipt separately so the diagnostic identifies the stage Studio actually reached.

The named regression passed and failed as expected with the preceding implementation. The workspace build, Studio typecheck, lint and format, 157 focused tests, and the full 2,593-test Studio player suite passed. The Chromium check used a controlled shadow response.

— tai (automated review)

@miguel-heygen

Copy link
Copy Markdown
Collaborator Author

Fixed in fbb6b72.

[P2] A failed reload now says when the timeline already arrived. Studio records the shadow's timeline when it accepts it, before the restore seek (acceptedTimelineGenRef, set in markAdapterReady), not when the commit is registered after the seek paints. The failure message now names that stage: "It was still waiting for its restore seek to paint." The earlier stages are unchanged: no timeline yet, or committed but its loaders not clear.

fails without the fix: names the restore seek when a shadow's timeline arrived but its seek never painted in useTimelinePlayer.shadowReload.test.ts. The shadow's timeline is accepted, its restore seek never paints, and the reload times out. On the previous code the message said it was still waiting for its timeline.

@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 fbb6b722347c13db6cac507447331e42743fc601, including Tai's finding at c4087372.

Tai's reported stage mismatch is resolved. packages/studio/src/player/hooks/useShadowPreviewReload.ts:340 records timeline acceptance before waiting for restore-seek paint; :217 uses that fact independently of the pending commit. The marker is generation-bound and cleared by the shared stop path. Sealed previews no longer infer a page stage from inaccessible document state. Independent source review found no introduced blocker.

Validation: frozen-lockfile install and full bun run build passed. Through the shared test gate, bun run --cwd packages/studio test src/player/hooks/useTimelinePlayer.shadowReload.test.ts src/player/hooks/useTimelineSyncCallbacks.sealed.test.ts --maxWorkers=2 passed 62 tests. Restoring only the hook to c4087372 made names the restore seek when a shadow's timeline arrived but its seek never painted fail: it reported "its timeline to be ready". Restoring this head passed that test. Happy-dom emitted iframe teardown AbortError/NetworkError diagnostics; the runner completed successfully. No real-browser failure walk or full player-suite rerun performed. The PR body contains the required fails without the fix: line.

Nit: the body's How section still describes only the timeline/loaders split; add the restore-seek stage and note that open previews gain that distinction too.

Need: yes · Size: ok · Reuse: existing readiness callback and shared cleanup · Simpler: already minimal · Structure: fine (checked timeline callback, seek helper and generation cleanup; no split)
Risk: low — diagnostic-only stage tracking, with existing promotion behavior unchanged.

— hf-review

Verdict: APPROVE
Reasoning: The previously reported stage mismatch is fixed and the regression fails on the prior implementation and passes at this head.

@vanceingalls vanceingalls 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.

Approving at 3ab857a6. Rames approved fbb6b722. The only code change since then is 3ab857a6, which shortens one test comment in useTimelinePlayer.shadowReload.test.ts to fit the 120-character limit, with no behaviour change.

  • Lane rule: met. fails without the fix: names "says only what a sealed shadow reported when it fails to reload" in useTimelinePlayer.shadowReload.test.ts.
  • Captures: the body now has ## Before and ## After with images. The first "Studio and player captures" run (23:31:58Z) read the body before those headings existed. The re-run at 23:32:40Z passed, so the red entry in the rollup is stale.
  • Terence's change request at c4087372 (the P2 at useShadowPreviewReload.ts:209, where an accepted timeline was read as absent before the restore seek) was answered at fbb6b722. The new test "names the restore seek when a shadow's timeline arrived but its seek never painted" pins it. GitHub will still show his change request until he dismisses or re-reviews it.

@miguel-heygen
miguel-heygen dismissed terencecho’s stale review November 20, 2026 04:48

Every point of this change request is answered at the current head, which has approvals; dismissing the stale request so the PR can merge. Happy to take a fresh review.

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit f13969f Nov 20, 2026
124 of 125 checks passed
@miguel-heygen
miguel-heygen deleted the secpub/sealed-u11d branch November 20, 2026 05:22
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.

4 participants