Skip to content

feat(studio): paste portable editable elements from clipboard - #5684

Closed
miguel-heygen wants to merge 18 commits into
mainfrom
feat/studio-element-paste
Closed

miguel-heygen wants to merge 18 commits into
mainfrom
feat/studio-element-paste

Conversation

@miguel-heygen

@miguel-heygen miguel-heygen commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

What

Paste a portable element clipboard into Studio as an editable, timed HTML clip. The clip uses the current playhead, becomes selected, extends the composition when needed, and participates in file history and undo.

Why

An element copied from another surface currently has no shared clipboard contract or native Studio insertion path.

Related work

This PR defines the producer-facing contract; a producer can import @hyperframes/core/element-clipboard after publication. It contains the receiving side and does not add a capture producer.

How

Core owns one bounded, versioned text envelope containing HTML, CSS, dimensions and warnings. Studio creates a fresh allowlisted tree, accepts embedded raster images/fonts and inline SVG, strips active content and external resource references, and scopes selectors, element IDs and font families. Existing internal copy/paste, text editing and read-only previews retain their current behavior.

Test plan

  • Failing-first contract and consumer regressions, including sanitization, placement/history, read-only handling, ID syntax and font collisions.
  • Core: 4 contract tests and build pass. Studio: 315 impacted tests across 15 files using the task-local test configuration; typecheck and production build pass.
  • Normal commit hooks pass: affected typechecks, lint, formatting, file sizes, Fallow, package exports and commitlint.
  • Actual Chrome native clipboard paste saves HTML; reload retains it; undo and redo restore the exact file contents. Separate browser probes exercise selector isolation and ID/font collision cases.
  • Four integration regressions fail before the fix and pass after it: parent/child compiler assembly keeps namespaces isolated; a paste retains the internal clipboard captured at invocation; duplicated nested media/supports styles retain their conditions; preformatted text survives insertion, history and reload without added spaces.
  • Independent Chromium 152 probes reproduce all four failures on the original receiver and pass on the successor, including a mounted React clipboard timing case. These use local file adapters and actual production callers, rather than a packaged Desktop app.
  • Two further receiver regressions fail on reviewed 81718dc1 and pass with the fix: repeated internal paste across composition files rebinds the copied element’s own embedded selectors; a duplicated SVG retains its local fragment references after the original is deleted and the saved file reloads. Both have committed consumer coverage and independent mounted-production-hook Chromium 152 probes with local file/history adapters and zero page errors. The SVG browser probe removes the original DOM node and serializes the survivor; it does not exercise the server delete endpoint.
  • Three further editing regressions fail on reviewed 8cd2a773 and pass on signed 7bb20141: fragment-attribute CSS predicates stay matched after repeated cross-file paste; a same-file SVG clone uses its own gradient while the original coexists; accepted ID-attribute selectors retain their styling after initial import and reload. Identical independent Chromium 152 production-hook probes observe all three failures before and all three passes after, with controls and zero page errors. File/history/source-edit adapters are local; the full Code panel and server endpoints are not exercised. Targeted tests also cover initial SVG fragment predicates, supported selector operators/flags, negative suffix matches and unrelated title literals.
  • Review round four: accepted xlink-to-href normalization and escaped local SVG URLs retain matching attribute styles; same-file Duplicate and Copy/Paste preserve previously false ID/resource predicates. Complete before/after attribute sets are compared per output node, including nodes with both ordinary href and xlink:href. Carried and embedded selectors use the same predicate preservation, while authored source edits retain their original spans. Identical independent Chromium 152 probes show five failures on reviewed 7bb20141 becoming passes on signed 3a6d555b, plus two dual-attribute controls that continue passing. Independent spec review caught two regressions during the repair; both are covered in the final seven-case passing run, with saved/history reload, controls and zero page errors. Eight source hashes bind that run to the signed commit. Local adapters and namespace-resolution limits remain explicit.
  • Review round five: synthesized root geometry style and safe button type retain the original attribute's absence or presence. Empty authored attributes remain present. Positive and negated style/type predicates keep their original matching behavior through import, duplication and history/reload. Identical independent Chromium 152 probes show four failures on reviewed 3a6d555b becoming passes on signed c2a3d0e5, with authored/empty-style and unaffected-descendant controls passing. All seven prior Chromium cases also pass; eight source hashes and both probe hashes bind the runs to the signed head. File/history/selection adapters remain local.
  • Review round six: unflagged HTML attribute-value predicates use the actual element/document matching context, including default ASCII-insensitive button type. Explicit i/s behavior remains distinct, and arbitrary HTML, SVG and XML-document values retain their own matching rules. Six browser-observed uppercase-button operator failures on reviewed c2a3d0e5 become passes on signed 1b690921, with lowercase/explicit-i controls, four native contextual helper controls, and all thirteen prior geometry/reference/carry-over cases passing through saved/history reload with zero page errors. Browser adapters remain local; Chromium 152 does not support explicit s, which is validated through focused helper tests rather than native paint.
  • Review round seven: generated CSS becomes an owned block in the last preceding participating stylesheet, preserving captured structural selectors and host clip topology without adding content siblings or ancestors. Timeline and full-root DOM copies read current saved CSS, remap owners and remove transient carriers before save. Chromium152 reproduces eight structural failures on reviewed 1b690921; final signed c7e02a8e407faab0300622d35c741d86b7316a44 passes all twelve structural cases, HEAD/BODY cascade-order, media/inert-style and atomic unsupported-target checks (six scripts, zero page errors). Nonempty titled sheets, namespace-bearing sheets, conditional imports and preceding BODY stylesheet links are rejected before file/history writes. Empty-title sheets and HEAD links retain supported controls. The preceding broader eleven-script matrix on signed 1171d8e6 covers ancestor depth, stylesheet adjacency, edited-CSS copy ownership and prior case/geometry/resource controls; only the narrow titled-sheet guard and shared attribute decoder changed afterwards. Spec found that titled-sheet issue and the preceding BODY cascade regression before push; earlier ancestor/head-order candidates were also rejected. The final six scripts and twelve source hashes bind to the signed successor; earlier runs retain their original attribution. Local clipboard/file/history/selection adapters do not establish full UI/server/packaged acceptance.
  • Review round eight: paste captures one transient project identity before native clipboard arbitration. Navigation invalidates it, including A→B→A. Internal fallback and accepted OS-envelope paths cancel stale work after clipboard, pending DOM-save and queued file-read waits, before file/history writes; completed saves avoid stale selection/reload. Seven mounted-hook regressions fail six stale cases and pass the no-navigation control on reviewed c7e02a8e; all seven pass with the repair, along with the existing Copy-later arbitration control. Parent Chromium 152 reproduces the specific equal-content read-B/write-A style loss on c7; identical internal/OS-envelope matrices pass eight schedules on signed 7a2c359ee6e6abbb7e4e3eee4a70e1c8e04a8308, with zero page errors. Other stale schedules validate the chosen cancellation contract; their old-source writes are not presented as the original styling defect. Local clipboard/file/history adapters remain explicit; no full navigation/server/packaged claim.
  • CI follow-up: split clipboard arbitration, native validation and saving within the same hooks. Fallow 2.75.0 with the stricter all-findings gate changes from exit 1 to exit 0 with zero complexity/dead-code findings. Ten unchanged test-clone locations remain warning-only. All 315 impacted tests, build, types, normal signed hooks and the same eight browser schedules pass on the successor; no gate, suppression or policy change.
  • Core selector tokenizer and clipboard contract tests (20), core build and public export smoke pass. Studio reuses this tokenizer through a narrow export; the element clipboard wire contract is unchanged.
  • A separate continuous producer-to-Studio devbox recording exercises six public websites against the original receiver implementation; it is attributed to those source heads. The current successor has the focused browser checks above.

The cached test runner was Vitest 3.2.4, while the workspace declares 4.1.11. Unsupported styles, resources and content produce a warning; animated content, remote resources and arbitrary HTML are deliberately outside the accepted paste subset. No capture-service or publishing acceptance is claimed.

Before

At the base commit, pasting the same OS clipboard envelope leaves the fixture unchanged and reports “Nothing to paste.”

Before: Ctrl+V of a copied element leaves the timeline empty

After

The original receiver capture below shows Ctrl+V rendering the element in the preview, saves its editable HTML, selects the five-second clip, and exposes it on the timeline. Captures use a fresh fixture project in Chrome. The separate six-site producer recording preserves the selected text and fonts, with outside-subtree artwork/backdrop limitations; it does not establish whole-page fidelity or packaged Desktop acceptance.

After: the pasted element renders and is a 5 s clip on the timeline

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 271 (base branch 271), smooth 172 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 (0)

@terencecho terencecho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed HEAD 4a4fb6b211adf2a6c9b7d0daf8188dc61ad25b5f against API/effective base 8be76fc86cda5b2a77d0ee23b65f582e85376042.

The fresh allowlisted output tree (packages/studio/src/utils/elementClipboardPaste.ts:112–166) and insertion inside the serialized history writer (packages/studio/src/hooks/elementClipboardPaste.ts:77–117) are good boundaries. Four P2 correctness issues remain:

[P2] Make the HTML/CSS paste namespace unique across composition files

packages/studio/src/hooks/elementClipboardPaste.ts:82–92

The ID census covers only the edited file, so the first external paste in both index.html and compositions/sub.html gets element-1 and matching descendant IDs. The compiler inlines the child into the same document; its CSS scoping adds an ancestor, not an exclusion from parent styles (packages/core/src/compiler/compositionScoping.ts:102–113). SVG collision repair does not rename these ordinary HTML IDs.

Valid example: paste <div id="parent"><h1>Parent</h1></div> with #parent h1{color:red} into the parent, and <div id="child"><h1>Child</h1></div> with h1{color:blue} into the child. Both can use width 100, height 50, warnings []. The parent's emitted #element-1 :is(#element-1-node-0 h1) also matches the child. Its two ID selectors beat the child's composition-prefixed one-ID selector: the blue child becomes red when assembled. A unique child HTML/CSS scope removes the match. The UUID currently passed only as fontScope does not fix this. Please cover parent/child assembly, not only repeated paste within one file.

[P2] Snapshot the internal clipboard before awaiting OS arbitration

packages/studio/src/hooks/useClipboard.ts:400–418

BASE evaluated await clipboardRef.current immediately. HEAD first awaits pasteSystemElement, then reads the mutable ref. With A copied, invoke paste while navigator.clipboard.readText() is pending, then select/copy B before that read completes. When the earlier read returns ordinary non-element text, the earlier paste inserts B instead of A. This is a cross-event schedule: packages/studio/src/hooks/appHotkeysDispatch.ts:125–129 does not await paste, and later copy replaces the ref at useClipboard.ts:388. Snapshotting the promise at invocation preserves A without changing external-envelope precedence. The existing arbitration test copies before invoking paste and misses this schedule.

[P2] Remap embedded nested styles when an imported clip is duplicated

packages/studio/src/utils/elementClipboardCss.ts:110–116

A valid payload containing <div><h1>Editable</h1></div> and @media all { h1 { color:red } } imports a normal timeline clip whose embedded rule targets #element-1 :is(h1). Duplicate that clip with Cmd+D: useClipboard.ts:507–514 reads saved markup and calls pasteTimelineClips(..., true), which renames the duplicate wrapper to element-1-2 but leaves CSS text targeting element-1. The existing repair only copies top-level CSSStyleRules, explicitly skipping nested rules (packages/studio/src/utils/clipboardLook.ts:44–64). The duplicate therefore loses its red style; a top-level rule is the working control.

This is a new-producer/old-consumer integration defect: the PR manufactures wrapper-scoped styles for supported @media/@supports imports, then exposes them to ordinary duplication. It is not a claim that this PR introduced the helper's historical limitation. Please remap the embedded stylesheet with the HTML IDs, including nested supported rules.

[P2] Preserve text newlines when inserting accepted preformatted content

packages/studio/src/hooks/elementClipboardPaste.ts:103–108

<pre>a\nb</pre> with empty CSS and valid dimensions is explicitly accepted, and the fresh-tree copier preserves its text. But this new caller routes serialized markup through pasteTimelineClips → insertTimelineAssetIntoSource, which prepends destination indentation to every serialized line after the first (packages/studio/src/utils/timelineAssetDrop.ts:164–171). In an unindented destination, saved text becomes a\n b; deeper indentation adds more spaces. Those spaces are visible inside <pre> and persist in history/reload. No-newline input is a control. The indentation helper predates this PR, but the new accepted external-content path needs a text-preserving insertion boundary rather than reindenting text nodes.

Evidence/scope: Source-derived BASE/HEAD/control traces and finite Python manual models corroborate these failures; no browser, React, PostCSS, compiler, repository test suite, or CI was executed. Audited the new implementations/tests, legacy clipboard path, metadata deltas, and actual dispatch/writer/duplication/compiler integration. Existing metadata/App/source-test HEADs were reviewed through full BASE plus exact delta; generated lockfile only through its exact delta. Strict whole-lockfile legacy-first semantic reading was not completed. Compiler context was scoped to integration ranges, not a whole-repository audit.

Verdict: REQUEST CHANGES
Reasoning: The new import path can leak styling across compositions, change an in-flight internal paste's payload, lose supported styles on duplication, and alter preformatted text during persistence.
— tai

@miguel-heygen

miguel-heygen commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator Author

Fixed the four findings from review 5545030742 in 774bd772c96bb1486ca4c641a5aba7360ddc8c0b:

  1. The wrapper, descendant IDs, stylesheet scope and font namespace now share a per-paste UUID. A real parent/child compiler-assembly regression verifies that the parent's selector cannot match the child; Chromium confirms the two headings retain red/blue and have unique IDs.
  2. Internal paste captures its clipboard promise before awaiting the OS read. A deferred copy-A → paste → copy-B schedule now inserts A, while the next paste sees B and external-envelope precedence remains covered.
  3. The existing style-copy path now traverses supported media/supports groups and preserves their conditions. External import → saved-DOM reload → ordinary duplicate retains nested styles; top-level and existing motion controls pass.
  4. Clipboard clip insertion preserves serialized text whitespace. <pre>a\nb</pre> stays exact at both destination indentations and in recorded history/reloaded DOM. Default asset insertion formatting retains its existing behavior.

All four regressions were observed failing before their corresponding fix. The same independent Chromium 152 caller probes pass at 774bd772 with zero page exceptions. Successor 81718dc123752e28c3ad411176e0322d1bf7a5b1 only removes one comment line to satisfy the repository comment ratchet; runtime code and the four fixes are unchanged. The exact comment check and normal hooks pass; browser tests were not repeated for that comment-only delta. Focused suite: 158 tests across 10 files; Studio production build/typecheck and normal commit hooks pass. Tests used the existing cached Vitest 3.2.4 environment; hosted CI remains the current-head gate. Browser probes use local file adapters and production callers, and do not claim packaged Desktop or live-backend acceptance.

The two findings from current-head review 5547450149 are fixed in signed 8cd2a773f01c55c40600468abdb4996e78142f1c:

  1. ID deduplication records the actual rename map and rebinds the copied subtree’s embedded selectors before insertion, including nested media/supports rules. Copy A → navigate B → Paste twice with unchanged OS text keeps both imported titles styled through history/reload. The existing same-file global carryLook gate stays unchanged; destination-global styles are not inherited.
  2. The same map rebinds local SVG href/xlink fragments and URL references in presentation attributes, inline styles and embedded stylesheets. Import → Duplicate → Cut original → save/history/reload retains references owned by the surviving clip. External/data URLs, quoted literals, text and script contents have preservation controls.

Both defects fail on reviewed 81718dc1 and pass with the correction in committed production-hook regressions. Independent Chromium 152 runs of the same mounted production hook observe the second title changing from black to red after saved/history reload, and the surviving SVG changing from a missing target/0×0 bounds to its own target/100×100 bounds, with zero page errors. The browser delete step removes the original DOM and serializes/reloads the survivor; the committed Cut test uses a local deletion/history adapter. These are not server delete-endpoint or packaged-app acceptance claims.

Validation: 170 Studio tests/12 files, 19 core tests/2 files independently during spec review, core/Studio builds, typechecks and normal hooks pass. The existing core selector scanner is reused through a narrow public export; its canonical package-subpath descriptor and the generator check across 14 workspaces pass. The wire contract is unchanged. Native evidence is on behavior commit d45b80bc; successor 8cd2a773 changes only the descriptor and all six native-tested source hashes match it. Cached Vitest 3.2.4 versus declared 4.1.11 remains disclosed; hosted CI must validate this new head.
The three findings from review 5548568683 are fixed in signed 7bb20141f36c56fbb06351d91161aceba07f27e6:

  1. The shared selector rebinder follows actual rewritten fragment attributes as well as ID tokens. Attribute predicates retain their match and specificity across supported operators/flags; unrelated title literals stay unchanged. Repeated Copy A → B → Paste twice keeps both use elements at opacity .25 after history reload.
  2. Same-file look copying rebinds declaration resource URLs with the full clone map. An edited blue clone now selects its own gradient while the original keeps its red gradient.
  3. Initial import uses the same predicate mapping for namespaced IDs and actual sanitized fragment attributes, including the initial SVG variant found while fixing this review. The accepted [id="title"] heading stays red through reload, matching the #title control.

Identical independent Chromium 152 production-hook probes fail all three reported schedules on reviewed 8cd2a773 and pass all three on 7bb20141, with controls passing and zero page errors. Six production-source hashes bind that run to the signed head. The browser uses local file/history/source-edit adapters; no full Code-panel, server endpoint or packaged-application claim is made. Validation: 185 focused tests/13 files, targeted operator/caller regressions, types, Studio production build, package descriptor/comment checks and normal signed hooks pass. The initial hook complexity/duplicate-test rejections were resolved through helper extraction without bypass. Cached runner-version limits above remain; current-head hosted CI and external re-review remain required.

The two findings from review 5550330015 are fixed in signed 3a6d555b2803588b3d2ea03516f90b46990f7361:

  1. Accepted attribute writes record actual input/output names and values, including xlink-to-href normalization and escaped local URL canonicalization. Selector adjustments compare complete original/final attribute sets per node, including unchanged attributes, and use zero-specificity output-node guards. Mixed xlink/ordinary href nodes remain distinct. The existing core name parser also supplies presence predicates; accepted tags, attributes and resources are unchanged.
  2. Same-file carried and embedded rules share predicate preservation with complete clone ID/resource facts. Internal clone facts use an inert template to group attributes, while actual authored-source edits retain their original scanner spans. Both Duplicate and Copy/Paste preserve negative suffix predicates for imported IDs and authored SVG references; clone-local gradients and conditional rules remain covered.

The identical independent Chromium 152 production-hook probe observes five failures on reviewed 7bb20141 becoming passes, with two additional dual-attribute controls remaining correct. Independent spec review caught initial-presence and internal-clone dual-attribute regressions during the repair; both are fixed before this push. All seven final cases survive serialized history reload, controls pass and page errors are zero. Eight relevant production-source hashes bind the run to this signed head.

Validation: 203 focused Studio tests/13 files, 36 targeted caller/helper tests, 20 core focused tests/2 files, public-subpath smoke, core and Studio builds, typechecks, package/comment checks and normal signed commit hooks pass. Cached Vitest 3.2.4 versus declared 4.1.11 remains disclosed. A real-Chrome namespace witness confirms unqualified/empty-namespace href predicates do not match xlink-only attributes; named-prefix lexical coverage does not establish arbitrary CSS namespace URI resolution. Browser file/history/selection adapters are local, rather than full UI/server/packaged acceptance. Current-head hosted CI and external re-review remain required.

The synthesized-attribute finding from review 5551414454 is fixed in signed c2a3d0e51b5a616f2293966652b06178e64e9d53:

The per-node attribute facts now represent original absence explicitly as null, while an authored empty value remains present. Geometry's root-style write and the sibling safe-button-type write feed that model. The writer retains existing original authored facts instead of adding a second contradictory fact. Positive and negated presence/value predicates therefore retain their pre-import truth, while mandatory geometry and safe button behavior remain applied.

Meaningful failing-first consumer/helper regressions show four failures and 41 passing cases on the reviewed source, then all 45 pass. Coverage includes absent, empty and authored style; positive and negated predicates; unaffected descendants; duplicate/save/history/reload; and absent/authored button type. The initial test draft over-counted duplicate carried declarations in two controls; its assertions were corrected and the old-source failure run repeated before production edits.

Independent identical Chromium 152 production-hook runs observe all four old failures becoming passes, plus passing authored/empty-style and descendant controls. The prior seven Chromium cases also pass, all through history reload with zero page errors. Eight production/core/generated hashes and both script hashes bind these runs to this signed head. Validation: 212 focused Studio tests/13 files, 45 targeted tests, production build and normal signed hooks including core/Studio/scripts types pass. Independent spec review also passes 324 original/output predicate comparisons and 54 focused tests. No wire contract, sanitizer allowlist, accepted resources, scanner or dependencies changed. Cached Vitest 3.2.4 versus declared 4.1.11 and the existing namespace/local-adapter limits remain; hosted CI and current-head external review remain required.

The HTML default attribute-value case-matching finding from review 5552390990 is repaired in signed 1b6909211c5dac11b05f5d86097e4ef5d09e442b.

The shared predicate model now carries transient element context from both accepted import and internal source parsing. Unflagged value predicates use a cached inert placeholder probe in that element's own document and namespace; only the predicate comparison folds ASCII when the native default requires it. Explicit i and s remain overrides. These facts are not persisted or added to the clipboard wire format, and authored source edits retain their existing spans.

Failing-first production caller/helper coverage records nine failures with 48 controls passing, followed by all 57 targeted tests passing. Independent Chromium 152 shows all six uppercase-button operators losing originally matching red styling on reviewed c2a3d0e5, then preserving it through paste/history reload with the repair; lowercase and explicit-i controls remain correct. Four native helper comparisons preserve truth for HTML class, SVG feFuncA type, HTML button type, and HTML elements in an XML document. All thirteen earlier browser regression cases also pass with zero page errors. The first generated probe accidentally duplicated the equals sign, was discarded, and was corrected before the accepted comparison. Chromium's explicit-s syntax is unsupported; its helper tests are not a native-paint claim. Local clipboard/file/history/selection adapters and cached runner limits remain explicit. Validation: 224 focused Studio tests across 13 files, 57 targeted tests, application/ESM/DTS build, core/Studio/scripts types, normal signed hooks, exact comment ratchet and package-subpaths pass. Eight production/core/generated source hashes and three probe hashes bind the browser runs to this exact signed commit. Independent spec review passes eight additional tests, including 144 contextual comparisons, and 66 focused tests across three files. Separate quality review also cleared the exact signed commit; current-head hosted CI and external review remain required.

The structural-selector finding from review 5554279839 is repaired in signed c7e02a8e407faab0300622d35c741d86b7316a44.

Generated stylesheet nodes no longer become siblings of the captured roots. They travel temporarily with copied markup, then leave the saved content tree and become owned blocks in the last preceding active stylesheet, retaining their relative order against authored rules. The existing content tree stays intact. A selected media-qualified stylesheet retains its authored rules under their original condition; imported CSS remains unconditional. Inert style/template content stays unchanged. Conditional imports, namespace-bearing or titled selected sheets and preceding body stylesheet links fail clearly before file/history writes; no external stylesheets are fetched. The shared copy path reads current saved CSS and carries only styles owned by IDs within the selected subtree, for timeline clips and full imported-root DOM elements. Existing clone ID/reference rewriting rebinds both selectors and owners. Destination source remains edited by spans; the public clipboard contract and sanitizer/resource policy are unchanged.

Parent Chromium 152 reproduces eight failures and four controls on the reviewed source across twelve structural schedules; the final revision passes all twelve through paste, duplicate, cross-file paste and saved/history reload. Additional checks cover stylesheet adjacency, no-ID geometry guards, actual DOM copies after a saved CSS edit, owner-ID isolation, and the existing case/geometry/SVG/resource regression matrix. Two local candidates were rejected before push: one added an ancestor that changed descendant selector truth, and one prepended CSS ahead of existing head styles and changed equal-specificity cascade order. Spec also caught a head relocation regression against a preceding authored body stylesheet, then an inactive titled-stylesheet regression. Chromium confirms reviewed1b69 keeps imported red while the initial1171 repair loses it to black; the final narrow guard rejects that selected nonempty-title target before file/history changes. Empty-title and untitled controls remain supported. These cases are covered by identical before/final browser witnesses, including a following-body-rule control and host clip adjacency/position controls. All accepted runs have zero page errors. The broader eleven-script matrix is attributed to1171; the final six-script recheck covers title abort atomicity, twelve structural cases, HEAD/BODY order, media/inert controls and prior unsupported boundaries. Twelve source hashes and six probe hashes bind the final recheck to this signed successor. Only the selected-title guard and shared attribute decoder changed between the broader matrix and final revision.

Validation: all 308 impacted Studio/source-patcher tests across 14 files, application/ESM/DTS build, affected core/Studio/scripts typechecks, and normal signed commit hooks pass. The normal complexity gate required helper extraction; final complexity and dead-code findings are zero, with four warning-only test clone groups. All accepted browser runs occurred after that extraction. The same independent spec reviewer and quality reviewer cleared this exact signed revision. Spec independently passes 79 focused tests across three files plus the repaired BODY-order witness; both reviewers verified the committed source and final probe hashes. The browser uses mounted production clipboard/store/encoder callers with explicit local clipboard/file/history/selection adapters; this is not full Studio UI/server or packaged Desktop acceptance. Cached Vitest 3.2.4 differs from declared 4.1.11. Current-head hosted CI and external re-review remain required.

The project-identity finding from review 5555509988 is repaired in signed 7a2c359ee6e6abbb7e4e3eee4a70e1c8e04a8308.

Paste snapshots a transient project identity before native clipboard arbitration. A project change invalidates the operation, even if navigation returns to the same project. Both internal fallback and accepted external-envelope paste revalidate after their asynchronous waits and within the queued source transformation before writing/history. Already-started consistent saves finish in their captured project; stale completions skip selection and preview reload. No clipboard wire data, sanitizer/resource policy or dependency changes.

Parent Chromium 152 reproduces the reported sequence with completed Copy A and identical A/B files: while native read is pending, navigation to B leads reviewed c7 to read B and write/history A with the expected-content precondition passing, losing the clone border (0px instead of 5px). The identical final probe retains no-navigation styling and cancels navigation before writes/history. Eight final native schedules cover internal and accepted OS-envelope arbitration, A→B→A, queued file-read waits and no-navigation controls, all passing with zero page errors; seven production source hashes plus the probe hash bind them to this signed head. Additional stale schedules enforce the chosen cancellation behavior and are not claimed as separate prior style-loss reports. Local native-read, file/history and navigation adapters remain bounded; this is not full Studio/server or packaged Desktop acceptance.

Validation: seven new actual-useClipboard/useStableHandlers schedules fail six/pass one on reviewed c7 and pass seven with the repair. The existing 25 source/arbitration tests pass, including Copy later during native read. The full impacted suite passes 315 tests across 15 files; types, application/ESM/DTS build and normal signed hooks pass. The same spec reviewer cleared the signed source, independently passing 32 focused tests serially and two additional pending-payload/issued-save schedules. The same quality reviewer independently cleared the three-file delta and verified the signed source, native hashes and package export gate. An initial concurrent spec run retained one failure in the existing 10 ms copy-failure timing test; the serial 32-test run passed without source changes. Cached Vitest 3.2.4 versus declared 4.1.11 remains disclosed; hosted CI/external re-review are the current-head gates.

The CI follow-up separates clipboard arbitration, native-envelope validation and saving within the existing two hooks. It removes the new Paste complexity finding without changing thresholds, suppressions, clipboard policy or project guards. Fallow 2.75.0 passes the stricter all-findings gate (old exit 1, final exit 0), with zero health/dead-code findings and ten unchanged warning-only test-clone locations. The old exact local default command returned 0 despite the hosted failure; that attribution discrepancy remains documented rather than called a CI flake. The 315 tests, build, types, normal hooks and unchanged eight-schedule browser probe pass on this signed successor. Same spec review also passes the pending-payload and already-issued-save boundary schedules; current-head hosted CI and external re-review remain required.

@terencecho terencecho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source-only review of 81718dc123752e28c3ad411176e0322d1bf7a5b1 against effective/API base 8be76fc86cda5b2a77d0ee23b65f582e85376042.

The four findings in the previous review are repaired by 774bd772c96bb1486ca4c641a5aba7360ddc8c0b, with meaningful regression sources retained. In particular, packages/studio/src/hooks/useClipboard.ts:401 snapshots the internal clipboard before OS arbitration, and packages/studio/src/utils/clipboardLook.ts:54–75 preserves nested media/supports conditions. The shared UUID namespace and whitespace-preserving insertion also address their cited failures. These are not being refiled.

Important

1. [P2] Rebind embedded styles on cross-file internal paste — packages/studio/src/utils/elementClipboardPaste.ts:160–164

Import {html:'<div class="title">Title</div>', css:'.title{color:rgb(255,0,0)}', width:100, height:50, warnings:[]} through the versioned envelope into composition A. Copy that timeline clip, navigate to composition B in the same project, and paste twice without another Copy. Leave the OS clipboard unchanged: it equals ignoredSystemText, so the real internal fallback runs (packages/studio/src/hooks/elementClipboardPaste.ts:53–59).

The copied markup includes <style>#S :is(.title){…}</style>. The first B paste keeps wrapper ID S; the second gets S-2, but its embedded stylesheet still targets #S. deduplicateIds changes only ID attributes, and fromThisFile is false for A → B, skipping carryLook (packages/studio/src/hooks/useClipboard.ts:222–247,430–441). The second clip consequently loses its supported color rule in saved/reloaded source. Composition scoping does not infer this missing wrapper rename. Fresh external pastes get independent UUIDs, and same-file duplication takes the repaired look-copy branch; those working paths do not cover this case.

Rebind the imported subtree's own embedded selectors using its actual ID map regardless of source file, without broadly inheriting destination-file styles. Add import → copy A → paste B twice coverage. This differs from the repaired same-file nested-CSS finding.

2. [P2] Keep SVG fragment references local when duplicating — packages/studio/src/utils/elementClipboardPaste.ts:47–51

This fully supported envelope imports correctly:

{"html":"<svg viewBox=\"0 0 100 100\"><defs><symbol id=\"shape\"><rect width=\"100\" height=\"100\" fill=\"red\"/></symbol></defs><use href=\"#shape\"/></svg>","css":"","width":100,"height":100,"warnings":[]}

Duplicate the imported clip, then delete only the original. handleDuplicate calls pasteTimelineClips(..., true) (packages/studio/src/hooks/useClipboard.ts:507–518). The clone's definition becomes <scope>-node-2-2, while its <use> still references #<scope>-node-2 in the original: packages/studio/src/utils/clipboardPayload.ts:197–210 rewrites only id attributes. This fixture has no script/style blocks for carryLook to copy. Production deletion removes the original definition, leaving the surviving copy's artwork reference dangling. Compiler collision repair cannot recover it: the IDs are already unique and no deleted definition is recreated.

Apply the same ID map to local fragment consumers when cloning and cover import → duplicate → delete original → saved/reloaded copy. A CSS-selector-only repair for finding 1 would not repair this native SVG reference.

Both generic consumer limitations predate this PR. These findings concern the newly supported imported clips being routed into incompatible ordinary editing paths, not a claim that the legacy deduplication algorithm itself changed.

Scope and verification

Audited: the envelope/receiver/sanitizer, changed clipboard/look/insertion paths, fixing patch, surviving regression sources, and targeted production copy/duplicate/navigation/save/history/delete/compiler integration. Two independent source passes completed; the parent independently traced both defects and checked finite identity/reference models with working controls. All 26 changed raw versions were acquired and Git-blob hash verified against reconstructed BASE/HEAD trees; that is provenance, not a claim of full semantic coverage.

Trusting / limits: unchanged integration code outside recorded ranges and whole-repository behavior. HEAD bun.lock was read at the exhaustive one-line dependency delta/relevant entries, not fully; the primary pass also did not fully read BASE lock semantics, so its strict whole-lockfile legacy-first requirement was incomplete. Non-lock changed sources were covered end-to-end or via fully read BASE plus exact deltas. Verification was inert source inspection and finite Python-standard-library models, not sanitizer/browser/compiler execution. No tests, builds, CI queries, or runtime checks were run; author-reported execution results are not independently verified here.

— tai

Verdict: REQUEST CHANGES
Reasoning: The four earlier issues are repaired, but imported clips can still lose supported styling on cross-file paste or SVG artwork after duplicate/delete. Preserve both selector and local-resource identity across those editing paths before approving this head.

@terencecho terencecho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source-only re-review of HEAD 8cd2a773f01c55c40600468abdb4996e78142f1c against API/effective base 8be76fc86cda5b2a77d0ee23b65f582e85376042.

The six previously cited schedules are repaired: 774bd772 fixes namespace isolation, invocation-time clipboard capture, nested media/supports copying and whitespace; d45b80bc fixes ordinary embedded #ID selectors on cross-file paste and native SVG references after duplicate/delete. The current descriptor-only successor retains those changes. In particular, the source-span rebinder (packages/studio/src/utils/clipboardReferences.ts:83–103) preserves surrounding text/scripts instead of reserializing them. I am not re-filing the repaired schedules.

Three P2 correctness gaps remain:

1. [P2] Rebind fragment-attribute predicates with the attributes they inspect

packages/studio/src/utils/clipboardReferences.ts:34–39,50–55

An existing authored timeline clip can contain <style>use[href="#shape"]{opacity:.25}</style>, a <symbol id="shape"> and <use href="#shape">. Copy it in A, navigate to empty B, then paste twice without another Copy, leaving OS text unchanged/ordinary. The second paste renames shape to shape-2. HEAD now correctly changes its actual href to #shape-2, but replaceSelectorIdTokens deliberately skips attribute-selector contents, leaving use[href="#shape"] unchanged. The second use no longer matches its opacity rule. The cross-file path skips carryLook (useClipboard.ts:243–247,427–446).

At BASE, the reference and predicate both remained #shape, so that rule still matched while both identical definitions existed. Rebinding the corresponding predicate restores matching; unrelated literals such as [title="#shape"] must remain untouched. Save/history preserve the mismatch, and compiler collision repair cannot infer the missing old-value relationship after IDs are already unique. Please cover attribute predicates over rewritten fragment consumers, not only #ID selector tokens.

2. [P2] Keep the same-file look copier from overriding clone-local SVG resources

packages/studio/src/hooks/useClipboard.ts:243–247; packages/studio/src/utils/clipboardLook.ts:74–75

Import a supported SVG with gradient paint and .painted{fill:url(#paint)}, then Copy/Paste that imported clip in the same file at time zero. The new receiver produces an embedded rule #S :is(.painted){fill:url("#G")}. The rebinder correctly gives the clone #S-2 … {fill:url("#G-2")}. However, insertion puts the clone before the original, and subsequent carryLook scans the entire resulting document. It appends #S-2 … {fill:url("#G")} to the original's later stylesheet: only the selector is copied, not its declaration's resource map. That equal-specificity later rule overrides the correct clone-local one. The later G→G-2 iteration examines selectors, so it does not repair the URL.

Using the real Code panel, move the clone aside and change only its own G-2 gradient stops from red to blue. Its winning fill still selects original G, so its own resource edit has no effect. Removing the stale carried rule is the control. The existing cut-original regression removes that overriding stylesheet too and therefore misses coexistence. This is the newly supported import producer interacting with the legacy look copier, not a claim that arbitrary BASE SVG duplication was independent. Preserve clone-local resource declarations when carrying original look.

3. [P2] Preserve accepted ID attribute selectors during the initial import

packages/studio/src/utils/elementClipboardCss.ts:104–110; producer packages/studio/src/utils/elementClipboardPaste.ts:137–142,160

A valid envelope with html:'<div><span id="title">Heading</span></div>', css:'[id="title"]{color:red}', dimensions 100×50 and warnings [] is accepted. The fresh-tree copier changes the span's ID to S-node-1, but the sanitizer only rewrites #title syntax. It emits #S :is([id="title"]){color:red}, which matches no span, without an unsupported-content warning. The equivalent #title rule is the working control. No old-ID alias is retained for a later repair. This is silent style loss on the initial accepted paste, distinct from finding 1's internal clone/reference rewrite.

Scope and evidence

Audited: envelope/receiver/sanitizer and clipboard/insertion/look implementations, historical fixing patches and surviving regression sources; actual copy/paste/duplicate/navigation, saved-source lookup, serialized writer/history, Code-panel save/refresh and targeted compiler identity/style-order integration. Two independent source passes completed and the parent independently adjudicated these three mechanisms with finite value/cascade controls. Complete BASE/HEAD trees were reconstructed and all 32 changed raw versions were Git-blob verified; that establishes provenance, not semantic completeness.

Trusting / limits: parent fully read 24 changed versions and relevant context, with remaining metadata/test versions inspected through narrower deltas/patches or left acquired-only. The independent primary read all 30 non-lock changed versions; both locks remain partial. Strict whole-version BASE-before-HEAD reading was not completed. Compiler bundler was read at integration ranges, not end-to-end; no whole-repository semantic audit is claimed. These are source-derived selector/resource consequences, not observed browser paint. No repository/dependency runtime, tests, builds or CI queries were executed. Author-reported browser/test results remain attributed, not independently verified here.

— tai

Verdict: REQUEST CHANGES
Reasoning: The prior six schedules are repaired, but accepted styles can still silently stop matching after ID/reference changes, and same-file copying can override the clone's own SVG resources. These are concrete editing/persistence defects rather than CI or missing-runtime-evidence objections.

@terencecho terencecho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source-only re-review of HEAD 7bb20141f36c56fbb06351d91161aceba07f27e6 against API/effective base 8be76fc86cda5b2a77d0ee23b65f582e85376042.

The actual before/after predicate checks in packages/studio/src/utils/clipboardSelectors.ts:33–64 preserve both positive and negative matches, and the source-span rebinder avoids reserializing unrelated content. The nine exact schedules in the previous review and its two predecessors are repaired: 774bd772 addresses namespace isolation, invocation-time clipboard capture, conditional styles and whitespace; d45b80bc addresses cross-file embedded selectors and duplicate/delete local resources; 8cd2a773 retains the package descriptor repair; 7bb20141 addresses ordinary fragment predicates, carried gradient declarations and initial ID predicates. Those repaired schedules are not being refiled.

Two distinct correctness gaps remain:

1. [P2] Record the actual accepted resource-attribute transformation

packages/studio/src/utils/elementClipboardPaste.ts:74–80 (producer at 50–54)

A valid envelope can contain:

{"html":"<svg width=\"100\" height=\"100\"><defs><path id=\"shape\" d=\"M0 0h100v100H0z\"/></defs><use xlink:href=\"#shape\"/></svg>","css":"use[*|href=\"#shape\"]{opacity:.25}","width":100,"height":100,"warnings":[]}

The resource and wildcard-namespace selector are accepted. copyResource changes xlink:href="#shape" into ordinary href="#S-node-2", but the recorder then asks for clean.getAttribute("xlink:href"), gets null, and emits no before/after fact. ID facts do not substitute for an href fact. The emitted [*|href="#shape"] predicate therefore changes from true to false: the accepted quarter-opacity style silently disappears on initial paste and in saved source. Ordinary href is the working control because its output attribute still has the queried name.

The same recording gap occurs when safeCssValue accepts/canonicalizes an escaped local URL: fill="url(\23 paint)" with rect[fill$="paint)"]{opacity:.25} becomes a quoted, scoped URL, but the literal-only rebindClipboardUrls probe sees no original url(#...) and records nothing. Preserve the actual accepted input/output attribute identity and value, rather than rediscovering writes with a narrower literal probe; cover normalization and escaped local resources through the receiver.

2. [P2] Preserve predicate truth in same-file carried selectors too

packages/studio/src/utils/clipboardLook.ts:82–88; caller packages/studio/src/hooks/useClipboard.ts:243–247

Import {html:'<div id="source">Text</div>', css:'[id$="-2"]{background-color:red}', width:100, height:50, warnings:[]} with a scope S that does not end in -2, then select that imported timeline clip and Duplicate it in the same file while keeping the original.

The initial child ID is S-node-0, so the suffix predicate is false. Duplication makes it S-node-0-2. The clone-owned stylesheet is correctly rebound with an exclusion for the new value, preserving the original false predicate. However, carryLook subsequently scans the original stylesheet and copies #S :is([id$="-2"]) as #S-2 :is([id$="-2"]), replacing only the hash-ID selector. This second, unexcluded rule matches the cloned child and gives it a red background the original never had. Rebinding declaration URLs on line 88 does not repair selector predicates.

At BASE the external import does not exist; this is the new accepted producer entering ordinary duplication. The same bypass also regresses an existing authored SVG clip with #clip use[href$="-2"]{opacity:0} and href="#shape": HEAD rewrites the cloned href to #shape-2, and the carried rule now hides it, whereas the BASE href and predicate remain unmatched. Cross-file paste skips carryLook and retains the correct exclusion; removing the incorrectly carried rule is another control. Use the same before/after predicate preservation for carried rules, and test through same-file duplicate/paste rather than only the selector helper.

Scope and evidence

Audited: all 32 non-lock changed BASE/HEAD versions read end-to-end, with existing BASE versions read before HEAD; exact changed-leaf census and raw-blob hashes against fully reconstructed trees; five fixing/successor patches, all current public review/discussion/commit texts, surviving regression sources, and actual keyboard/copy/paste/duplicate/saved-source/queued history/project-bound writer paths. Parent independently adjudicated the two findings; independent primary and adversarial source passes completed. Bundler/preview/SVG handling was inspected at relevant integration ranges (SVG namespacing end-to-end): these witnesses have unique IDs, and later processing has no original attribute facts with which to undo either incorrect predicate result.

Trusting / limits: unchanged integration outside recorded ranges, whole-repository behavior, and author-reported runtime results. bun.lock used the specifically authorized BASE-first inert parsed/scanned dependency-record equality/delta method, not direct FULL reading: all 1,074 package records are unchanged; the sole delta adds Studio's direct postcss dependency, using an existing resolution. Unchanged integrity literals were hash-bound/proven equal, not reproduced/read individually. The adversarial pass's narrower metadata/App ranges and original lock chronology remain limitations, not retroactively full coverage; the primary pass independently reports full legacy-first reading of all 34 changed versions, including both locks. Findings are source-derived with finite manual value/predicate controls, not observed browser paint. No repository/dependency runtime, tests, builds or CI queries were executed.

— tai

Verdict: REQUEST CHANGES
Reasoning: Accepted resource transformations can still silently lose matching styles, and same-file duplication can reintroduce matches deliberately excluded by the new rebinder. Both need integration-level repair before approving this head.

@terencecho terencecho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source-only re-review at HEAD 3a6d555b2803588b3d2ea03516f90b46990f7361, against effective/API base 8be76fc86cda5b2a77d0ee23b65f582e85376042.

The invocation-time internal clipboard snapshot (useClipboard.ts:401–419) and per-node attribute grouping (clipboardSelectors.ts:66–109) address the earlier races and predicate cross-contamination. I traced the prior fixing commits and current regression sources: UUID scope uniqueness, nested media/supports carry-over, significant whitespace, repeated cross-file embedded styles, clone-local references, ID predicates, and accepted-attribute normalization are repaired for the previously reported cases. One additional boundary remains.

Blocker — [P2] Preserve predicates when geometry adds an absent root attribute

packages/studio/src/utils/elementClipboardPaste.ts:178–205, especially the direct capturedRoot.setAttribute("style", ...) at lines 181–184.

An otherwise supported HTML root with no authored style attribute always gains one here, but that absent→present transformation never enters attributes. The later finalAttributes/changedNodes/writes pipeline only examines original attribute writes. With <div><span>Text</span></div> there are no attribute facts or ID mappings at all, so rebindClipboardSelector leaves [style] unchanged.

Concrete accepted public-envelope input:

{"html":"<div><span>Text</span></div>","css":"[style]{display:none}","width":100,"height":50,"warnings":[]}

Put its encodeElementClipboard text on the OS clipboard and paste into a writable composition without an internal clipboard override. Neither original element matches [style]; the saved captured root does. The emitted #<scope> :is([style]){display:none} therefore hides the imported content, and no unsupported-content warning is added. Conversely, div:not([style]){background:red;color:white} loses its originally matching background/text styling. These use allowed elements, declarations and selectors—not removed active content or remote resources.

The result is not merely a transient preview mutation: pasteSystemElement inserts the prepared HTML in the queued source transform; studioFileHistory.ts records that exact after-content, and useProjectFileWriter.ts:90–100 sends it unchanged as the PUT body. Reload/history cannot reconstruct the original predicate truth.

Please include synthesized attributes (with explicit original absence) in the per-node before/after predicate model, or otherwise preserve those predicates while applying geometry. Add regression coverage for both positive and negated style-presence selectors on an initially unstyled root; keep authored-style and unaffected-descendant controls.

Evidence/limits: This is a source-derived finite attribute/predicate trace through the production entry, transform and writer—not an executed browser test. The effective base has no portable receiver; this is introduced accepted-content corruption in the new path, not a claim that the base rendered the same payload correctly. No repository tests, browser/native runs, CI queries, live services or merge actions were performed. I am not filing the separate dual-href/xlink:href candidate because its expected native precedence was not independently established.

Audited: Complete changed-leaf/tree/blob census (26 leaves, 40 versions); 38 non-lock versions read directly or through a fully read base plus exhaustive metadata delta; current regression sources; eight repair implementation patches; production clipboard/arbitration, sanitizer, CSS/reference/carry-over, insertion and exact source-history/write handoff; 21 bounded cross-feature pairs; independent adversarial source pass.

Trusting / partial: bun.lock structural and exhaustive-delta review only (the added workspace postcss row; no resolution change), compiler/hotkey/file-manager context at relevant integration ranges, and browser/server runtime behavior not executed. Strict all-base-before-all-head reading order was not achieved for some metadata/generated glue and the lock. No whole-repository semantic audit is claimed.

— tai

Verdict: REQUEST CHANGES
Reasoning: An accepted no-style HTML root can silently lose its styling or become hidden because mandatory geometry changes selector truth without recording the transformation.

@terencecho terencecho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed c2a3d0e51b5a616f2293966652b06178e64e9d53 against effective base 8be76fc86cda5b2a77d0ee23b65f582e85376042.

The prior root-style finding is repaired: synthesis now records original absence distinctly from an empty authored value, and the final per-node facts feed selector rebinding (elementClipboardPaste.ts:67–76,200–219).

Blocker

[P2] Preserve HTML's default attribute-value case matching — packages/studio/src/utils/clipboardSelectors.ts:47–53. valueMatches folds only with explicit i, but unflagged HTML type selectors already match ASCII-case-insensitively. A valid accepted envelope with HTML <div><button type="BUTTON">Text</button></div> and CSS button[type^="but"]{color:red} demonstrates the mismatch:

  • The original selector matches the authored button. The receiver accepts type="BUTTON", then safely normalizes it to type="button" (elementClipboardPaste.ts:88–103,132–133).
  • The fact model instead computes before=false / after=true, so predicateChanges adds an exclusion. That exclusion's target-qualified [type="button"] matches the output button, causing the rewritten rule to stop matching. The accepted styling is silently lost and the exclusion is saved with the pasted markup.
  • Lowercase authored type="button" and an explicit i are controls: neither receives this incorrect exclusion.

The implicit matching contract is bound to the HTML attribute-value WPT source at the exact snapshot referenced by pinned jsdom: its HTML/default ^= assertions cover type. This is a source-derived witness, not a browser test run. Make the truth model respect the element/document's default matching semantics while retaining explicit s/i behavior; do not globally lowercase SVG or arbitrary attribute values. Add an initial-paste regression for the uppercase/unflagged case.

Audited: All changed non-lock BASE/HEAD versions, receiver/core envelope, shared selector/reference utilities, copy/paste/carryLook integration and regression sources; relevant compiler, writer/history, hotkey and project-identity context. Prior fixing patches and public reviews were reconciled; an independent bounded source audit completed, with this contract question separately resolved by the parent review.

Trusting / limits: Lockfile sections plus the exact lock delta, not the whole lockfile; author-reported browser/Desktop results were not rerun. No repository runtime, tests, CI queries or live services were executed; no whole-repository semantic claim.

Verdict: REQUEST CHANGES
Reasoning: The prior absence-fact fix holds, but a valid accepted HTML button still loses matching styling through the new predicate-preservation path.

— tai

@terencecho terencecho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source-only re-review of HEAD 1b6909211c5dac11b05f5d86097e4ef5d09e442b against API/effective base 8be76fc86cda5b2a77d0ee23b65f582e85376042.

The prior HTML default-case finding is repaired: transient Element context reaches both import and clone facts, and the unflagged comparison uses the element's own document/namespace (packages/studio/src/utils/clipboardSelectors.ts:31–75). I traced the earlier fixing patches and surviving regressions; the previously reported namespace, snapshot, whitespace, clone-resource and attribute-predicate cases are not being refiled.

[P2] Keep the stylesheet out of the captured root's structural sibling set

packages/studio/src/utils/elementClipboardPaste.ts:220–223

The new wrapper.prepend(style) changes the element sibling list against which accepted structural selectors are evaluated. A valid public envelope is:

{"html":"<div class=\"card\"><span>Text</span></div>","css":".card:not(:first-child){display:none}","width":100,"height":50,"warnings":[]}

Put its encodeElementClipboard text on the OS clipboard and paste into a writable ordinary top-level index.html composition. The captured card is the only element in the supplied fragment, and copying the supported content initially makes it the wrapper's first/only element child. The sanitizer accepts this selector and display:none, emitting #<scope> :is(.card:not(:first-child)){display:none} (elementClipboardCss.ts:89–107). Prepending the generated style changes the children to [style, div.card], so the previously false predicate becomes true and hides the content. No unsupported-content warning is added. Positive :first-child/:only-child styling likewise stops matching.

This reaches saved/reloaded output: the production receiver passes the prepared wrapper's outerHTML through queued clip insertion and file history (packages/studio/src/hooks/elementClipboardPaste.ts:77–123). In the ordinary top-level Vite preview path, compiler coalescing handles head styles; the body-descendant style remains beside the card (packages/core/src/compiler/htmlBundler.ts:736–746,1069–1374). Identity stamping adds attributes rather than removing this sibling. I am not claiming every template/mounted child-composition path fails: those have separate style-hoisting branches.

Keep stylesheet storage outside the captured content's structural sibling set, and cover structural-selector truth through paste and saved reload. Merely appending the style is not a general fix: it instead changes :last-child and :only-child. This is introduced by the new receiver, not a claim that BASE supported the same OS envelope.

Audited: All 13 existing changed non-lock BASE versions before all 25 non-lock HEAD versions; complete reconstructed BASE/HEAD trees and raw Git-blob verification of 26 changed leaves/40 versions; all 11 fixing patches, current public record and regression sources; actual clipboard/hotkey, sanitizer/rebinding, copy/duplicate, insertion, queued writer/history and scoped root-preview integration. Two independent source lanes completed; the parent independently adjudicated this finding and cross-feature pairs. A bounded matching-line census covers 38 acquired production/context sources, not the whole repository.

Trusting / limits: Both lockfiles were exhaustively structurally/delta scanned, not directly FULL-read by the parent: only Studio's direct postcss workspace row changes; all 1,074 package records are equal. Context outside recorded integration ranges, lower library implementations, external capture/packaged Desktop and author-reported runtime results remain unverified. The finding is a source-derived structural-selector trace with a finite manual sibling model, not observed browser paint. No repository/dependency runtime, tests, builds, CI queries or live services were executed. No whole-repository semantic claim.

— tai

Verdict: REQUEST CHANGES
Reasoning: The previous case-matching repair holds, but adding the generated stylesheet as a content sibling can silently hide otherwise accepted pasted content or remove its structural-selector styling.

@terencecho terencecho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source-only re-review of HEAD c7e02a8e407faab0300622d35c741d86b7316a44 against API/effective base 8be76fc86cda5b2a77d0ee23b65f582e85376042. One new P2 remains.

The owned-style relocation removes generated stylesheet nodes from the content sibling set, while preserving the selected sheet's order and media behavior (elementClipboardStyles.ts:82–142). The receiver still funnels accepted elements through the shared queued file/history write (hooks/elementClipboardPaste.ts:74–114).

[P2] Keep the project identity consistent across the new OS-clipboard await

packages/studio/src/hooks/useClipboard.ts:408–425 introduces a pending native-read boundary, but the internal fallback rereads projectIdRef.current at line 431 while retaining the invocation's composition path and project-scoped writer/history callbacks.

With an already-completed internal Copy in A, start Paste in A, switch the mounted Studio to B while the native read is pending, then let that read fall through to the internal clipboard. The fallback reads B and computes fromThisFile against B, but useStableHandlers deliberately retains A's writer/history epoch. Consequently it writes A. If A and B have identical before-content, the explicit content-hash precondition succeeds rather than detecting the mixed project identity.

For example, both index.html files can contain an ordinary #card clip styled by an unowned head rule #card{border:5px solid red}. The copy's markup does not contain that head rule. The fallback renames the clone to card-2, incorrectly skips carryLook because payload.projectId is A and pid is B, then persists the unstyled clone in A. B is not written. The existing source test covers a later Copy during the native await, not this project transition.

Capture/revalidate one project epoch across arbitration, reading, same-file classification, writing and history, or cancel when it changes. The inline comment gives the producer, writer and BASE/control trace.

Earlier findings reconciled

I checked the actual fixing patches and surviving current regression sources; these previously reported examples are addressed and are not being refiled:

  • Review 5545030742 → 774bd772 / 81718dc1: per-import UUID, invocation payload snapshot, supported conditional CSS and significant whitespace.
  • 5547450149 → d45b80bc / 8cd2a773: repeated cross-file embedded selectors and clone-local SVG/resource references; canonical selector export descriptor retained.
  • 5548568683 → 7bb20141: fragment/ID predicates and full-map carried declaration URLs.
  • 5550330015 → 6e461ae4 / e4fd2c71 / ebb07ea5 / 3a6d555b: actual accepted attribute writes and complete per-node clone/carry facts.
  • 5551414454 → c2a3d0e5: synthesized absence versus authored-empty attributes.
  • 5552390990 → 1b690921: element/document-context default case matching, retaining explicit flags.
  • 5554279839 → 9313b805 / 23b71749 / 1171d8e6 / c7e02a8e: structural topology, stylesheet order/media, and rejection of unsupported selected sheets before writes.

Scope and limits

Audited: complete reconstructed BASE/HEAD trees and all 30 changed leaves/46 raw versions; all 15 existing changed non-lock BASE versions read before HEAD; all 14 standalone changed production TS implementations end-to-end, five changed regression files end-to-end, full effective diff, 15 historical fixing-patch records, current public record, and relevant clipboard/hotkey/project-navigation/scoped-handler/reader/writer/history/version/server-write sources. Independent conventions and correctness/adversarial lanes completed; I independently adjudicated this finding and the 21 cross-feature pairs across namespace, arbitration, conditional CSS, whitespace, references, predicate facts and owned-style relocation.

Trusting / partial: App.tsx, six other changed test files, package descriptors/manifests and generated glue were reviewed through explicit integration ranges/full diffs rather than claimed FULL; compiler context remains bounded to recorded ranges. Both locks were structurally/delta scanned, not fully read: all 1,074 resolved package records are equal; only Studio's direct postcss workspace dependency is added. Context acquisition is not whole-repository semantic coverage.

The finding is a source-derived await/identity trace with finite manual BASE/HEAD and no-navigation/different-content controls—not an executed browser or application reproduction. It is conditional on a native clipboard Promise spanning navigation; no browser-specific timing was experimentally established. No repository/dependency runtime, tests, builds, CI queries or live services were run. Author-reported browser results remain attributed claims, not my execution evidence.

— tai

Verdict: REQUEST CHANGES
Reasoning: The previous repairs hold for their reported examples, but the added native-read await can split the internal paste's read/classification identity from its actual write/history project and silently persist a malformed clone.

Comment on lines +408 to +412
const pendingPayload = clipboardRef.current;
if (
await pasteSystemElement(
{
projectId: projectIdRef.current,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Capture or revalidate the project epoch before this await. pendingPayload is snapshotted, but the fallback rereads projectIdRef.current at line 431; its activeCompPath, writeProjectFile and recordEdit are still from this invocation. useStableHandlers.ts:13–30 intentionally keeps an old wrapper in its original project epoch.

Valid source schedule: finish internal Copy of an ordinary #card clip in A; A and B both have the same index.html, including unowned head CSS #card{border:5px solid red}. Invoke Paste in A, leave the native clipboard Promise pending, switch the hash to valid B and let useServerConnection.ts:159–188 update the still-mounted Studio, then resolve the native read to ordinary text/null. Fallback now reads B (timelineTimingSync.ts:35–50) and sets fromThisFile=false, while the retained writer PUTs A (useProjectFileWriter.ts) and retained history claims A. The identical before-bytes satisfy the explicit SHA-256 If-Match (studioFileVersion.ts:42–48; server helpers/fileVersion.ts:21–30). The saved A clone is card-2, but useClipboard.ts:251–254 skips the carryLook that would supply its ID-keyed styling. B remains unchanged.

At BASE, an already-resolved internal copy lets the immediate microtask capture A before the later navigation task, so reads/writes and same-file look stay in A. HEAD without navigation also works; different before-bytes generally conflict instead. This is a source-derived cross-await schedule, not an observed browser run or a same-turn race. Add a project-transition regression and keep read/classification/write/history bound to one epoch, or cancel a stale paste.

@miguel-heygen miguel-heygen Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9766fd81c6c4ac9d947b776d1a78dc35798f7b12; the repair is retained at current head 7a2c359ee6e6abbb7e4e3eee4a70e1c8e04a8308.

  • useClipboard.ts:408 captures the project object before native clipboard arbitration and passes its captured ID to the reader. Line 428 derives pid from that same object; classification, file reads and history saves use this captured ID rather than rereading the mutable ref.
  • readPastePayload:43–47 cancels after both native arbitration and the captured internal-payload await when the project epoch changed. The queued transform and post-save UI also check that epoch. The ref object is replaced on navigation (line 280), including A→B→A.

The seven project-epoch regression cases cover navigation during the native/payload/file waits, queued writes and UI, plus an already-issued A save remaining in A. The original identical-content read-B/write-A styling loss fails on c7; eight controlled Chromium152 schedules pass at the signed current head with zero page errors. Spec and quality cleared that head, and normal CI is ready. This uses actual hooks with local clipboard/file/history/navigation adapters; it is not full Studio/server/packaged or real OS timing evidence.

@terencecho terencecho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source-only re-review of HEAD 7a2c359ee6e6abbb7e4e3eee4a70e1c8e04a8308 against API/effective base 8be76fc86cda5b2a77d0ee23b65f582e85376042. Two P2 correctness issues remain; concrete inputs and production consumer traces are in the inline comments.

  1. Preserve selector-list specificity. Wrapping a complete comma-separated list in one :is() lets an unmatched ID arm increase the specificity of a matching class arm. The accepted .card, #other / .card.selected example changes the card's winning color from blue to red, and that rewritten CSS is persisted.
  2. Keep owned styles inside the selected template's asset scope. Pasting into a supported template-backed child composition moves its stylesheet into document head, outside the template. The actual subcomposition assembly deliberately ignores document-head assets for template sources, so it keeps the pasted element but drops its stylesheet.

Earlier findings reconciled

The actual fixing patches and current predicates/regression sources retain the earlier repairs: UUID namespace, invocation clipboard snapshot, conditional CSS and whitespace (774bd772/81718dc1); clone selectors/resources and export descriptor (d45b80bc/8cd2a773/7bb20141); accepted attribute facts and shared predicate preservation (6e461ae4/e4fd2c71/ebb07ea5/3a6d555b); synthesized absence versus authored empty attributes (c2a3d0e5); contextual default-case matching (1b690921); content topology, source order/media and selected-sheet rejection (9313b805/23b71749/1171d8e6/c7e02a8e). In particular, 9766fd81, retained by the 7a2c359e extraction, captures and checks one project epoch across arbitration, queued transformation and post-save UI, including A→B→A. The original equal-content read-B/write-A finding is repaired and is not being refiled.

Scope and limits

Both independent source lanes completed all 16 existing changed effective-BASE versions before all 31 changed HEAD versions, including both complete lockfiles. The parent verified their 47 raw-version tree/blob bindings and actual Read coverage/order, read their final reports and all reported cross-feature pairs (36 conventions pairs / 28 correctness pairs at different grouping granularities), and independently adjudicated these two findings through targeted sanitizer, insertion, persistence and template-assembly sources. The parent's own audit is targeted, not a separate whole-change FULL read.

One lane's additional-context accounting has a retained limitation: its 27 raw context blobs were supplemented by 88 historical partial patches with 57 result SHAs outside mandatory changed versions; counting those result SHAs conservatively exceeds the 50-unique-context cap. This was not waived or represented as FULL historical-file coverage. The other lane remained within its context budget.

These findings are source-derived specificity/asset-population traces with controls, not observed browser paint or an executed compiler reproduction. No repository/dependency execution, tests, builds, browser/native runs, CI queries or live-service operations were performed. Author-reported execution results remain attributed and unverified. The final public record is reconciled; no exact-head gate review was present in that snapshot.

Verdict: REQUEST CHANGES
Reasoning: Supported clipboard inputs can silently change their winning styles or lose their stylesheet during normal child-composition assembly. Preserve cascade specificity and template asset ownership before approving this head.

— Review by tai (pr-review)

return;
}
const selector = rebindClipboardSelector(node.selector, context.ids, context.attributes);
node.selector = `#${context.scope} :is(${selector})`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Preserve each selector-list arm's specificity when adding the scope

A valid accepted envelope is {html:'<div class="card selected"><span id="other"></span>Editable</div>', css:'.card, #other{color:red}.card.selected{color:blue}', width:100, height:100, warnings:[]}. In the supplied fragment, .card.selected (0,2,0) beats the matching .card arm (0,1,0), so the card is blue.

After ID rebinding, this line emits #S :is(.card, #S-node-1) and #S :is(.card.selected). The first selector has specificity (2,0,0), because :is() takes the maximum specificity of its list even though the ID arm does not match the card. It now beats the second selector's (1,2,0), making the card red. Removing the unmatched , #other arm is a working control. The class attributes/color declarations are accepted; owned-style hoisting retains these selectors, and the normal queued file/history writer persists them.

Add the common scope without promoting a lower-specificity arm to the list's maximum (for example, scope the arms separately), and cover competing mixed-specificity lists. The existing declaration collector checks matching/traversal order, not cascade specificity. This is source-derived CSS specificity reasoning, not a browser reproduction; BASE has no portable-envelope receiver, so the introduction is accepted-content corruption in this new path.

Comment on lines +49 to +51
const html = tags.find((tag) => tag.name === "html");
const index = html?.end ?? tags[0]?.start ?? source.length;
return source.slice(0, index) + `<head>${styles}</head>` + source.slice(index);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Keep hoisted styles within a template composition's asset scope

Open a writable child compositions/scene.html containing <template id="scene"><div data-composition-id="scene" data-duration="10"></div></template> and paste a valid envelope with HTML <div><h1>Title</h1></div>, CSS h1{color:blue}, dimensions 100×50 and warnings []. The ordinary external-paste path inserts the wrapper inside that composition root, then hoistElementClipboardStyles removes its temporary style carrier. With no preceding sheet, appendToSheet reaches this fallback, which inserts <head><style>…</style></head> before the template.

The supported parent data-composition-src consumer does not collect that head: subCompositionValidity.ts:61–64 returns only template.innerHTML with hasTemplate=true; compositionAssembly.ts:238–250 sets assetHead=null for that representation; inlineSubCompositions.ts:393–418,497–503 emits the resulting styleSources. Consequently assembled output retains the editable title but omits its imported CSS (and any imported font-face rules). History/reload faithfully retain the misplaced source rather than repairing this asset boundary. The current child-composition regression uses full-document HTML, not a template.

Keep the owned stylesheet outside the composition root's content topology but inside the selected template's asset scope, whose supported root-sibling style position is collected by assembly. That is a control and does not undo the earlier structural-selector repair. This is a source-level missing-asset trace through the actual consumer, not an executed browser/compiler test; BASE has neither this portable receiver nor this new hoister.

@miguel-heygen

Copy link
Copy Markdown
Collaborator Author

Closing in a cleanup of old PRs: not a priority right now; the branch stays so it can be reopened.

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