feat(paste): opt-in Cmd+V image passthrough (macOS)#332
Open
roba-adnew wants to merge 3 commits into
Open
Conversation
Add a [paste] config section with image_passthrough (default false). When enabled and the macOS clipboard holds an image, Cmd+V forwards Ctrl+V (0x16) to the focused terminal instead of pasting text, so a CLI running there performs its own inline image paste. Plain text paste is unaffected. - config.zig: PasteConfig + default-config template + tests - platform/macos_clipboard.zig: NSPasteboard image detection via objc interop - app/terminal_actions.zig: tryPasteImagePassthrough sends 0x16 - app/runtime.zig: gate the Cmd+V handler on the flag
Replace +[NSImage canInitWithPasteboard:] with -[NSPasteboard canReadObjectForClasses:@[NSImage] options:nil] for clipboard image detection. canInitWithPasteboard: only matches the legacy NeXT pasteboard type set: it missed images declaring only modern UTIs (some Universal Clipboard / iPhone screenshots) and false-positived on any file URL. The modern UTI-aware API matches public.image-conforming types (incl. Universal Clipboard) and image file URLs while rejecting non-image file URLs, and is metadata-only so it does not pull promised bytes.
Forwarding Ctrl+V relied on the CLI's own clipboard read, which is unreliable: Claude Code reads via a synchronous osascript call that fails on Universal Clipboard promised data and large images, inserting an empty placeholder. Now Architect reads the clipboard image as PNG bytes itself, writes a temp file, and pastes that path as text — CLIs like Claude Code attach image file paths reliably. macos_clipboard gains readClipboardImagePng (reads public.png, or converts the TIFF representation via NSBitmapImageRep as a fallback).
Owner
|
Hey, thank you for this PR. I think being able to paste images with Cmd+V instead of relying on the agent implementation would be a nice addition to Architect's feature set. If it works well, we can later make it the default behavior. Could you please fix the build (looks like the linting fails) and update the |
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.
Adds an opt-in
[paste]config section withimage_passthrough(defaultfalse).When enabled and the macOS clipboard holds an image, Cmd+V forwards Ctrl+V (
0x16) to the focused terminal instead of pasting text — so a CLI running there that supports Ctrl+V image paste inlines the image, matching the Cmd+V behavior people expect from editors. Plain text paste is unchanged, and the feature is off by default.How:
macos_clipboard.zigdetects clipboard images via NSPasteboard (objc interop, same pattern asmacos_input_source.zig);terminal_actions.tryPasteImagePassthroughsends0x16; the Cmd+V handler is gated on the flag.Scope: macOS only · 4 files, +124/−3 · build / test /
zig fmt/zig build lintall green. Clipboard detection unit-tested; manually verified end-to-end (screenshot → Cmd+V → inline image).