Skip to content

fix: snapshot escapes composition text in its output; stills sweep the transcode cache - #7832

Merged
michaelwang11394 merged 2 commits into
mainfrom
sec-partials-1115
Nov 15, 2026
Merged

michaelwang11394 merged 2 commits into
mainfrom
sec-partials-1115

Conversation

@michaelwang11394

Copy link
Copy Markdown
Contributor

What

Two follow-ups to #7779.

  • snapshot terminal output: text that comes from a composition is printed with C0, DEL and C1 control characters shown as visible \xNN. That covers frame-extraction warnings (they name the video), the self-closed media warning, failed font names, the not-media file warning, unsettled image sources, review beat labels, seam sides and notes, the project name and the final failure message. The warnings array in --json output keeps the raw text, because JSON already escapes control characters.
  • Still frames and the transcode cache: making a still, or serving one already on disk, now runs the same throttled cache sweep that proxy copies run. Stills already counted toward the cache's size and idle limits, but only a proxy request started a sweep. So a client that asked only for stills could grow .transcode-cache without bound. A still being served, and any still in flight, is protected from that sweep.

Why

  • Composition text could still send escape sequences to the terminal through hyperframes snapshot.
  • Requests for stills at many different times could fill a project's .transcode-cache, because nothing evicted them.

Related work

Refs #7779.

How

  • cli/commands/snapshot.ts: each print site wraps its composition-derived values in the shared terminalText(). The CLI's own colours are unchanged.
  • studio-server/helpers/proxyTranscoder.ts: maintainProxyCache also protects stills in flight and the still just served. resolveStill calls it on a cache hit (after marking the still as used), and makeStill calls it after writing a new still. The sweep is rate-limited per cache folder, as before.
  • scripts/package-size-budgets.json: studio-server's budgets go to 173,500 packed and 676,000 unpacked. main already measured 171,862 packed against a 172,000 budget, and this change measures 172,061 packed and 670,941 unpacked.

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

  • snapshot.test.ts: a video whose file name holds ESC and BEL produces a warning with them escaped.

  • proxyTranscoder.test.ts: a still idle past the cache's idle limit is evicted when a new still is made.

  • Both new tests fail without their fix.

  • studio-server vitest (proxyTranscoder, proxyCache, preview; 251 passed) and CLI snapshot vitest (214 passed) pass. tsc --noEmit is clean for cli and studio-server. oxlint, oxfmt, fallow, the comment ratchet and verify-packed-manifests pass.

@github-actions

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 267 (base branch 267), smooth 93 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)

Unstable (2)

  • seqnudge-none-px-r0-nested-z100: tracking 0.05, pressJump 0, drop 0, reload 323.41, render 0.03, renderKey -, undo false, teleport true / tracking 0.05, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.05, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true
  • seqseek-none-pct-r0-root-z100: tracking 0.05, pressJump 0, drop 0, reload 312.39, render 0.03, renderKey -, undo false, teleport true / tracking 0.05, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.05, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true

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

The changed snapshot messages reuse terminalText, and still creation/cache hits now reuse the throttled sweeper with the current and in-flight stills protected (snapshot.ts:833, proxyTranscoder.ts:352,1174,1244). Protection here covers the sweep itself and pending generation. The preview route then reads bytes synchronously before constructing the response; this is not a cross-process serving lease.

Pre-existing follow-ups, not blockers:

  • packages/cli/src/commands/snapshot.ts:1907,1913: the entry-mismatch advice still prints the suggested composition path directly. Escape those interpolated values too; my real-command probe confirms the remaining gap in ordinary and JSON mode's stderr. Other path-bearing diagnostics, including warnSnapshotsNotRecorded and the contact-sheet catch, should receive the same audit.
  • packages/cli/src/utils/terminalText.ts:1: the shared formatter covers C0/DEL/C1 (except intentional tabs), but leaves bidi formatting characters intact. Also, JSON.stringify escapes C0, not C1 or bidi. Keeping raw structured values is reasonable, but the PR's “JSON already escapes control characters” statement is too broad: ESC/C0 are escaped, C1 and bidi can remain raw. Document that boundary or use JSON Unicode escapes while preserving parsed values.

Validation: full workspace build passed; CLI snapshot/formatter suites plus three probes: 105 passed; proxyTranscoder/proxyCache/preview suites: 253 passed. Both new regression tests fail with their corresponding production change reverted. The remaining path-output probe also passes on base, confirming it predates this patch. An independent pass traced the still-response reader and cache eviction scheduling without finding a new regression. No manual browser or Windows run.

Locally packed studio-server: 172,652 packed / 666,394 unpacked bytes, below the new 173,500 / 676,000 budgets; the prior budgets were 172,000 / 672,000, so each budget increases by under 1%.

Need: yes · Size: ok · Reuse: terminalText and cleanupProxyCache · Simpler: already minimal · Structure: fine (checked shared formatter, sweeper and preview reader; no split)
Risk: medium — output handling and shared cache eviction.

— Rames / pr-review

Verdict: APPROVE
Reasoning: No new escaping regression was found at the changed sites; the still-only eviction regression is fixed. The remaining output-hardening limits predate this change and should be addressed separately.

@michaelwang11394
michaelwang11394 added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit a2f9267 Nov 15, 2026
84 checks passed
@michaelwang11394
michaelwang11394 deleted the sec-partials-1115 branch November 15, 2026 17:30
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