Skip to content

VSCode extension: image paste into Codev terminal #736

@amrmelsayed

Description

@amrmelsayed

Summary

Image paste (Cmd+V) works in the Codev web dashboard terminal and in VSCode's built-in terminal (Claude Code session inside it picks up pasted images), but does not work in Codev's VSCode extension terminal.

Why this asymmetry exists

VSCode's image-paste-to-terminal bridge only fires for terminals where VSCode owns the input pipeline (built-in terminals created with `shellPath`). For `Pseudoterminal`-backed extension terminals — which is how Codev creates its terminals — VSCode delivers clipboard contents as text via `handleInput(data: string)`. If the clipboard contains only an image, `handleInput` receives empty text and the image is dropped before the extension sees it.

The web dashboard works because it intercepts the browser-native `ClipboardEvent` directly on the xterm.js DOM node (`packages/dashboard/src/components/Terminal.tsx:165-185`) and uploads the image to Tower's existing `POST /api/paste-image` endpoint (`packages/codev/src/agent-farm/servers/tower-routes.ts:1277`, shipped under #252).

Proposed implementation

Replicate the dashboard flow in the extension, with per-OS clipboard glue since VSCode's clipboard API is text-only:

  1. Bind `Cmd+Shift+V` (or `Cmd+V` with a Codev-terminal-focus `when` clause) to a new `codev.pasteImage` command.
  2. Probe system clipboard for image bytes:
    • macOS: `pngpaste -` or AppleScript
    • Linux: `xclip -selection clipboard -t image/png -o` / `wl-paste -t image/png`
    • Windows: PowerShell `Get-Clipboard -Format Image`
  3. POST bytes to Tower's existing `/api/paste-image` endpoint.
  4. Inject the returned path into the PTY via `pty.handleInput(path)`.
  5. Toast fallback when no image is on the clipboard / clipboard tool isn't installed.

Estimated ~100–150 LOC including the three platform shims.

Context

Surfaced during the #602 audit (VSCode extension umbrella). This is the last functional gap between the web dashboard and the VSCode extension for terminal interactions. Filed separately so #602 can be closed.

Acceptance criteria

  • Cmd+Shift+V (or Cmd+V) on a focused Codev terminal in VSCode uploads a clipboard image and pastes the resulting file path
  • Works on macOS, Linux (X11 + Wayland), and Windows
  • Friendly toast when no image is on the clipboard
  • Graceful degradation (clear error) when the per-OS clipboard tool isn't installed
  • No regression to text paste

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions