Skip to content

test(switch_picker): gate target-selection tests on preview pane, not row count - #2767

Merged
max-sixty merged 1 commit into
mainfrom
picker-macos-flake
May 15, 2026
Merged

max-sixty merged 1 commit into
mainfrom
picker-macos-flake

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

The expected_rows: Some(1) gate (added in #2729) waits for skim's row list to filter down after the test types its query. But skim's matcher runs on a separate thread, and under heavy parallel macOS load the row redraw can lag the matcher by more than the 30s timeout — even though skim's selection cursor and preview pane have already advanced to the matched item. The gate then panics with saw 2, while the test would have selected the right item anyway: Enter acts on the cursor, not on which rows happen to be painted. This is the flake reported on test_switch_picker_no_cd_prints_branch_without_switching (local) and test_switch_picker_switch_to_existing_worktree (CI on #2764).

These three target-selection tests don't snapshot the list panel, so they don't need the filter applied — only the cursor on the right item. They now gate on the preview-pane text that's emitted once skim's selection moves to target-branch, which tracks the cursor rather than the lagging redraw. If selection genuinely never moves, the content gate still fails loudly, so the diagnostic value of #2729 is preserved.

Reproduced the original flake at ~2/5 with 5 parallel cargo test test_switch_picker -- --test-threads=20. After the fix: 0 occurrences of the line-528 panic across 48-run focused stress, the original 5×20 recipe, and a 16× pathological run. The preview_panel_* snapshot tests share the same matcher-lag root cause but genuinely need the filter applied (they snapshot the list); they weren't in scope here and remain as follow-up.

Also deletes test_switch_picker_no_cd_suppresses_directive — a strict subset of test_switch_picker_no_cd_prints_branch_without_switching (identical setup/env/inputs, both assert exit 0 + empty cd file; the latter additionally asserts the printed branch name). Same belief, no coverage lost. Net diff is a reduction.

… row count

The `expected_rows: Some(1)` gate (added in #2729) waits for skim's row
list to filter down after typing the query. Under heavy parallel macOS
load skim's matcher runs on a separate thread, and the row redraw can lag
the matcher by >30s even though the selection cursor and preview pane have
already advanced to the matched item — so the gate times out and panics
("saw 2") while the test would have selected the right item anyway (Enter
acts on the cursor, not the painted rows).

These three tests don't snapshot the list, so they don't need the filter
applied — only the cursor on the right item. Gate instead on the
preview-pane text emitted once skim's selection moves to target-branch,
a signal that tracks the cursor rather than the lagging redraw. If
selection genuinely never moves, the content gate still fails loudly.

Also delete test_switch_picker_no_cd_suppresses_directive: it was a strict
subset of test_switch_picker_no_cd_prints_branch_without_switching (same
setup/env/inputs, both assert exit 0 + empty cd file; the latter also
asserts the printed branch name). Same belief, no coverage lost.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 9bea859 into main May 15, 2026
33 checks passed
@max-sixty
max-sixty deleted the picker-macos-flake branch May 15, 2026 21:33
max-sixty added a commit that referenced this pull request May 15, 2026
…gate (#2769)

Follow-up to #2767, which fixed the observed macOS picker flake on the
target-selection tests by gating on preview-pane text instead of
`expected_rows: Some(1)`. That left the same matcher-lag root cause live
in the four `preview_panel_*` tests, and left the `expected_rows` gate
machinery in place even though it had no remaining users.

The `preview_panel_*` tests typed `"feature"` to filter the picker to
one row, then gated on `expected_rows: Some(1)`. skim's matcher runs on
a separate thread; under heavy parallel macOS load its row redraw can
lag the keystroke-driven prompt past the 30s gate timeout and panic with
the `saw 2` diagnostic. These tests select `feature` by Down-arrow
navigation instead — the matcher only runs on query changes, so cursor
navigation never invokes it and the selection is deterministic
regardless of load. The flake is structurally impossible here now, not
papered over with a longer timeout.

With no remaining `Some(n)` call site, the entire `expected_rows`
machinery is dead. This removes the third tuple element across all
PTY-test call sites, both PTY-helper signatures, the loop bindings,
`visible_list_rows()`, the `display_ready` branch, and the line-525 `saw
N` timeout panic (the historical #2334/#2345 flake site).
`wait_for_stable_with_content` now gates only on content + stability.

Also deletes `test_switch_picker_switch_to_existing_worktree`: a strict
subset of `test_switch_picker_emits_cd_directive_by_default` (identical
setup/inputs/default command) whose `screen.contains("target-branch") ||
"Switched" || "cd "` assertion passed even on a wrong selection, since
`target-branch` is in the picker list itself. The cd-directive test
already verifies the real switch outcome via the directive file.

Reviewer note: the four `preview_panel_*` `_list` snapshots now show two
rows (`@ main` + cursor on `+ feature`) instead of one filtered row.
That is the intended, deterministic consequence of dropping the filter
query, not a regression — the tests assert preview-panel content; the
list panel is incidental scaffolding.

Net diff is a reduction (−173/+65 in the test file). Verified: all 18
`switch_picker` tests pass, `cargo fmt --check` clean, `cargo clippy
--tests --features shell-integration-tests` clean.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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