Repository navigation
feat(agent): attach pasted clipboard images #18409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1261,6 +1261,18 @@ function onPanelDrop(event: DragEvent): void { | |
| event.preventDefault() | ||
| void attachment.addFiles(files) | ||
| } | ||
|
|
||
| function onPanelPaste(event: ClipboardEvent): void { | ||
| const target = event.target | ||
| if (!(target instanceof Element) || !target.closest('#agent-composer')) return | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: The summary frames this as pasting images "instead of letting the canvas create a Load Image node" — was the canvas actually claiming these pastes? The document-level handler in If that's right, the change is purely additive — it adds attaching, rather than winning a conflict — and the framing in the description (and in the E2E step 3, "verify no Load Image node is added") describes a race that wasn't happening. Not a code problem either way; I'd just rather the recorded motivation match the mechanism, since the next person to touch paste ownership will read this description first. If you have seen a Load Image node appear from a composer paste, that's more interesting than the fix — it would mean |
||
| const files = Array.from(event.clipboardData?.files ?? []).filter( | ||
| isAgentAttachable | ||
| ) | ||
| if (files.length === 0) return | ||
| event.preventDefault() | ||
| event.stopPropagation() | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: In the capture phase this stops the event before the composer's own editor ever sees it. Is dropping the accompanying text intended when the clipboard carries both? The composer is a ProseMirror contenteditable ( The case I'm unsure about is a mixed payload. Copying a cell range out of Sheets or Excel puts both a rendered image and If attaching is the intent, no change needed beyond maybe a note here. If text should still land when it's present, gating on |
||
| void attachment.addFiles(files) | ||
| } | ||
| </script> | ||
|
|
||
| <template> | ||
|
|
@@ -1272,6 +1284,7 @@ function onPanelDrop(event: DragEvent): void { | |
| @dragleave="onPanelDragLeave" | ||
| @dragover="onPanelDragOver" | ||
| @drop="onPanelDrop" | ||
| @paste.capture="onPanelPaste" | ||
| > | ||
| <input | ||
| ref="fileInput" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: This test passes whether or not the composer guard exists, so the PR's central mechanism is uncovered.
I verified it rather than eyeballing it. On
cac5412, I deleted the guard inAgentPanelRoot.vue:1267, reducing it toif (!(target instanceof Element)) return, and re-ran both new tests:The reason is the dispatch target.
document.bodyis an ancestor of the element carrying@paste.capture, not a descendant, so the handler never runs for this event — the guard is never consulted anddefaultPreventedis triviallyfalse. The assertion holds for a reason unrelated to what it's meant to prove.That matters because
closest('#agent-composer')is doing real work: it's a magic string matched against an id defined in a different component (Composer.vue:332), with no type relationship between them. A rename there is exactly the regression this test should catch, and today it wouldn't.Dispatching on something inside the panel but outside the composer covers it — the message list, or the panel root itself. With the guard intact that stays
false; with it removed it flips totrueand the test fails, which is the signal you want.