From 8b0283598e2f0a3df67114fb25943e1bc46b250a Mon Sep 17 00:00:00 2001 From: NagyVikt Date: Sat, 16 May 2026 01:59:49 +0200 Subject: [PATCH] fix(tmux-menu): keep mouse selection visible after drag-release MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Operator complaint: highlighting text via mouse drag flashed for ~50ms then auto-hid because tmux's MouseDragEnd1Pane bound `copy-pipe-and- cancel` (which exits copy-mode + clears the highlight). The newly-shipped right-click "Copy selection" row (PR #145) needs the selection to STAY visible long enough to right-click + commit. Surgical change in scripts/codex-fleet/style-tabs.sh: 1. MouseDragEnd1Pane swaps `copy-pipe-and-cancel` → `copy-pipe-no-clear`. Selection persists in copy-mode after release; buffer is still populated (so the menu's `#{buffer_sample}` preview still works); user dismisses with Esc, a new drag, or by clicking "Copy selection". 2. Smart-top "Copy selection" command appends `send-keys -X cancel` before the toast so clicking it copies + cleanly exits copy-mode in one go (no stuck-in-copy-mode after the menu dismisses). Explicit-commit gestures (Enter, y, double-click, triple-click) intentionally KEEP `copy-pipe-and-cancel` — those are "I'm done" and should still drop back to normal mode immediately. --- scripts/codex-fleet/style-tabs.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/codex-fleet/style-tabs.sh b/scripts/codex-fleet/style-tabs.sh index 338ad0d..b3fdac5 100755 --- a/scripts/codex-fleet/style-tabs.sh +++ b/scripts/codex-fleet/style-tabs.sh @@ -306,7 +306,7 @@ bind-key -T root MouseDown3Pane \ select-pane -t = ; \ display-menu -O -x M -y M \ -T "#[align=centre,bold,fg=#FFFFFF,bg=#1C1C1E] pane #{pane_index} · #{pane_id} " \ - "#{?#{!=:#{buffer_size},0},#[fg=#34C759]✓ #[fg=#FFFFFF,bold]Copy selection #[fg=#8E8E93,italics]\"#{=/22/...:buffer_sample}\",-}" "" "run-shell \"tmux save-buffer - | bash ${CODEX_FLEET_REPO_ROOT}/scripts/codex-fleet/bin/pane-menu-clip-dual.sh && tmux display-message -d 1200 '✓ selection copied'\"" \ + "#{?#{!=:#{buffer_size},0},#[fg=#34C759]✓ #[fg=#FFFFFF,bold]Copy selection #[fg=#8E8E93,italics]\"#{=/22/...:buffer_sample}\",-}" "" "run-shell \"tmux save-buffer - | bash ${CODEX_FLEET_REPO_ROOT}/scripts/codex-fleet/bin/pane-menu-clip-dual.sh && tmux send-keys -X -t '#{pane_id}' cancel 2>/dev/null ; tmux display-message -d 1200 '✓ selection copied'\"" \ "#[fg=#34C759]↳ #[fg=#FFFFFF]Paste clipboard" p "run-shell \"wl-paste --no-newline | tmux load-buffer - && tmux paste-buffer -d -p -t '#{pane_id}'\"" \ "" "" "" \ "#[fg=#AEAEB2]▣ #[fg=#FFFFFF]Copy whole pane" C "run-shell \"tmux capture-pane -t '#{pane_id}' -p -S - -E - | bash ${CODEX_FLEET_REPO_ROOT}/scripts/codex-fleet/bin/pane-menu-clip-dual.sh && tmux display-message -d 1200 '▣ pane history copied'\"" \ @@ -428,7 +428,14 @@ if [[ -n "$_clip_cmd" ]]; then # Drag-end fires inside copy-mode-vi (MouseDrag1Pane enters copy-mode -M # for non-mouse-grabbing panes). Pipe the selection through the clipboard # tool then cancel copy-mode so the user is back at the prompt. - tmux bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "$_clip_cmd" 2>/dev/null || true + # MouseDragEnd1Pane uses `copy-pipe-no-clear` (not -and-cancel) so the + # visual highlight persists after the user releases the mouse — they + # can right-click → "Copy selection" without losing what they selected. + # Esc / new drag dismisses the highlight; the right-click "Copy selection" + # row also runs `send-keys -X cancel` after copying for a clean exit. + # Explicit commit gestures (Enter, y, double-click, triple-click) stay on + # `copy-pipe-and-cancel` because the user has already signaled "I'm done". + tmux bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-no-clear "$_clip_cmd" 2>/dev/null || true # `Enter` and `y` (vi yank) — also pipe through clipboard. tmux bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "$_clip_cmd" 2>/dev/null || true tmux bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "$_clip_cmd" 2>/dev/null || true