Skip to content

fix(studio): previews framed from another site get no editing port; abandoned still jobs stop - #7793

Merged
michaelwang11394 merged 4 commits into
sec-studio4-1114from
sec-hf5-1114
Nov 15, 2026
Merged

michaelwang11394 merged 4 commits into
sec-studio4-1114from
sec-hf5-1114

Conversation

@michaelwang11394

Copy link
Copy Markdown
Contributor

What

  • Editing port. A Studio preview document requested by a frame on another site carries a marker, and the runtime's editing agent then ignores every connect in that document. Studio, the desktop app, the agent browser view and hyperframes.studio all load the preview from their own origin, so they keep the editing port. A page on another site that frames a local preview still plays the film but gets no DOM read/write port. A frame load from another site always gets a fresh, marked 200, never a 304 for a cached unmarked copy.
  • Abandoned still jobs. A still-frame job counts the requests waiting on it. When the last waiter's connection closes, ffmpeg is killed and the job is dropped. A waiter that passes no abort signal keeps the job running.

Why

  • The editing agent handed its DOM read/write port to whichever parent framed the preview. Any website could frame a running local Studio preview and read or change the document.
  • A still request that was cancelled left its ffmpeg running to the end.

Related work

Stacked on #7779, which adds the still slots and the cross-site guard these build on. #7778 already covers nested HLS playlists.

How

  • studio-server/createStudioApi.ts: for a cross-site or same-site frame or document load of a preview HTML, the server strips If-None-Match and If-Modified-Since, injects a marker meta tag at the start of <head>, and drops the ETag. Chrome's HTTP cache is keyed by site, which ignores the port, so without the stripping a page on another local port could revalidate Studio's cached unmarked copy. Other cross-site requests, such as the Studio opaque frame's fonts, keep revalidating.
  • core/runtime/editingAgent.ts: ignores connects in a marked document.
  • studio-server/helpers/proxyTranscoder.ts and routes/preview.ts: per-job waiter counts and an abort signal from c.req.raw.signal.

Test plan

  • Unit tests added/updated

  • Manual testing performed

  • Documentation updated (if applicable)

  • Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug

  • core editingAgent.test.ts 117 pass. The studio-server preview, sandbox, origin-guard and opaque-frame tests and proxyTranscoder.test.ts pass (277, 2 skipped). Each new test fails without its fix.

  • Real Chrome:

    • Studio's sandboxed frame from its own origin still gets a port and answers query.
    • A frame on another site gets no port.
    • A frame on another local port gets no port, including through revalidation.
  • A live still test with a slow fake ffmpeg: the process was killed when the client disconnected.

  • Not run on Windows (the kill test is skipped there, like the existing proxy kill test). hyperframes.studio was checked from the code, not live.

…diting port

When the Studio server answers a preview document to another site's
request, it now marks the document, and the runtime's editing agent
ignores every connect in a marked document. The Studio's own frames,
which load the preview from the same origin, keep the editing port.
The marked copy carries no ETag, so it is never revalidated in place of
the unmarked one.
Each still job now counts the requests waiting on it. A request whose
connection closes leaves the job, and when the last one leaves, the
job's ffmpeg is killed and the job is forgotten, so the next request
starts afresh. A caller that passes no signal keeps the job running,
and a request that has already closed starts nothing.
…ated

A frame load of a preview from another site now drops If-None-Match and
If-Modified-Since before the route answers, so it always gets a fresh,
marked document instead of a 304 that could reuse the unmarked copy a
browser cached for the Studio's own page on the same site. Subresource
loads keep their validators.

@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 2c18b57

The cross-site preview marker is checked on every editing-port connection. Frame/document validators are stripped before serving, so revalidation cannot reuse an unmarked response. Still requests detach independently, the last waiter aborts ffmpeg, and identity-based map cleanup prevents an old job from deleting its replacement.

Stack state: the current parent head 96959aa is an ancestor. This review covers the nine-file increment over that parent.

Validation: frozen install/full build passed; editing-agent 117 passed, preview/sandbox/origin/proxy suites 308 passed, including cancellation and shared-waiter coverage. Read the changed runtime/server files, queue/spawn consumers and token-preview route. No new native browser, Windows or hosted-site walkthrough performed.

Commands: bun run --cwd packages/core test src/runtime/editingAgent.test.ts --maxWorkers=1 and bun run --cwd packages/studio-server test src/helpers/proxyTranscoder.test.ts src/routes/preview.test.ts src/routes/preview.sandbox.test.ts src/createStudioApi.originGuard.test.ts --maxWorkers=1 (through the shared test gate).

Need: yes · Size: ok · Reuse: existing preview middleware, editing marker module and still scheduler · Simpler: attach waiter ownership to the existing shared job · Structure: fine (checked editing-port callers, token-route recursion and proxy/slot cleanup; no second scheduler)
Risk: medium — changes editing-channel admission and shared process cancellation.

Verdict: APPROVE
Reasoning: The marker/revalidation boundary and last-waiter cleanup are consistently wired and preserve the other callers' work.

— Rames

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