test: pin automation target resolution at base-index 1; document duration flag units - #178
Open
edwinhu wants to merge 1 commit into
Open
Conversation
Adds a regression guard for the pane-target resolution shared by the
rmux-specific automation commands, and documents the unit requirement on
the duration flags.
Under `base-index 1` + `pane-base-index 1`, rmux 0.8.0 failed every
extension command with
unable to resolve pane id for target <session>:<window>.0
even when the caller passed a fully explicit `session:window.pane` slot
or a `%id`. The tmux-compatible surface (`capture-pane`, `list-panes`)
resolves server-side and was unaffected, so the break was invisible to
anyone on the default zero-based indices.
The resolution itself is already fixed on main: `pane_id_for_slot` now
selects `#{pane-base-index}` and `listed_pane_index_matches_target`
adds it before comparing against the display-space `#{pane_index}`.
What was missing is a test that pins it. `nonzero_pane_base_index_*`
covers `pane-base-index` alone, with `base-index` still 0 and only
slot-shaped targets, so the reported configuration was not exercised.
The new test sets both indices to 1 and drives pane-snapshot, wait-pane,
locator and expect-pane against all three target spellings, including a
bare session target, which must land on the ACTIVE pane rather than on
display index 0 (which does not exist when pane-base-index is 1).
Reverting the `saturating_add(pane_base_index)` in
`listed_pane_index_matches_target` fails it.
Separately, `parse_duration` rejects bare integers so that `--timeout
8000` can never be read ambiguously, but `--help` rendered the flag as a
bare `--timeout <TIMEOUT>` with no help text, leaving the requirement
discoverable only by hitting the error. The duration flags now carry a
`<DURATION>` value name and state the accepted units, and the rejection
message carries an example.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9BMBLf4cXLCZfxCPRvctZ
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
Adds a regression test pinning pane-target resolution for the rmux-specific automation commands at
base-index 1+pane-base-index 1, and documents the unit requirement on the duration flags.The bug this pins
Reported against 0.8.0 (current nixpkgs). With
base-index 1set, every rmux extension subcommand failed while the tmux-compatible surface worked:Root cause in 0.8.0 was
pane_id_for_slot, which listed the window's panes with#{pane_index}\t#{pane_id}and compared the internaltarget.pane_index()directly against the display-space#{pane_index}. Under a non-zero base index those spaces differ by one, no row matched, and the command bailed.capture-paneresolves server-side and was unaffected, so the break was invisible on the default zero-based indices.The error text naming
rt:1.0regardless of the target passed made this look like the target was being discarded; it is not — it isDisplay for PaneTargetrendering the already-normalized internal indices.This is already fixed on
main.270dd546added#{pane-base-index}to the format string and routed the comparison throughlisted_pane_index_matches_target, which applies the offset. I verifiedmainat9f007bf6resolves all three target spellings correctly.What this PR adds
1. A regression test for the reported configuration. The existing
nonzero_pane_base_index_preserves_targeted_automation_and_percent_resizepinspane-base-indexalone, withbase-indexstill0and only slot-shaped targets — so the reported setup was never exercised. The newbase_index_one_resolves_every_automation_target_spellingsets both indices to1, asserts the layout really is shifted (so it can't pass vacuously), and drivespane-snapshot,wait-pane,locatorandexpect-paneagainst:alpha:1.1andalpha:1.2— explicit slots%<id>for each pane — stable idsalpha— which must land on the active pane, not display index 0 (which does not exist underpane-base-index 1)Reverting the
saturating_add(pane_base_index)inlisted_pane_index_matches_targetfails the test, so it guards the actual fix rather than the surrounding scaffolding.2.
--timeout/--stable-for/--ttldocument their required unit.parse_durationrejects bare integers on purpose —--timeout 8000must not be silently read as either 8s or 8000s — but--helprendered the flag as a bare--timeout <TIMEOUT>with no help text, so the requirement was discoverable only by triggering the error. I kept the strict parse and fixed the discoverability:duration_flags_document_their_required_unitpins both the help text and the example in the rejection.Verification
cargo test --test automation_cli— 25 passedcargo test --test cli_surface— 145 passed;manpage_surface— 1 passedcargo test --bin rmux— 530 passedcargo fmt --all -- --checkclean;cargo clippy --all-targetsadds no new warningsbase-index 1daemon built from this branch:pane-snapshot,stream-paneandwait-paneall return pane content for-t rt,-t rt:1.1and-t %0Note on an unrelated pre-existing failure
cargo test --test acceptance_cli_matrixfails 2 of 22 on unmodifiedmainat9f007bf6in my environment —cli_acceptance_matrix_exercises_real_daemon_stateanddetached_window_spawns_without_c_use_non_attached_caller_cwd, both withcan't find window: 0. It reproduces with the working tree stashed, so it is not caused by this change, but the failure mode looks like the same display-vs-internal index confusion and may be worth a separate look.