Repository navigation
fix(test): gate switch_picker stability on matcher row count, not preview vscroll - #2729
Merged
Merged
Conversation
… vscroll
Replace the indirect `display_matches_count` consistency check with an
explicit `expected_rows` parameter on `wait_for_stable_with_content` and on
each input tuple. The four `(feature, …)` filter tests now pass `Some(1)`, so
the helper actively waits for skim's matcher to narrow the list before
snapshotting and panics with a diagnostic dump (not warn-and-proceed) if it
never does.
The prior check parsed `\d+/\d+` off the right edge of the screen, intending
to read skim's match counter. But the picker uses `no_info(true)`, so the
real counter is hidden — the regex was actually matching the previewer's
`{vscroll_offset}/{content.len()}` indicator (e.g. `1/28`). That happened to
equal `visible_list_rows == 1` in the steady filtered state, so it appeared
to work, but it offered no real protection during matcher lag: under heavy
parallel load skim's matcher (own thread) lags seconds behind the prompt
repaint, the wait timed out at 30 s, and `wait_for_stable_with_content`
silently warned-and-proceeded, capturing the stale pre-filter screen with
`@ main` still visible.
Closes #2334 (reopened — #2345 only accidentally guarded the steady state).
Co-Authored-By: Claude <[email protected]>
worktrunk-bot
approved these changes
May 12, 2026
max-sixty
added a commit
that referenced
this pull request
May 12, 2026
…nters (#2733) Two comment-only fixes following #2729 — no behavioral change, no snapshot change. - `is_skim_ready` no longer claims skim "displays item count like 1/3"; the picker uses `no_info(true)`, so it doesn't render that. - The snapshot filter that normalizes the trailing `N/M` on the preview pane's first line now correctly attributes it to skim's previewer vertical-scroll indicator (`{vscroll_offset}/{content.len()}`, drawn in reverse video at the right edge — see `skim::previewer::Previewer::draw`), rather than the matcher's matched/total counter. The earlier comment's misattribution is what led #2345's stability check to parse the wrong thing; #2729 fixed the check, this fixes the comment so the misunderstanding doesn't resurface. The filter regex and replacement string are untouched. Co-authored-by: Claude <[email protected]>
7 tasks done
max-sixty
added a commit
that referenced
this pull request
May 15, 2026
… row count (#2767) 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. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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
The flake's mechanism was that skim's matcher runs on a separate thread and, under heavy parallel load (the failure first surfaced in a 3641-test nextest run), can lag seconds behind the prompt repaint. The test types
feature, skim renders> featureinto the query line, but the items list still has both rows. The prior consistency check (display_matches_count, added in #2345) was supposed to detect exactly this and reject "stable" screens with row counts that disagreed with skim'sN/Mcounter — exceptno_info(true)hides the real counter, so the regex was actually matching the previewer's{vscroll_offset}/{content.len()}indicator (e.g.1/28). That coincidentally equalledvisible_list_rows == 1in the filtered steady state, so it looked like it worked, but under matcher lag the wait simply timed out at 30 s andwait_for_stable_with_contentwarned-and-proceeded — capturing the stale unfiltered screen with@ mainstill visible.Fix
Replaced the indirect counter-parsing gate with an explicit
expected_rows: Option<usize>parameter threaded through the input tuple andwait_for_stable_with_content. Stability now requiresvisible_list_rows == expected_rowswhen set, and the timeout path panics with a diagnostic dump (instead of silently proceeding) so a future matcher-lag regression fails at the actual cause rather than at the snapshot assertion downstream.The four
(feature, …)filter tests (uncommitted,log,main_diff,summary) and the four(target, …)selection tests now passSome(1). Tests that don't depend on a specific row count passNone.parse_match_countanddisplay_matches_countare deleted — they were checking the wrong thing.Test plan
cargo run -- hook pre-merge --yes— 3666 tests pass.--test-threads=8..snap.new(both rows visible despite the filter) plus skim's source (matcher on a separate thread; previewer's vscroll indicator that the old regex was actually matching). Closes Flaky: test_switch_picker_preview_panel_main_diff on macOS #2334 (which test(switch_picker): gate stability on matcher/display consistency #2345 only accidentally guarded).