fix(watch): copy backend cascade + tmux load-buffer + env pre-flight#35
Merged
Conversation
User on a headless SSH dev box hit `copy failed: xclip exited with 1` when pressing `c` in `muxa watch`. Root cause: `xclip` was on PATH so the previous backend list tried it; with `$DISPLAY` unset the binary exits 1, and the dispatch surfaced that failure to the user instead of cascading to the /tmp fallback. Three improvements: 1. Lead with `tmux load-buffer` when `$TMUX` is set. Loads the prompt into tmux's paste buffer (`prefix + ]`); on tmux 3.2+ with `set -g set-clipboard on` it also forwards to the host terminal's clipboard via OSC 52. A single backend covers most of the "remote dev over SSH" case where xclip/wl-copy can't reach a display server. 2. Pre-flight env check before each X11/Wayland backend: `wl-copy` requires `$WAYLAND_DISPLAY`; `xclip` / `xsel` require `$DISPLAY`. If the env var is unset we skip the backend entirely instead of running it and waiting for it to fail. 3. Cascade past `Failed`, not just `NotFound`. The original code bubbled `Failed` to the user — the comment said "so the user sees `xclip: ...` rather than a silent /tmp surprise" — but that's only the right call if there's no further backend to try. With the env pre-flight in place the chain only contains plausibly-working backends, so a Failed from any of them means "this one really didn't work, try the next." Also added `xsel` as another X11 candidate for users who don't install xclip. Tests pass without modification — the existing recorder-based tests don't actually invoke clipboard helpers; they just exercise the action-dispatch state machine. Workspace 477 → 477 (same), but clippy required two minor adjustments alongside the rewrite: - `PipeErr::Failed(String)` is now `#[allow(dead_code)]` — the cascade past Failed means callers don't read the message; it stays for debug traces and future use. - Used `is_ok()` instead of a `match` over a single happy-path variant in the new dispatch loop (clippy `single_match`). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
User on a headless SSH dev box hit `copy failed: xclip exited with 1` when pressing `c` in `muxa watch`. `xclip` was on PATH so the priority list tried it; without `$DISPLAY` set the binary exits 1, and the dispatch surfaced that failure to the user instead of cascading.
Three improvements
`xsel` added as another X11 candidate.
Test plan
🤖 Generated with Claude Code