fix(app): Ctrl+V pastes images in chat input (amicode#365) - #217
Conversation
The VS Code webview chat runs as a sandboxed cross-origin iframe where navigator.clipboard / clipboardData are empty — image data is only readable via the outer webview relay (chat_panel.ts → navigator.clipboard.read() → dataUrl). PromptInput v1 (the classic composer, still default when newLayoutDesigns is off) only wired platform.readClipboardImage (desktop/TUI native) and never the bridge, so an image-only clipboard on Ctrl+V produced no files, no text, and no attachment — fixed by mirroring v2's bridge-first read and the global-clipboard image slot. - import readClipboardImageViaBridge alongside readClipboardViaBridge - readClipboardImage: bridge first, then platform fallback (parity with prompt-input-v2.tsx:389) - setClipboardImageHandler -> addAttachments for the global Ctrl+V fallback (v2 pattern) Fixes harmoniqs/amicode#365 Closes harmoniqs/amicode#365
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe prompt input now reads clipboard images through the webview bridge before using the platform fallback. It also registers a global clipboard image handler that adds supplied files to prompt attachments and removes the handler during cleanup. ChangesClipboard image paste
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized change adds image clipboard support while preserving existing text paste and attachment behavior; no actionable merge-blocking risk remains beyond normal checks and review. Sequence Diagram(s)sequenceDiagram
participant PromptInput
participant WebviewBridge
participant PlatformClipboard
participant ClipboardImageHandler
PromptInput->>WebviewBridge: Read clipboard image
WebviewBridge-->>PromptInput: Return image or no image
PromptInput->>PlatformClipboard: Read fallback image
PlatformClipboard-->>PromptInput: Return clipboard image
ClipboardImageHandler->>PromptInput: Provide image files
PromptInput->>PromptInput: Add attachments
Possibly related issues
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
Linked issue: harmoniqs/amicode#365 — now closed. Fix is on |
Fixes harmoniqs/amicode#365
The VS Code webview chat runs as a sandboxed cross-origin iframe where
navigator.clipboard/clipboardDataare empty — image data is only readable via the outer webview relay (chat_panel.ts→navigator.clipboard.read()→ dataUrl).PromptInputv1 (classic composer, default whennewLayoutDesignsis off — the reporters config on 0.2.1) only wiredplatform.readClipboardImage(desktop/TUI native) and never the bridge, so an image-only clipboard on Ctrl/Cmd+V produced no files, no text, and no attachment.Mirrors the already-shipped v2 fix:
readClipboardImageViaBridgealongsidereadClipboardViaBridgereadClipboardImage: bridge first, then platform fallback(parity withprompt-input-v2.tsx:389)setClipboardImageHandler→addAttachmentsfor the globalCtrl+Vfallback (v2 pattern)Closes harmoniqs/amicode#365
Base:
local/amicode(amicode fork line)Test: manual Ctrl+Cmd+V with image on Darwin arm64 in VS Code webview;
+button unchanged; text paste unchanged.Summary by CodeRabbit