Repository navigation
fix(editor): make copy/cut/paste work across documents (VCs included) - #543
Open
fortusfederal wants to merge 1 commit into
Open
fortusfederal wants to merge 1 commit into
fortusfederal wants to merge 1 commit into
Conversation
The clipboard slice reimplemented its own page-only "find the active document" lookup (getActivePage) instead of routing through resolveActiveTreeTarget, the VC-aware resolver every other named tree-mutation action shares via mutateActiveTree. Two consequences: - Entering Visual Component mode doesn't clear activePageId (only stashes it in previousActivePageId), so getActivePage kept resolving to whichever page was open before -- a stale, unrelated document. - resolveInsertLocation then looked up the right-clicked node's id in that wrong tree, found nothing, and returned null. pasteNode saw a null location and aborted with no error, no toast -- exactly the reported symptom (Paste appears in the menu since clipboardEntry is a plain boolean unrelated to the active document, but clicking it does nothing). - A second, independent instance of the same bug lived inside the actual insert transaction, which looked up the draft target via `site.pages.find(...)` -- a Visual Component's tree lives in `site.visualComponents`, not `site.pages`, so this line could never resolve a VC target even after fixing the first lookup. Replaced getActivePage with getActiveTree, backed by resolveActiveTreeTarget, at both call sites (outer resolution + the draft-side lookup inside the paste transaction). copy/cut/paste now work identically whether the active document is a page, template, or Visual Component, matching every other mutation action's routing. Added regression coverage: paste into a VC tree while it's the active document, and copy-from-VC / paste-into-page in the other direction. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
fortusfederal
marked this pull request as ready for review
September 18, 2026 00:57
This branch has not been deployed
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.
Summary
Copy, cut and paste silently do nothing inside a Visual Component. Paste appears in the context menu (a clipboard entry exists) and then no node is inserted, with no error and no toast.
The clipboard slice reimplements its own page-only "find the active document" lookup (
getActivePage) instead of routing throughresolveActiveTreeTarget, the VC-aware resolver every other named tree-mutation action shares viamutateActiveTree. Two consequences:activePageId(it only stashes it inpreviousActivePageId), sogetActivePagekeeps resolving to whichever page was open before — a stale, unrelated document.resolveInsertLocationthen looks up the right-clicked node's id in that wrong tree, finds nothing, and returnsnull.pasteNodesees a null location and aborts.The slice now resolves through
resolveActiveTreeTargetand operates on aNodeTree<PageNode>rather than aPage, so clipboard operations behave identically whichever kind of document is open.Verification
bun run buildbun testbun run lintChecklist
clipboardSlice.test.ts🤖 Generated with Claude Code