fix: capture-pane CLI expands POSIX short flag clusters#326
Conversation
`psmux capture-pane -ep -t <target>` returned exit 0 with empty stdout,
while `psmux capture-pane -e -p -t <target>` (same flags, separated)
worked correctly.
Root cause: the CLI dispatcher for `capture-pane` in `main.rs` matched
flag strings exactly (`"-p"`, `"-e"`, `"-J"`), so a POSIX short flag
cluster like `-ep` or `-pe` fell through to `_ => {}` and was silently
dropped. As a result `print_stdout` stayed `false` and the command was
routed to the fire-and-forget `send_control` branch — no response was
printed, hence the empty stdout and exit 0.
Fix: add a `match` arm that detects an argument of the form `-XYZ`
whose every character after the dash is one of the capture-pane
boolean shorts (`p`, `e`, `J`), and emit each flag individually.
Value-taking flags (`-t`, `-S`, `-E`, `-b`) take a following argument
and are not eligible for clustering — they stay on their existing
arms.
Smoke matrix (attached 29x120 session):
| Form | Before | After |
|---------|--------|-------|
| -p | 1281 | 1281 |
| -e -p | 2312 | 2312 |
| -ep | 0 | 2312 |
| -pe | 0 | 2312 |
Zero regression on the separated forms; the cluster form now matches
the separated-flag output and contains ANSI SGR escapes as expected
for -e.
The CLI dispatcher for capture-pane matched flag strings exactly (-p, -e, -J), so a POSIX short flag cluster like -ep or -pe fell through to the wildcard arm and was silently dropped. As a result print_stdout stayed false and capture-pane returned empty stdout with exit 0. Add a match arm that detects arguments of the form -XYZ whose every character after the dash is one of the capture-pane boolean shorts (p, e, J), and emits each flag individually. Value-taking flags (-t, -S, -E, -b) take a following argument and are not eligible for clustering. This is a tmux parity fix: tmux's args_parse_flags() uses a character-by-character loop that naturally supports POSIX flag clustering for all commands. 19 E2E tests pass, 2110 Rust tests pass (0 regressions). Co-authored-by: David Berlioz <berliozdavid@gmail.com>
|
Hey @quazardous, another solid catch. Applied in 72d08aa with your Co-authored-by credit. Bug confirmed before patch:
POSIX flag clusters silently fell through to After patch:
All cluster combinations now match their separated equivalents. What I verified (19/19 E2E tests pass):
tmux parity note: tmux natively supports POSIX flag clustering for ALL commands through its Thanks David, two for two this week. |
|
Applied in commit 72d08aa with Co-authored-by credit. Thanks @quazardous! |
…#37) psmux <= v3.3.4 silently dropped POSIX short-flag clusters in the capture-pane CLI dispatcher (returned exit 0 + empty stdout), so the `-ep` form we used at both call sites lost ANSI on graphite. Upstream fix landed in psmux commit 72d08aa via PR psmux/psmux#326. Switch both call sites (src/pane.ts captureOnce, src/api/agents.ts SSE tick) to the separated `-e -p` form — works on every psmux version, not just post-72d08aa. With the cluster form gone, the b/w fallback in captureOnce (text="" retry without -e) is dead code and removed. Also updates the stale "Caveat psmux : capture-pane may handle -e differently — to validate with #467" comment in agents.ts now that the caveat is gone, and the matching reference in TerminalView.vue.
Summary
psmux capture-pane -ep -t <target>returned exit 0 with empty stdout, whilepsmux capture-pane -e -p -t <target>(same flags, separated) worked correctly.Root cause
The CLI dispatcher for
capture-paneinmain.rsmatched flag strings exactly ("-p","-e","-J"), so a POSIX short flag cluster like-epor-pefell through to_ => {}and was silently dropped. As a resultprint_stdoutstayedfalseand the command was routed to the fire-and-forgetsend_controlbranch — no response was printed, hence the empty stdout and exit 0.Fix
Add a
matcharm that detects an argument of the form-XYZwhose every character after the dash is one of the capture-pane boolean shorts (p,e,J), and emit each flag individually. Value-taking flags (-t,-S,-E,-b) take a following argument and are not eligible for clustering — they stay on their existing arms.Smoke matrix (attached 29×120 session)
-p-e -p-ep-peZero regression on the separated forms; the cluster form now matches the separated-flag output and contains ANSI SGR escapes as expected for
-e.Test plan
cargo build --releaseclean-ep/-pe→ 0 bytes ;-p/-e -p→ text)