You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Probe the live clipboard for images on every paste, in-daemon
The v1.33 browser Copy Image bridge lives in `paste_image.sh`, which the
kitty Ctrl+V binding only invokes outside tmux. Inside tmux the binding
short-circuits to `flashpaste-trigger`, sending the request straight to
the daemon — and the daemon's existing pickup paths (`inotify_watch`,
the screenshots-dir scan in `handle_paste`) only see files on disk. So
right-click → Copy Image in Firefox/Chrome, then Ctrl+V in a tmux pane,
attached nothing: the bytes were on the Wayland/X11 clipboard but never
landed on `~/Pictures/Screenshots/`, and the daemon never probed there.
`ipc.rs` now adds an eager live-clipboard image probe alongside the
screenshot scan. `read_clipboard_image_if_present` walks Wayland MIME
types (`wl_clipboard_rs::paste::get_mime_types`, 150 ms timeout) and
xclip TARGETS (300 ms timeout), picks PNG > JPEG > WebP, reads bytes via
wl-clipboard then xclip, and validates magic with `image_magic_ok` —
the same defence against xclip's silent text-fallback that lives in
`bin/flashpaste-capture-clip`. If the bytes differ from what's staged
(byte-comparison against `state.staged_snapshot()`), the daemon stages
them with a synthetic path under `screenshots_dir/flashpaste-clip-live.*`
so downstream logging and the Aider adapter still get a clean filename.
`state.rs` gains `last_live_image_probe_ms` so the probe shares the
hot-path throttle window with the screenshots scan; back-to-back pastes
don't fan out repeated xclip / wl-clipboard subprocess calls. Happy-path
cost on an empty clipboard is ~15 ms (one MIME probe + TARGETS); the
capture path is ~40–80 ms for a typical browser image.
Verified end-to-end: `wl-copy -t image/png < img.png` + `flashpaste-trigger`
on a tmux pane produces `paste: captured live clipboard image (browser
Copy Image bridge) bytes=3370846 mime="image/png"` in the journal,
followed by a successful `PASTED image`. Text path unchanged — when no
image is on the clipboard the existing external-text override fires
exactly as before.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments