fix(studio): a text edit saves to the element that was edited, or says why it could not - #4803
Merged
Merged
Conversation
Edit accuracy: 434 passing here, 434 on the base branchThe gate passes. |
miguel-heygen
marked this pull request as ready for review
October 1, 2026 00:40
somanshreddy
approved these changes
Oct 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A text edit made in place on the Studio canvas is now saved to the element that was edited, whatever is selected when the edit closes. When a text edit cannot be saved, Studio says so in an error toast, logs why, and puts the old text back, so the screen never shows text that is not in the file.
Why
Today the in-place text commit saves against the current selection, and silently drops the edit when the edited element is not that selection. The typed text stays on screen, nothing is written, no toast appears, and the text is gone after a reload.
Repro on main (built Studio via
hyperframes preview): double-press a headline and type. While the edit is open, something else changes the selection (an agent callsstudio_selecton another element, or a host app clears its pick). Press Enter: nothing is written in 8 s, no toast, and a reload shows the old text. A host that opens the edit on a child of what it has selected (a composition host or a container) hits the same path, and so does a host whose Escape clears the pick before the edit closes.How
handleDomRichTextCommitresolves the selection from the edited element itself (buildDomSelectionFromTarget(element, { exactTarget: true, skipSourceProbe: true })), so the patch targets that element's own source file (a nested element saves to its sub-composition file).console.error, and puts the previous markup back.Test plan
Unit tests:
useDomEditTextCommits.test.tsx(the selection is another element, or none: the edit saves to the edited element and the selection is left unchanged; the edited element still selected: the selection is refreshed; an unresolvable element: toast, console error, old text back) anduseDomEditCommits.test.tsx(a commit onto a removed preview node is refused and now says so). The new tests fail on main's source; breaking the selection condition either way turns one of them red.Studio unit tests for
src/hooksandsrc/components/editor: 1662 passed.tsc --noEmitclean.Manual: headless Chrome on a built CLI preview, root and nested text: double-press, type, Enter writes in about 100 to 170 ms (unchanged); the agent-select repro above writes on the branch and not on main.
Edit accuracy bench, text cases (from the open bench PR that adds them), same machine, same main, 2 jobs:
All four fail only
smoothon both builds (a loaded Linux box; the blank-page control drops frames there too). The bench's text route keeps the selection on the edited element, so it passes on main; the repro above is the route it does not cover.Documentation updated (if applicable)
Comments follow CONTRIBUTING.md "Comments"
Before
On main: the headline was double-pressed and " typed" entered; an agent then selected the card, and Enter was pressed. The typed text stays on screen, nothing is written and no toast appears:
After a reload the typed text is gone:
After
Same steps on this branch. The file is written on Enter, the card stays the only selected element, and after a reload the typed text is still there: