From 3af75dae3752cb844420c9f8936f6d6be554821f Mon Sep 17 00:00:00 2001 From: christian-byrne Date: Sun, 4 Oct 2026 17:27:43 -0700 Subject: [PATCH 1/3] test(agent): pin that a composer text paste adds no node to the graph MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The reported symptom of PM-1261 — pasting text into the agent composer also pastes the last copied canvas node — had no black-box case. The four cases #18062 added cover the copy side and canvas paste; none pastes into the composer, so the behaviour users reported was unpinned. Two cases, both red on the pre-#18062 routing: - a composer text paste leaves the graph untouched - that paste leaves the node clipboard usable, so an ordinary canvas Ctrl+V still pastes the copied node Plain text is put on the clipboard with `writeText`, which leaves `localStorage['litegrapheditor_clipboard']` holding the node copy — the precondition of the report. The node can therefore only reach the graph through the canvas-paste fallback in `usePaste`. Verified red by removing the two guards that now cover this path (`isContentEditable` in `shouldIgnoreCopyPaste`, from #18062, and the `e.defaultPrevented` early return, from #18248): both fail with a SaveImage node landing on the graph. Green on main with both in place. Co-Authored-By: Claude Opus 5 (1M context) --- .../tests/agent/agentCopyPaste.spec.ts | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/browser_tests/tests/agent/agentCopyPaste.spec.ts b/browser_tests/tests/agent/agentCopyPaste.spec.ts index f90248bb0d5..d723c2f2967 100644 --- a/browser_tests/tests/agent/agentCopyPaste.spec.ts +++ b/browser_tests/tests/agent/agentCopyPaste.spec.ts @@ -5,6 +5,11 @@ import { agentCopyPasteTest as test } from '@e2e/fixtures/AgentCopyPasteDriver' import { AgentPanel } from '@e2e/fixtures/components/AgentPanel' +import { nextFrame } from '@e2e/fixtures/utils/timing' + +// Plain text, so `text/html` carries no node payload: the only way a node can +// reach the graph from this paste is the canvas-paste fallback. +const COMPOSER_PASTE_TEXT = 'make the sampler deterministic' test.describe( 'Copy and paste beside the agent panel', @@ -115,6 +120,68 @@ test.describe( }) }) + test('pasting text into the composer leaves the graph untouched', async ({ + agentCopyPaste, + page + }) => { + const before = await agentCopyPaste.graphNodes() + + await test.step('copy a node on the canvas', async () => { + await agentCopyPaste.revealAndSelectNode( + AGENT_COPY_PASTE_SCENARIO.earlierNode.id + ) + await agentCopyPaste.clipboard.copy() + }) + + await test.step('put plain text on the clipboard', () => + agentCopyPaste.clipboard.writeText(COMPOSER_PASTE_TEXT)) + + await test.step('paste it into the composer', () => + agentCopyPaste.clipboard.paste(agentCopyPaste.composer)) + + await test.step('the text lands in the composer', () => + expect(agentCopyPaste.composer).toContainText(COMPOSER_PASTE_TEXT)) + + await test.step('no node was added to the graph', async () => { + await nextFrame(page) + expect(await agentCopyPaste.nodesAddedSince(before)).toEqual([]) + }) + }) + + test('a composer paste keeps the node clipboard usable on the canvas', async ({ + agentCopyPaste, + page + }) => { + const before = await agentCopyPaste.graphNodes() + + await test.step('copy a node on the canvas', async () => { + await agentCopyPaste.revealAndSelectNode( + AGENT_COPY_PASTE_SCENARIO.earlierNode.id + ) + await agentCopyPaste.clipboard.copy() + }) + + await test.step('paste plain text into the composer', async () => { + await agentCopyPaste.clipboard.writeText(COMPOSER_PASTE_TEXT) + await agentCopyPaste.clipboard.paste(agentCopyPaste.composer) + await expect(agentCopyPaste.composer).toContainText(COMPOSER_PASTE_TEXT) + }) + + await test.step('paste on the canvas', () => + agentCopyPaste.clipboard.paste(page.locator('#graph-canvas'))) + + await test.step('the copied node is pasted', async () => { + await expect + .poll(() => agentCopyPaste.graphNodes()) + .toHaveLength(before.length + 1) + expect(await agentCopyPaste.nodesAddedSince(before)).toEqual([ + expect.objectContaining({ + type: AGENT_COPY_PASTE_SCENARIO.earlierNode.type + }) + ]) + }) + }) + test('text copy preserves a newer equal command copy', async ({ agentCopyPaste, page From ce3c7a7d5e20ebb2dd8464d35b2e612c24f394fa Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Mon, 19 Oct 2026 01:42:53 -0700 Subject: [PATCH 2/3] test(agent): close the four vacuity holes in the composer-paste pin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses the four Cursor review findings on #20147. Every change is a strengthening; no assertion is weakened and no case is retired. - Prove the node clipboard actually holds the copied node before asserting what a paste did to the graph. Without that precondition a silently-failed selection leaves nothing to leak and the negative assertion passes while binding nothing. (finding at line 133) - Replace the single `nextFrame` sample with a settle window. `usePaste`'s document handler is `async` and every insertion route is awaited, so a mis-routed paste can land after one frame has already been sampled. (finding at line 146) - Compare the whole node set rather than `nodesAddedSince`'s one-way difference, so a regression that *removes* nodes is visible too — which is what the `loadGraphData` route does, since it replaces the graph. (finding at line 147) - Re-baseline the canvas-paste assertion on the post-composer-paste graph. Measured against a snapshot spanning both pastes, "the canvas paste worked" and "the composer paste leaked the node and the canvas paste did nothing" are the same observation. (finding at line 177) Each of the four was verified real rather than taken on faith: under the failure mode it names, the original assertion stayed green and the new guard rejects. The pin still binds the product behaviour — both cases are red with `shouldIgnoreCopyPaste`'s `isContentEditable` arm and `usePaste`'s `e.defaultPrevented` early return removed, and all 6 cases in the spec pass with them in place (`--project=cloud --workers=1`). --- .../tests/agent/agentCopyPaste.spec.ts | 99 +++++++++++++++++-- 1 file changed, 93 insertions(+), 6 deletions(-) diff --git a/browser_tests/tests/agent/agentCopyPaste.spec.ts b/browser_tests/tests/agent/agentCopyPaste.spec.ts index d723c2f2967..3ba3d691c38 100644 --- a/browser_tests/tests/agent/agentCopyPaste.spec.ts +++ b/browser_tests/tests/agent/agentCopyPaste.spec.ts @@ -1,5 +1,7 @@ import { expect } from '@playwright/test' +import type { Page } from '@playwright/test' +import type { AgentCopyPasteDriver } from '@e2e/fixtures/AgentCopyPasteDriver' import { AGENT_COPY_PASTE_SCENARIO, agentCopyPasteTest as test @@ -11,6 +13,66 @@ import { nextFrame } from '@e2e/fixtures/utils/timing' // reach the graph from this paste is the canvas-paste fallback. const COMPOSER_PASTE_TEXT = 'make the sampler deterministic' +type LiveGraphNodes = Awaited> + +/** + * Where `LGraphCanvas.copyToClipboard` parks a Ctrl+C node copy — the state the + * reports mean by "the *last copied* node". Mirrored from + * `@/lib/litegraph/src/canvas/clipboardStorage` rather than imported, so this + * spec stays inside `browser_tests/`. + */ +const CANVAS_CLIPBOARD_KEY = 'litegrapheditor_clipboard' + +/** How long a "nothing happened" assertion has to hold before it is believed. */ +const SETTLE_FRAMES = 10 + +/** + * The node types currently on the canvas clipboard. The cases below use this as + * a precondition: a negative assertion about what a paste did to the graph is + * satisfiable by an *empty* node clipboard, so without proving the copy landed + * first, a silently-failed selection turns the pin into a test that passes + * while binding nothing. + */ +function nodeClipboardTypes(page: Page): Promise { + return page.evaluate((key) => { + const raw = localStorage.getItem(key) + if (!raw) return [] + const parsed = JSON.parse(raw) as { nodes?: { type?: string }[] } + return (parsed.nodes ?? []).map((node) => node.type ?? '') + }, CANVAS_CLIPBOARD_KEY) +} + +function byId(nodes: LiveGraphNodes): LiveGraphNodes { + return [...nodes].sort((a, b) => a.id.localeCompare(b.id)) +} + +/** + * Asserts the live graph still holds exactly `before`, and keeps asserting it + * across a settle window. + * + * Two reasons it is not a single `nodesAddedSince` sample. `usePaste`'s + * document handler is `async` and every route that can insert a node is + * awaited — `pasteImageNode`, `pasteVideoNode`, `app.loadGraphData` — so a + * mis-routed paste lands some ticks after the paste event rather than inside + * the next frame, and one sample reads the graph before it arrives. And + * `nodesAddedSince` is a one-way difference keyed on node id, so it is blind to + * a regression that *removes* nodes — which is exactly what the + * `loadGraphData` route does, since it replaces the graph wholesale. Comparing + * the whole node set, sorted by id, catches both directions and is + * order-insensitive. + */ +async function expectGraphUnchanged( + page: Page, + agentCopyPaste: AgentCopyPasteDriver, + before: LiveGraphNodes +): Promise { + const expected = byId(before) + for (let sample = 0; sample < SETTLE_FRAMES; sample++) { + await nextFrame(page) + expect(byId(await agentCopyPaste.graphNodes())).toEqual(expected) + } +} + test.describe( 'Copy and paste beside the agent panel', { tag: ['@cloud', '@agent', '@vue-nodes'] }, @@ -133,6 +195,12 @@ test.describe( await agentCopyPaste.clipboard.copy() }) + await test.step('the node clipboard holds that node', async () => { + expect(await nodeClipboardTypes(page)).toEqual([ + AGENT_COPY_PASTE_SCENARIO.earlierNode.type + ]) + }) + await test.step('put plain text on the clipboard', () => agentCopyPaste.clipboard.writeText(COMPOSER_PASTE_TEXT)) @@ -142,10 +210,8 @@ test.describe( await test.step('the text lands in the composer', () => expect(agentCopyPaste.composer).toContainText(COMPOSER_PASTE_TEXT)) - await test.step('no node was added to the graph', async () => { - await nextFrame(page) - expect(await agentCopyPaste.nodesAddedSince(before)).toEqual([]) - }) + await test.step('the graph is untouched', () => + expectGraphUnchanged(page, agentCopyPaste, before)) }) test('a composer paste keeps the node clipboard usable on the canvas', async ({ @@ -161,20 +227,41 @@ test.describe( await agentCopyPaste.clipboard.copy() }) + await test.step('the node clipboard holds that node', async () => { + expect(await nodeClipboardTypes(page)).toEqual([ + AGENT_COPY_PASTE_SCENARIO.earlierNode.type + ]) + }) + await test.step('paste plain text into the composer', async () => { await agentCopyPaste.clipboard.writeText(COMPOSER_PASTE_TEXT) await agentCopyPaste.clipboard.paste(agentCopyPaste.composer) await expect(agentCopyPaste.composer).toContainText(COMPOSER_PASTE_TEXT) }) + // Re-baseline on the post-composer-paste graph instead of reusing + // `before`. The canvas paste adds one node of `earlierNode.type`, so + // measured against a snapshot taken before *both* pastes, "the canvas + // paste worked" and "the composer paste leaked the node and the canvas + // paste did nothing" are the same observation — one extra node of that + // type either way. Proving the composer paste added nothing first is what + // makes the addition below attributable to the canvas paste alone. + const afterComposerPaste = + await test.step('the composer paste left the graph alone', async () => { + await expectGraphUnchanged(page, agentCopyPaste, before) + return agentCopyPaste.graphNodes() + }) + await test.step('paste on the canvas', () => agentCopyPaste.clipboard.paste(page.locator('#graph-canvas'))) await test.step('the copied node is pasted', async () => { await expect .poll(() => agentCopyPaste.graphNodes()) - .toHaveLength(before.length + 1) - expect(await agentCopyPaste.nodesAddedSince(before)).toEqual([ + .toHaveLength(afterComposerPaste.length + 1) + expect( + await agentCopyPaste.nodesAddedSince(afterComposerPaste) + ).toEqual([ expect.objectContaining({ type: AGENT_COPY_PASTE_SCENARIO.earlierNode.type }) From 74771f9201e1c7fc9a21d604f05fb0bd29fbd65e Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Mon, 19 Oct 2026 02:29:43 -0700 Subject: [PATCH 3/3] test(agent): remove prohibited spec comments --- .../tests/agent/agentCopyPaste.spec.ts | 38 ------------------- 1 file changed, 38 deletions(-) diff --git a/browser_tests/tests/agent/agentCopyPaste.spec.ts b/browser_tests/tests/agent/agentCopyPaste.spec.ts index 3ba3d691c38..a163cc461bd 100644 --- a/browser_tests/tests/agent/agentCopyPaste.spec.ts +++ b/browser_tests/tests/agent/agentCopyPaste.spec.ts @@ -9,30 +9,14 @@ import { import { AgentPanel } from '@e2e/fixtures/components/AgentPanel' import { nextFrame } from '@e2e/fixtures/utils/timing' -// Plain text, so `text/html` carries no node payload: the only way a node can -// reach the graph from this paste is the canvas-paste fallback. const COMPOSER_PASTE_TEXT = 'make the sampler deterministic' type LiveGraphNodes = Awaited> -/** - * Where `LGraphCanvas.copyToClipboard` parks a Ctrl+C node copy — the state the - * reports mean by "the *last copied* node". Mirrored from - * `@/lib/litegraph/src/canvas/clipboardStorage` rather than imported, so this - * spec stays inside `browser_tests/`. - */ const CANVAS_CLIPBOARD_KEY = 'litegrapheditor_clipboard' -/** How long a "nothing happened" assertion has to hold before it is believed. */ const SETTLE_FRAMES = 10 -/** - * The node types currently on the canvas clipboard. The cases below use this as - * a precondition: a negative assertion about what a paste did to the graph is - * satisfiable by an *empty* node clipboard, so without proving the copy landed - * first, a silently-failed selection turns the pin into a test that passes - * while binding nothing. - */ function nodeClipboardTypes(page: Page): Promise { return page.evaluate((key) => { const raw = localStorage.getItem(key) @@ -46,21 +30,6 @@ function byId(nodes: LiveGraphNodes): LiveGraphNodes { return [...nodes].sort((a, b) => a.id.localeCompare(b.id)) } -/** - * Asserts the live graph still holds exactly `before`, and keeps asserting it - * across a settle window. - * - * Two reasons it is not a single `nodesAddedSince` sample. `usePaste`'s - * document handler is `async` and every route that can insert a node is - * awaited — `pasteImageNode`, `pasteVideoNode`, `app.loadGraphData` — so a - * mis-routed paste lands some ticks after the paste event rather than inside - * the next frame, and one sample reads the graph before it arrives. And - * `nodesAddedSince` is a one-way difference keyed on node id, so it is blind to - * a regression that *removes* nodes — which is exactly what the - * `loadGraphData` route does, since it replaces the graph wholesale. Comparing - * the whole node set, sorted by id, catches both directions and is - * order-insensitive. - */ async function expectGraphUnchanged( page: Page, agentCopyPaste: AgentCopyPasteDriver, @@ -239,13 +208,6 @@ test.describe( await expect(agentCopyPaste.composer).toContainText(COMPOSER_PASTE_TEXT) }) - // Re-baseline on the post-composer-paste graph instead of reusing - // `before`. The canvas paste adds one node of `earlierNode.type`, so - // measured against a snapshot taken before *both* pastes, "the canvas - // paste worked" and "the composer paste leaked the node and the canvas - // paste did nothing" are the same observation — one extra node of that - // type either way. Proving the composer paste added nothing first is what - // makes the addition below attributable to the canvas paste alone. const afterComposerPaste = await test.step('the composer paste left the graph alone', async () => { await expectGraphUnchanged(page, agentCopyPaste, before)