Skip to content

fix(app): Ctrl+V pastes images in chat input (amicode#365) - #217

Merged
Rchari1 merged 1 commit into
local/amicodefrom
fix/365-ctrlv-image-paste
Aug 20, 2026
Merged

fix(app): Ctrl+V pastes images in chat input (amicode#365)#217
Rchari1 merged 1 commit into
local/amicodefrom
fix/365-ctrlv-image-paste

Conversation

@Rchari1

@Rchari1 Rchari1 commented Aug 20, 2026

Copy link
Copy Markdown
Member

Fixes harmoniqs/amicode#365

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.tsnavigator.clipboard.read() → dataUrl).

PromptInput v1 (classic composer, default when newLayoutDesigns is off — the reporters config on 0.2.1) only wired platform.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:

  • import readClipboardImageViaBridge alongside readClipboardViaBridge
  • readClipboardImage: bridge first, then platform fallback (parity with prompt-input-v2.tsx:389)
  • setClipboardImageHandleraddAttachments for the global Ctrl+V fallback (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

  • New Features
    • Added support for pasting images directly into prompt attachments.
    • Image pastes now use the available clipboard integration with a platform fallback.
    • Clipboard images received from the application are automatically added to prompts.

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
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8d165df3-fe64-4eb7-bc4b-9bbfc8700f78

📥 Commits

Reviewing files that changed from the base of the PR and between aa3331c and 155a34b.

📒 Files selected for processing (1)
  • packages/app/src/components/prompt-input.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The 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.

Changes

Clipboard image paste

Layer / File(s) Summary
Wire clipboard image sources into prompt attachments
packages/app/src/components/prompt-input.tsx
The prompt input reads images through the bridge, falls back to the platform clipboard, registers a global image handler, adds received files as attachments, and clears the handler during cleanup.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 155a3

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
Loading

Possibly related issues

  • harmoniqs/amicode#365 — The change wires clipboard image handling into the chat prompt input, matching the reported Ctrl/Cmd+V failure.

Suggested reviewers: brendonovich, hona

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the fix for image pasting in the chat input through Ctrl+V.
Description check ✅ Passed The description identifies the issue, explains the implementation, and documents manual verification, although template headings and checklist items are omitted.
Linked Issues check ✅ Passed The changes satisfy issue #365 by enabling bridge-based image reads and attaching clipboard images through Ctrl+V or Cmd+V.
Out of Scope Changes check ✅ Passed The changes are limited to clipboard image handling in the chat composer and align with issue #365.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/365-ctrlv-image-paste

Comment @coderabbitai help to get the list of available commands.

@Rchari1
Rchari1 merged commit 689dbd0 into local/amicode Aug 20, 2026
1 of 5 checks passed
@Rchari1

Rchari1 commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

Linked issue: harmoniqs/amicode#365 — now closed. Fix is on local/amicode @ 689dbd0 (image bridge in PromptInput v1). Next step: vendor new binary into harmoniqs/amicode.

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.

BUG: Ctrl+V does not paste images directly into the chat input

1 participant