Add screenshot/image paste to the terminal - #3
Open
benfrank241 wants to merge 1 commit into
Open
Conversation
Pasting an image (e.g. a macOS screenshot sitting on the clipboard) into a terminal pane did nothing: xterm only handles text paste and silently drops image blobs. And because the shell — Claude Code in particular — runs in a server-side PTY, there is no local clipboard for it to read from either. Intercept the paste in the capture phase on the terminal container, upload any image items to the session cwd via the existing /api/fs/upload endpoint, and type the resulting on-disk path into the PTY. That is the same path-handoff the file-drop handler already relies on, and tools like Claude Code recognize an image path and attach it. Plain-text pastes are left untouched and flow through to xterm normally. The upload logic is factored out of handleDrop into a shared uploadBlobsAndType helper, and a small "Attaching image…" badge gives paste feedback (drop has a drag overlay; paste has none). Pasted screenshots are saved as pasted-<timestamp>.png in the session cwd. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Pasting an image (e.g. a macOS screenshot on the clipboard,
Cmd+Ctrl+Shift+4thenCmd+V) into a terminal pane currently does nothing. xterm only handles text paste and silently drops image blobs — and since the shell (Claude Code in particular) runs in a server-side PTY, there's no local clipboard for it to read from either.How
ui/src/components/TerminalCell.tsx:pastelistener on the terminal container. It runs before xterm's hidden textarea sees the event, so image pastes can be handled and text pastes pass straight through untouched.POST /api/fs/uploadendpoint, then type the resulting on-disk path into the PTY ({type:'input', data: path}).handleDropinto a newuploadBlobsAndTypehelper.Pasted screenshots are saved as
pasted-<timestamp>.pngin the session cwd.Notes
/api/fs/upload+/api/fs/:id/browse.tsctypecheck andvite buildboth pass.Test plan
Cmd+V.[Image #N].🤖 Generated with Claude Code