From 1f5d1911e461d141b2178e2e6bcd0c69772d79ea Mon Sep 17 00:00:00 2001 From: NagyVikt Date: Sat, 16 May 2026 01:03:07 +0200 Subject: [PATCH] =?UTF-8?q?fix(pane-menu):=20add=20p)=20handler=20?= =?UTF-8?q?=E2=80=94=20paste=20system=20clipboard=20(text=20+=20image)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The right-click pane action menu lists "Paste (p)" but the script's case statement had no `p)` branch — pressing 'p' was a silent no-op. Operator hit this trying to paste content copied from outside the terminal (Ctrl-V worked because kitty has its own bracketed-paste shortcut wired straight to the system clipboard). New behavior: - Wayland: read system clipboard via wl-paste. If the clipboard holds an image (PNG/JPEG/GIF/WebP/BMP), save it to /tmp/clipboard-paste- . and paste the path as text — codex/claude can then read the file directly. If text, paste the text via tmux load-buffer + paste-buffer -p (bracketed paste). - Fallback (no wl-paste): tmux paste-buffer (original behavior). Out of scope: other unhandled menu shortcuts (w/K/r/t). One menu entry per PR keeps the diff bounded; those can be lanes of their own. --- scripts/codex-fleet/bin/pane-context-menu.sh | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/scripts/codex-fleet/bin/pane-context-menu.sh b/scripts/codex-fleet/bin/pane-context-menu.sh index 0150a0c..f4ad49e 100755 --- a/scripts/codex-fleet/bin/pane-context-menu.sh +++ b/scripts/codex-fleet/bin/pane-context-menu.sh @@ -235,6 +235,36 @@ case "$choice" in tmux display-message -d 1500 '▢ Visible area copied' ;; l) printf '%s' "$MOUSE_LINE" | wl-copy tmux display-message -d 1500 '─ Line copied' ;; + p) # Paste from the SYSTEM clipboard (Wayland wl-paste). Falls through to + # tmux's own buffer if wl-paste is unavailable. Images are detected via + # MIME type and saved to /tmp/clipboard-paste-.; the saved path + # is then pasted as text so downstream CLIs (codex/claude) can read it. + if command -v wl-paste >/dev/null 2>&1; then + mimes="$(wl-paste --list-types 2>/dev/null || true)" + img_mime="$(printf '%s\n' "$mimes" | grep -m1 -oE '^image/(png|jpeg|gif|webp|bmp)' || true)" + if [ -n "$img_mime" ]; then + ext="${img_mime#image/}"; [ "$ext" = "jpeg" ] && ext="jpg" + out="/tmp/clipboard-paste-$(date +%s).$ext" + if wl-paste --type "$img_mime" > "$out" 2>/dev/null && [ -s "$out" ]; then + printf '%s' "$out" | tmux load-buffer -b _menu_paste - + tmux paste-buffer -b _menu_paste -t "$PANE_ID" -p + tmux delete-buffer -b _menu_paste 2>/dev/null || true + tmux display-message -d 1800 "⤓ Image pasted as path: $out" + else + rm -f "$out" 2>/dev/null || true + tmux display-message -d 1500 '⚠ Image paste failed' + fi + else + wl-paste --no-newline 2>/dev/null | tmux load-buffer -b _menu_paste - + tmux paste-buffer -b _menu_paste -t "$PANE_ID" -p + tmux delete-buffer -b _menu_paste 2>/dev/null || true + tmux display-message -d 1500 '⤓ Pasted from clipboard' + fi + else + tmux paste-buffer -t "$PANE_ID" -p + tmux display-message -d 1500 '⤓ Pasted from tmux buffer (no wl-paste)' + fi + ;; '<') tmux copy-mode -t "$PANE_ID" tmux send-keys -X -t "$PANE_ID" history-top ;; '>') tmux copy-mode -t "$PANE_ID"