fix(paste): attach clipboard image when paste content is empty - #3490
Open
joestump wants to merge 1 commit into
Open
fix(paste): attach clipboard image when paste content is empty#3490joestump wants to merge 1 commit into
joestump wants to merge 1 commit into
Conversation
On macOS, terminal emulators intercept CMD+V and deliver the clipboard's text via bracketed paste. When the clipboard holds an image instead of text, the resulting tea.PasteMsg is strictly empty, and handlePasteMsg fell through the text-paste path and silently did nothing. Add a fallback in handlePasteMsg: when pasted content is strictly empty, delegate to pasteImageFromClipboard (mirroring the key-bound ctrl+v path) so image data on the clipboard is attached. The check is a strict == "" rather than TrimSpace so genuine whitespace-only pastes still insert as text. Like the key-bound path, the fallback is gated to image-capable models. Also surface a warning naming the current model when either paste-image entry point (the key binding or the new fallback) is used on a model that doesn't support images. Both paths previously returned nil silently, so a paste vanished with zero feedback and the failure was undiagnosable from the UX.
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.
Problem
On macOS, copying an image (e.g. from Preview) and pressing CMD+V in the chat editor does nothing. Terminal emulators intercept CMD+V and deliver the clipboard's text via bracketed paste; when the clipboard holds an image instead of text, the resulting
tea.PasteMsgis strictly empty, andhandlePasteMsgfell through the text-paste path and silently inserted nothing. The image-only clipboard is never checked.Fix
Two changes in
internal/ui/model/ui.go:Empty-paste fallback: when the pasted content is strictly empty,
handlePasteMsgnow delegates topasteImageFromClipboard(the same path as the ctrl+vPasteImagebinding), so image data on the native clipboard is attached as a pending attachment. The check is a strict== ""rather thanTrimSpace, so genuine whitespace-only pastes still insert as text. Like the key-bound path, the fallback is gated to image-capable models.Warn on image-incapable models: both paste-image entry points (the key binding and the new fallback) previously returned
nilsilently when the current model didn't support images — a paste vanished with zero feedback, which made the macOS bug undiagnosable from the UX. They now surface a warning naming the current model ("gpt-4o-mini doesn't support images").Tests
New
internal/ui/model/paste_image_test.gocovers:Verification
go test ./internal/ui/...— all passgo vet ./internal/ui/...— cleangofumpt -l internal/ui/— cleangolangci-lint run ./internal/ui/...— 0 issues