Skip to content

feat(studio): Studio's preview runs sealed by default - #7846

Draft
miguel-heygen wants to merge 12 commits into
mainfrom
feat/studio-preview-sealed-by-default
Draft

miguel-heygen wants to merge 12 commits into
mainfrom
feat/studio-preview-sealed-by-default

Conversation

@miguel-heygen

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

Copy link
Copy Markdown
Collaborator

What

Studio's preview now runs on an opaque origin by default: VITE_STUDIO_OPAQUE_PREVIEW_ENABLED defaults to on, so the live, shadow and backdrop players get sandbox-origin and load under the frame-token path (#7817). Setting the variable to false keeps today's same-origin preview.

Why

A composition's scripts should run apart from Studio's own page. The editing port and the token path now carry what Studio needs for playback, selection, the console errors panel and playback keys.

What does not work yet on a sealed preview

These still read the preview's window directly. On a sealed frame they fall back or do nothing until each moves to the editing port. Each row says whether I saw it in a browser or read it in code.

Feature On a sealed preview Source
Timeline clip thumbnails (filmstrip) empty seen (headless Chrome, #7817 captures)
Live GSAP edits: keyframe value at the playhead, 3D slider live preview, live retime, soft reload, undo restore no live preview; edits apply after a full reload code (findParsedTween, gsapLivePreview, applySoftReloadFinalization)
Timeline move, resize, hide full reload instead of the in-place rebind code (applySoftReloadFinalization callers)
In-place scene swap every edit becomes a full reload code
Inline text editing on the canvas no caret opens on a press and Enter; #8181 and #8183 move it to the port seen (inline-text-caret.mjs, sealed)
Captions overlays, colour-grading reads, audio meter and scrub, snap guides, off-canvas indicators, motion paths, shift-click add, slideshow scenes to walk code
WebMCP agent tools (look, select, inspect, writes) studio_look lists no elements: the scene is read from the frame's document seen (undo-socket-pool.mjs, sealed)

Already on the port and working sealed: element picking and selection (#7561), loop start, the clip manifest, the console errors panel (#7824), playback keys with focus in the preview (#7844), composition thumbnails (already opaque).

Related work

Needs #7856 (a sealed preview's video proxy wait passes its preflight; found in review here), #7824 and #7844 in the same release. #7817 is merged.

Merge order

Do not merge before v0.9.54 is cut: that release carries #7811 and #7817 with the flag still off by default. This default lands in the release after it at the earliest. Desktop embeds Studio and must not take a release with this default before its own sealed-preview loads are on its main.

Before

main, flag unset, headless Chrome at 1600x900, the blank template: the preview frame runs on Studio's origin (http://127.0.0.1:<port>) and the timeline clip shows its filmstrip.

before

After

This branch, flag unset: the frame loads under the frame-token path on origin null; the preview looks the same, and the timeline clip's filmstrip is empty (first row above).

after

Test plan

  • Unit tests added/updated

  • Manual testing performed

  • Documentation updated (if applicable)

  • Comments follow CONTRIBUTING.md "Comments"

  • One line: the flag's default. On Linux, Node 24, packages/studio vitest run (the whole package) with the new default: 759 files, 8660 tests pass (1 skipped file, 16 todo), so no test depends on the old default.

  • A browser walk of every row above, sealed against same-origin, follows in this PR.

fails without the fix: packages/studio/tests/e2e/aroll-backdrop.mjs, run against a sealed Studio, stops at its first wait at 9028129a (walk stopped at "undefined": Waiting failed: 60000ms exceeded) and passes at 369259e4. It and inline-text-caret.mjs read the preview through iframe.contentDocument, which is null for a sealed frame. They now reach it with contentFrame(), as graded-video-transitions.mjs does. inline-text-caret.mjs now gets past the frame and fails at its first edit: no caret opens, because sealed in-place text editing is not on this branch. #8181 and #8183 close that gap.

Base automatically changed from feat/studio-preview-sandbox-origin to main November 15, 2026 17:32
@miguel-heygen
miguel-heygen force-pushed the feat/studio-preview-sealed-by-default branch from a907dbb to 43c5ac8 Compare November 15, 2026 17:37

@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 43c5ac83e495512b70c25d1e70c5c6bb70f6b97a.

Important — complete the token-path proxy CORS contract before default-on. packages/core/src/runtime/proxyWait.ts:20–24 sends X-HF-Proxy-Priority for at-playhead and background requests. The opaque token route in packages/studio-server/src/helpers/opaqueFrameLoads.ts does not answer that preflight with the required method/header grant. In real Chrome, the actual waitForServedProxy helper succeeds unsealed for a ready H264 copy of a MOV, but returns false sealed. mediaProxy then reports proxy_playback_failed instead of installing the playable copy. This prevents proxy-backed playback for the demonstrated MOV fixture, rather than taking the disclosed full-reload fallback.

Add a narrowly scoped OPTIONS response after token validation for the supported proxy GET headers, and expose Content-Range, Retry-After and X-HF-Proxy-Progress on the matching responses. Reuse the header contract already defined for trusted capture loads, while retaining the server's token and private-file boundary. Add a real-browser sealed proxy regression. A temporary fixture-only preflight/header response makes both sealed and unsealed controls pass; no production fix was pushed.

Native evidence: temporary vitest run src/routes/reviewDefaultSeal.test.ts reports 1 passed, 1 failed (unsealed proxy=true, sealed proxy=false); the fixture-only header fix reports 2 passed. Real token/preview server and bundled runtime helper, same media/cache fixture. Ordinary image, media metadata, JSON/XHR, CSS, font, module and 206 body loads work in both modes. Sealed JavaScript cannot read Content-Range, so the runtime's source-size probe also loses its total-size input. This does not show ordinary range-body seeking itself failing.

The package-scoped flag/Player/NLEPreview suites, including an explicit-false control, pass 71 tests. The flag reaches live, shadow and backdrop players; explicit false selects the prior path. The sandbox and expected-frame message checks remain in place. The listed empty-filmstrip/full-reload limitations are product trade-offs, not my blocker. I did not walk all remaining “to walk” features or certify that list complete.

Need: yes · Size: ok · Reuse: token validation and existing capture header contract · Simpler: scoped server preflight/header support · Structure: fine (checked player propagation and runtime proxy callers; no split)
Risk: high — changes the default execution boundary and media-loading behavior.

Verdict: REQUEST_CHANGES
Reasoning: Default-on activates a demonstrated proxy playback failure. The scoped header fix should land and pass the sealed browser control first.

— Rames

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 273 (base branch 271), smooth 21 of those

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

Newly passing (2)

  • seqscaletwice-scale-px-r0-nested-z100
  • seqscaletwice-scale-px-r0-root-z100

Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)

  • seqscaletwice-scale-px-r0-nested-z100
  • seqscaletwice-scale-px-r0-root-z100

Quarantined, measured but not gated (0)

Unstable (1)

  • seqplainkeys-none-pct-r0-nested-z100: tracking 12.43, pressJump 0, drop 0, reload 0, render 0.02, renderKey -, undo true, teleport true / tracking 0.05, pressJump 0, drop 0, reload 0, render 0.02, renderKey -, undo true, teleport true / tracking 0.05, pressJump 0, drop 0, reload 0, render 0.02, renderKey -, undo true, teleport true

@miguel-heygen

Copy link
Copy Markdown
Collaborator Author

On the token-path preflight: this is met. hyperframes#7856 (merged, and in this branch) makes the opaque token route answer the proxy wait's preflight. On main, packages/studio-server/src/helpers/opaqueFrameLoads.ts answers an OPTIONS from origin null for GET with Access-Control-Allow-Headers: PROXY_WAIT_ALLOWED_HEADERS (line 79), and captureLoads.ts:17 defines that as Range, X-HF-Proxy-Priority, the header proxyWait.ts sends. I'm taking this PR over; next I rebase it on main (174 behind, no conflicts) and look at the edit-accuracy gate, which reads 0 of 267 with the preview sealed.

@miguel-heygen

Copy link
Copy Markdown
Collaborator Author

Reply to the change request at 43c5ac83.

The token-path proxy CORS contract landed in #7856 (ae5829db), which this branch's head (9a153c72) already contains. Point by point, cited at main ce0932e0:

  • Preflight, answered after token validation. packages/studio-server/src/helpers/opaqueFrameLoads.ts:121-125: the token route first checks the project's token (an unknown token answers 404), then answers an OPTIONS with 204 only when answersProxyPreflight (:75-79) holds: Origin: null, Access-Control-Request-Method: GET, and a video asked for with the proxy query. The answer (:81-86) allows GET and the headers Range, X-HF-Proxy-Priority.
  • Exposed headers on the matching responses. :66-69: a granted load (Origin: null; a fetch is Sec-Fetch-Dest: empty, granted at :23) gets Access-Control-Expose-Headers: Retry-After, X-HF-Proxy-Progress, Content-Range.
  • One header contract, reused. Both lists come from the trusted capture loads' constants, packages/studio-server/src/helpers/captureLoads.ts:17-18 (PROXY_WAIT_ALLOWED_HEADERS, PREVIEW_EXPOSED_HEADERS). The header names come from packages/core/src/previewProxyBox.ts:9-10, the same ones proxyWait.ts sends and reads.
  • Token and private-file boundary kept. The preflight answers without reading any file. The GET still goes through the plain preview route under the token, so its private-file check applies as before.
  • Tests. packages/studio-server/src/routes/preview.opaqueFrameLoads.test.ts:286-337 covers the preflight answer and four cases it must leave unanswered: a non-video, a video without the proxy query, a caller that is not an opaque frame, and a method other than GET. It also covers a preflight without the project's token (404) and the exposed headers on a granted load. The real-browser sealed regression is packages/studio/tests/e2e/sealed-preview-proxy.mjs: a sealed Studio frame fetches clip.mov?hf-proxy=1 with Range and X-HF-Proxy-Priority, must get past the preflight, and must read the answer, including Retry-After on a pending copy. CI runs it in the step "Verify a sealed preview's proxy wait gets past its preflight", which passes at 9a153c72.

…ugh its frame

Both walks read the preview through iframe.contentDocument, which is null for a sealed frame, so each timed out
at its first wait. They now reach the frame with contentFrame(), as graded-video-transitions.mjs does.

aroll-backdrop.mjs passes sealed. inline-text-caret.mjs gets past the frame and fails at its first edit: no caret
opens, because sealed in-place text editing is not on this branch. That is the gap #8181 and #8183 close.
This was referenced Nov 22, 2026

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

REQUEST_CHANGES. Re-reviewed at 504645c9de13daca50ad7de5b1a7bd398226f8c5.

My earlier two points are resolved. #7856 (ae5829db7e) is an ancestor of this head. At this head, serveTokenPreviewPaths still answers the proxy wait's OPTIONS after token validation (answersProxyPreflight → 204 with Range, X-HF-Proxy-Priority), and tokenPathHeaders exposes Retry-After, X-HF-Proxy-Progress, Content-Range on granted responses. The later fetchAgain/seek-reapply changes to that file leave both in place. The real-browser regression (sealed-preview-proxy.mjs) runs in CI. Nothing more is needed there.

What still blocks: the default flip regresses 15 editing cases. This PR's only production change is STUDIO_OPAQUE_PREVIEW_ENABLED defaulting to true. The edit accuracy gate at this head (run 45491729250) reports 258 accurate cases against 271 on the base branch. Fifteen cases marked passing in baseline.json now fail:

  • resize: resize-late-px-r0-root-z100-{on,after,before}, resize-late-px-r0-nested-z100-on, resize-size-px-r0-{root,nested}-z100-on, resize-size-px-r0-root-z100-{after,mid}
  • sequences: seqab-none-{center,px,pct}-r0-{root,nested}-z100, seqfastkeys-none-px-r0-root-z100, seqnudge-none-px-r0-nested-z100

The unstable rows show what a user would see. seqab-none-center-r0-* runs end with undo false and a reload jump of 300–437 px in 2 of 3 runs. These are edits that work today with the preview unsealed and break once it is sealed by default, so this is the change itself rather than flakiness.

To clear it: this branch is also behind main and conflicts in packages/studio/tests/e2e/aroll-backdrop.mjs, and main has landed several sealed-mode editing fixes since the last merge (#8772, #8736, #8719, #8777). Merge main, resolve the walk conflict, and get the edit accuracy gate back to the base branch's count (or quarantine named cases with a stated reason). I'll approve that head. The timeline viewport gate failed in both the flag-on and flag-off attempts (interaction p95 over budget either way), so I'm not counting it against this PR. The Windows studio-1 shard is likewise separate.

The conflict alone would not block an approval; it's noted only because the merge it needs is also the likely route to the gate.

Need ✅ (default-on is the goal) · Size ✅ (one production line plus walk updates) · Reuse ✅ (smoke serves the real runtime; walks read the frame through its token) · Simpler ✅ · Structure ✅
Risk: high. Flipping the default changes the preview's execution boundary for every Studio user, and the gate shows resize and A/B-sequence edits regressing under it.

— Rames

This branch has not been deployed

No deployments
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