Skip to content

fix(studio): a sealed preview edits text over 200,000 characters in place, as unsealed does - #9074

Merged
miguel-heygen merged 6 commits into
mainfrom
test/sealed-parity-long-text
Nov 29, 2026
Merged

miguel-heygen merged 6 commits into
mainfrom
test/sealed-parity-long-text

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

What

A sealed preview now edits text over 200,000 characters in place, as the unsealed preview does. Until now a sealed preview would not open a text edit on such an element, and would refuse a typed result that grew past 200,000 characters.

  • The sealed parity gate counts inline-text-long: words typed after a text of 249,999 characters save and show, in both modes.
  • Gate: 20 of 35 rows had tests on main; on this branch 21 of 35.

Why

Studio may only seal its preview by default once every behaviour works the same in both modes. #8183 recorded this one as a known sealed-only gap: 200,000 characters was the bound on text markup between Studio and the sealed preview, and the unsealed preview has none. The unsealed save path has no limit of its own: the element patch route takes any body, and the real ceiling is the 32 MiB a file may have for Studio to read it as text (MAX_TEXT_READ_BYTES in packages/studio-server/src/routes/files.ts). The text-markup bound is now that same ceiling, so both modes stop at one size. Style and attribute values keep the 200,000 bound.

Related work

Follow-up to #8183, #9058 and #9064.

How

  • textMarkup.ts: MAX_TEXT_MARKUP (32 MiB) next to MAX_EDIT_VALUE. Every check on text markup between Studio and the frame uses it:
    • isEditableText: may the frame open an edit on this element.
    • isTextMarkup and the html/expect checks in editElement.ts: the markup Studio sends the frame.
    • The html/previous checks on an ended edit in textEdit.ts: the markup the frame sends Studio.
  • The markup check is unchanged: only text tags and plain attributes pass, at any length.
  • inlineTextTyping.browser.test.ts: typeAndEnd takes the element's markup; a new both-mode case types after a 249,999-character text.
  • textEdit.test.ts and inlineTextEdit.sealed.test.ts: the refusal cases now go one past the new bound.

Test plan

  • fails without the fix: "words typed after a sealed text over 200,000 characters save" (packages/studio/src/hooks/inlineTextTyping.browser.test.ts) times out before the fix: the sealed edit never opens. The unsealed case passes before and after.

  • With the fix, on the devbox: the new file 6 of 6 per mode. Core textEdit.test.ts and editElement.test.ts: 41 of 41. Studio inlineTextEdit.sealed.test.ts: 61 of 61. tsc --noEmit in packages/core and packages/studio: exit 0.

  • 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

No visible change

A sealed preview now edits long text as the unsealed preview already does. Nothing on screen changes for text under 200,000 characters.

@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 bc004b0. No blocker.

Read whole: the diff (7 files, +43/-16), textMarkup.ts, and the event parsers in textEdit.ts. Read as hunks: editElement.ts, the three test files, the manifest. Nothing was run; one string search over core, studio and studio-server for the remaining 200,000 bounds.

Checked:

  • Every length check on text markup between Studio and the frame now uses MAX_TEXT_MARKUP: isEditableText, isTextMarkup, the html/expect fields in editElement.ts, and html/previous on an ended edit. No text markup check is left on the old bound, so open and close of an edit cannot disagree.
  • Style and attribute values keep 200,000 (MAX_EDIT_VALUE in editElement.ts, restoreAttributes.ts, setAudioGroupAttribute.ts untouched).
  • The markup rule itself (holdsOnlyTextMarkup: text tags, plain attributes) is unchanged; only the length moved.
  • 32 MiB matches MAX_TEXT_READ_BYTES in studio-server/src/routes/files.ts.
  • The "fails without the fix:" line is in the body and names the test; the new case runs in both modes and compares saved, written and shown text. The refusal tests moved to one past the new bound, so the refusal path is still covered.
  • The manifest edits only the inline-text-long row and its name matches the new case.

Non-blocking:

  • The bound counts string length (UTF-16 units) while the server cap counts bytes, so non-ASCII text can pass here and still make a file the server will not read back as text. The two ceilings are equal only for ASCII; a comment on MAX_TEXT_MARKUP would keep that from surprising anyone.
  • Studio now parses up to two strings of this size (html, previous) into a template for each ended edit the frame reports. Fine as a ceiling; if this event can ever arrive without an edit Studio opened, that cost is worth a guard.
  • The two refusal tests now build strings over 32 MiB in the DOM stand-in; watch their run time in CI.

Need: yes · Size: small · Reuse: one constant beside the existing one · Simpler: no · Structure: fine
Risk: low; larger messages across the frame boundary, same markup rule.

— Rames

@miguel-heygen

Copy link
Copy Markdown
Collaborator Author

Thanks. On the non-blocking notes:

  • Characters vs bytes: the bound is on string length (UTF-16 units). Every unit of a file's text takes at least one UTF-8 byte (an astral character is 2 units and 4 bytes), so any text in a file Studio can read (32 MiB of bytes at most) is at most 32 MiB units long. The sealed bound never refuses text the unsealed preview can open. It only admits more than the file could hold, which cannot reach it.
  • Parsing: yes, an ended edit's html and previous are each parsed once into a template to check the markup, so the cost is linear in the text. At 250,000 characters the new browser case's sealed run takes as long as its unsealed one, within the file's 60 s budget.
  • Test time: I'll post the CI durations of textEdit.test.ts and inlineTextEdit.sealed.test.ts from this head's run here once it finishes, and shrink those cases if they cost more than a few seconds.

@github-actions

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 275 (base branch 273), smooth 66 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-root-z100
  • seqscaletwice-scale-px-r0-nested-z100

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

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

Quarantined, measured but not gated (0)

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 29, 2026
@miguel-heygen

Copy link
Copy Markdown
Collaborator Author

Durations from this head's CI, and one correction to my last comment:

  • packages/core textEdit.test.ts: 29 tests in 477 ms. editElement.test.ts: 12 tests in 240 ms.
  • packages/studio inlineTextEdit.sealed.test.ts: 61 tests in 9.2 s. Of that, 3.3 s is "leaves Enter to playback on text too long for the frame to edit", which now builds two strings one past 32 MiB. I'm leaving it as it is: it is the only test that proves the bound itself.
  • Correction: I wrote that the new long-text browser case runs as fast sealed as unsealed. I had not measured the sealed time. What is measured: it passes in both modes, on the devbox and in this head's Sealed parity job, within the file's 60 s per-case budget. The unsealed run took 561 ms before the fix. No per-case sealed time is recorded.

Merged via the queue into main with commit 17f1046 Nov 29, 2026
109 checks passed
@miguel-heygen
miguel-heygen deleted the test/sealed-parity-long-text branch November 29, 2026 08:28
@miguel-heygen miguel-heygen mentioned this pull request Nov 29, 2026
5 of 6 tasks
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