Repository navigation
fix(studio): element picker style, data and text edits draw in a sealed preview - #8663
Merged
Merged
Conversation
Contributor
Edit accuracy: accurate 273 (base branch 271), smooth 58 of thoseThe gate passes. Newly passing (2)
Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)
Quarantined, measured but not gated (0) Unstable (1)
|
jrusso1020
approved these changes
Nov 24, 2026
jrusso1020
left a comment
Collaborator
There was a problem hiding this comment.
Approving at 099e958.
- fails without the fix: checked. With the sealed branch disabled, the sealed case fails with the message quoted in the body. At head it passes 2/2, the changed and covering test files pass 31/31, and
tscis clean. - Sealed and unsealed match: sealed edits now go through the editing port in the same order as unsealed: draw, then the picker state update, then the source patch with the same
hfId/ownFile. The unsealeduseElementPicker.test.tspasses unchanged. - File size: on the merge with current main,
useElementPicker.tsis 529 lines andelementPickerWrites.tsis 52. The diff is.tsonly, so the "No visible change" captures exemption applies. - No overlap: no files are shared with #8662 or #8668, and there's no dependency on either.
Nits, none blocking:
- A sealed text edit is refused when the element holds more than text, or when the value is over the length cap. Unsealed overwrites in those cases. The body says so.
- The sealed picker-state update lands after an await. If someone picks another element first, the edit lands on that element's state.
- Only
writePickedis tested. The hook's sealed wiring (the state update and save after the promise) has no test.
Review by Rames
This was referenced Nov 24, 2026
Merged
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
useElementPicker'ssetStyle,setDataAttrandsetTextContentnow draw on the picked element and save to source in a sealed preview, the same as in an unsealed one. Before this, all three looked up the element throughiframe.contentDocument. A sealed frame does not expose it, so typing a style, a data attribute or text in the picker did nothing: nothing was drawn, the picker state did not change, and nothing was saved, with no error.Why
A sealed preview must give exactly the same result as an unsealed one. The picker already shows a sealed pick (its styles come over the editing port,
useElementPicker.tsshowPicked), but its edits never reached the frame or the source.Related work
Same port as #8149 (property panel style and attribute edits):
editPreviewElement(packages/studio/src/player/lib/previewElements.ts:434), withqueryPreviewElementsanddescribePreviewElementsto find the element and its source the waypreviewSelection.tsdoes (previewIdentity,previewElementSourceFile).How
hooks/elementPickerWrites.tswithwritePicked(iframe, selector, write). For a readable frame it applies the live edit to the firstselectormatch, as before, and returns the element'sdata-hf-idand source file. For a sealed frame it queries the first match's handle, describes it, draws the edit witheditPreviewElement, and returns the same{ hfId, ownFile }once the frame says it drew the edit (hfIdfrom the description's attributes,ownFilefrompreviewElementSourceFile).useElementPickershare onewritePickedElement: draw, then update the picker state, then patch the source. That is the same order as before.syncToSourcetakes{ hfId, ownFile }instead of the live element.escapeHtmlText), which gives the same text node astextContent = text.editElement.tsrefused). The sealed text setter then draws and saves nothing. Unsealed still overwrites. Lifting that rule is a separate decision about the port.Test plan
packages/studio/src/hooks/elementPickerWrites.browser.test.tsopens the same preview in real Chrome, once same-origin and once sandboxed (HF_PARITY_MODEpicks one). It applies a style, a data attribute and text with markup characters to.title, then a write to a selector with no match. It checks the frame's computed color, the attribute and the text, and that every write returns{ hfId: "t1", ownFile: "index.html" }(null for the missing element). Both modes must give the same result.Devbox: the named test passed 3 runs in a row (exit 0, 2 passed), the covering studio test passed, and studio
tscwas clean.fails without the fix:
elementPickerWrites.browser.test.ts"the element picker's style, data and text edits draw in a sealed preview". With the sealed branch removed, so that only main'scontentDocumentpath runs, the sealed case fails withexpected { sources: [ null, null, …(2) ], …(1) } to deeply equal { sources: [ { …(2) }, …(3) ], …(1) }(exit 1, 1 failed, 1 passed): no write lands and nothing is drawn, which is what main does sealed. The unsealed case stays green.Devbox gate at this head: Fallow audit clean, pre-push clean.
No visible change
No production code calls these three setters today:
packages/studio/src/hooks/useElementPicker.tsand the new test. Agit grepforsetStyle|setDataAttr|setTextContentoverpackages/anddocs/finds no other caller. Studio's own panel edits go throughonSetStyleand the DOM edit commits instead.@hyperframes/studioexportsuseElementPicker(packages/studio/src/index.ts:188). Its one known consumer, the HyperFrames Desktop app, takes onlypickedElement,isPickMode,enablePick,disablePickandclearPickfrom it, never the setters.So no person sees row 48 on a screen yet. It reaches people only through an embedder that calls these setters on a sealed preview, and there it now draws and saves exactly as unsealed. The proof is the real-Chrome test above, which runs the real runtime in a sandboxed frame. The change is in
.tsfiles only.