Skip to content

test(switch): assert alt-l/alt-h no-op via before/after equality - #3245

Merged
max-sixty merged 3 commits into
mainfrom
alt-l-invariant
Jun 25, 2026
Merged

max-sixty merged 3 commits into
mainfrom
alt-l-invariant

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Rewrites test_switch_picker_alt_l_does_not_hscroll from a committed full-list snapshot to a before/after equality invariant, and dedupes the PTY test-helper boilerplate the rewrite touched.

The problem

The alt-l test asserted a one-bit belief — "alt-l/alt-h don't horizontally scroll the picker list" — by committing the entire rendered list as a snapshot (switch_picker_alt_l_ignored_list.snap). That over-coupled it to two things it doesn't care about:

The change

Assert the invariant directly: capture the settled list, press alt-l/alt-l/alt-h, capture again, and require the two byte-for-byte equal. No committed frame, so column-layout changes never touch this test and there's no frozen baseline to diverge from a sibling on async timing. The snapshot is deleted.

The rewrite would have triplicated the PTY boot boilerplate, so it's extracted instead, shared across the picker PTY helpers:

  • boot_picker_pty — spawn + skim-ready + initial stabilize.
  • abort_and_exit_code — Escape + discard-drain + exit poll (the two capture-then-abort helpers).
  • list_pane_text — list-pane extraction, shared with panels().

Testing

The equality assertion was teeth-checked: injecting a Down-arrow (which moves the > cursor inside the list pane) makes it fail, so it catches a real list change. The full suite is green, and the new test passes under #3236's new main…± column layout — confirming it's immune to the exact coupling it removes.

This was written by Claude Code on behalf of max

max-sixty and others added 2 commits June 25, 2026 10:48
Replace the committed full-list snapshot for
test_switch_picker_alt_l_does_not_hscroll with a before/after equality
invariant: capture the settled list, press alt-l/alt-l/alt-h, capture
again, and require the two byte-for-byte equal. The belief is narrow —
"alt-l/alt-h change nothing" — so asserting it directly drops the
snapshot's coupling to picker column layout and to async-column render
timing. That coupling is what broke #3227: the frozen frame captured a
different async state (a populated Age/[TIME] column) than its sibling
multiple-worktrees snapshot, so a column change silently diverged them.

Dedupe the PTY plumbing the rewrite would otherwise have triplicated:
boot_picker_pty (spawn + skim-ready + initial stabilize) and
abort_and_exit_code (Escape + discard-drain + exit poll), plus a
list_pane_text helper shared with panels().

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Resolve the alt-l snapshot delete/modify conflict by keeping it deleted:
the test no longer snapshots a frozen frame (it asserts a before/after
equality invariant), so #3236's column-layout regen of that snapshot is
moot — the exact coupling the rewrite removes.

Integrate the rewritten picker helpers with #3238's deflake work:
exec_in_pty_capture_noop_probe now sends inputs through the merged-in
send_input_awaiting_content path, alongside boot_picker_pty and
abort_and_exit_code.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Approved. The test (windows) failure is an unrelated Windows PTY flake, not a regression from this change — I've re-run the failed jobs and left the approval in place.

All 26 failures are switch_picker.rs PTY tests, every one panicking on the same write_all(...).unwrap() against the PTY writer after the child has exited — the known Windows PTY write-after-exit race (#3242 is de-flaking these same tests). It's not specific to the rewritten test: 20 of the 26 panic at send_input_awaiting_content, which this PR doesn't touch, and the two write_all().unwrap() call sites both predate this PR on main. The new test_switch_picker_alt_l_does_not_hscroll failed on the shared PTY-write panic, not on its new equality assertion.

Evidence

Windows run 28190121758, job test (windows):

26 FAILED — all integration_tests::switch_picker::* PTY tests
panic sites:
  20 × switch_picker.rs:602:39   w.write_all(input.as_bytes()).unwrap()  (send_input_awaiting_content — unchanged by this PR)
   6 × switch_picker.rs:236:30   w.write_all(b"\x1b").unwrap()           (abort_and_exit_code — relocated, logic unchanged)

Both .unwrap() patterns exist on origin/main before this PR (write_all(b"\x1b").unwrap() and write_all(input.as_bytes()).unwrap()). A mass simultaneous failure of every PTY test with identical write-after-exit panics points at a runner-level skim/PTY hiccup, not a deterministic logic bug in the diff.

boot_picker_pty took the writer/reader from the PTY pair's MasterPty and
then dropped the master on return, threading out only child/writer/rx/
parser. On Unix take_writer() hands back an independent fd so this is
harmless, but on Windows dropping the MasterPty tears down the ConPTY —
so every subsequent write to the picker failed with BrokenPipe ("The
pipe is being closed"), failing all 26 switch_picker tests on the Windows
runner while Linux/macOS stayed green.

Return the master in a PickerSession struct and have each helper hold it
(`_master`) for the session's lifetime, restoring the lifetime the
pre-extraction inline helpers had (where `pair` lived for the whole fn).
The struct also clears clippy's type_complexity on the former 5-tuple.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@worktrunk-bot

Copy link
Copy Markdown
Collaborator

The required test (windows) job passed on this commit — the _master-lifetime fix does what it set out to do: holding the ConPTY master alive for the session keeps the picker writes from failing with BrokenPipe. That's the change validated end-to-end on the platform it targets.

The two red jobs — test (macos) (required) and affected tests (windows, advisory) — are both the same unrelated flake, not a regression from this change: test_switch_picker_worktree_row_comments_tab_shows_thread timing out after 30s waiting for diff --git to render in the preview pane (switch_picker.rs:584). That's the documented preview-content-load race (the send_input_awaiting_content doc comment calls it out as a load-induced flake where the git diff compute loses the race against the keystroke), on the preview render path — orthogonal to this PR's PTY write path. On macOS the _master change is a no-op anyway, since take_writer() hands back an independent fd.

Approval left in place; I've re-run the two failed jobs.

Evidence

Both failures, identical signature:

test integration_tests::switch_picker::test_switch_picker_worktree_row_comments_tab_shows_thread ... FAILED
panicked at tests/integration_tests/switch_picker.rs:584:9:
Timed out after 30s waiting for expected content "diff --git" to appear on screen.

This is the same class of PTY/preview timing flake #3242 is de-flaking; this commit doesn't touch the comments-tab preview path.

@max-sixty
max-sixty merged commit 94b989c into main Jun 25, 2026
48 of 50 checks passed
@max-sixty
max-sixty deleted the alt-l-invariant branch June 25, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants