Skip to content

feat(tui): ctrl+v pastes a clipboard image into the first prompt - #307

Merged
erickgnclvs merged 1 commit into
mainfrom
new-session-paste-image
Sep 29, 2026
Merged

erickgnclvs merged 1 commit into
mainfrom
new-session-paste-image

Conversation

@erickgnclvs

Copy link
Copy Markdown
Owner

What

Ctrl+V on the new-session form's first-prompt field now pastes clipboard images: the image is saved to a temp PNG and its path is inserted at the cursor. With no image on the clipboard it falls through to the textarea's existing text paste, unchanged.

Why ctrl+v, not cmd+v

Cmd+V is handled by the terminal emulator and only ever sends text; the app never sees it. Ctrl+V is a real keypress, so the TUI can read the clipboard itself — the same trick Claude Code uses.

Notes

  • Front-end side of the client/core split (reads the viewer's clipboard) — lives in internal/tui/clipimage.go.
  • macOS only (osascript); Linux (wl-paste/xclip) can follow when needed.
  • Over SSH it reads the host's clipboard, so it just degrades to text paste.
  • Hint copy updated (appended, so it's what clips first at 40 cols); goldens updated.

Testing

  • TestNewSessionPromptCtrlVPastesClipboardImagePath (red without the hook).
  • Manually verified the real clipboard read produces a valid PNG, and a text-only clipboard errors without leaving a temp file.
  • Unit + e2e suites pass (internal/terminal only fails locally when run inside Ghostty because of its env vars; unrelated).

🤖 Generated with Claude Code

A terminal paste only carries text, so like Claude Code the new-session
prompt field now reads the clipboard itself on ctrl+v: an image is saved
to a temp PNG and its path inserted at the cursor (agents read an image
path as the image). No image falls through to the textarea's text paste.

macOS only (osascript); over SSH it reads the host's clipboard.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@erickgnclvs
erickgnclvs merged commit 750dd7b into main Sep 29, 2026
3 checks passed
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.

1 participant