Repository navigation
Conversation
Under heavy macOS parallel load, skim's matcher updates its `N/M` counter ahead of the list-panel repaint, so `wait_for_stable` could declare a screen stable while a filtered-out row was still visible — producing the flaky `test_switch_picker_preview_panel_main_diff` snapshot diff tracked in #2334. Add a consistency check that rejects stable states where skim's match count doesn't equal the visible list-row count, in both the primary and fallback return paths. Closes #2334 Co-Authored-By: Claude <[email protected]>
worktrunk-bot
approved these changes
Apr 20, 2026
2 of 3 tasks
max-sixty
added a commit
that referenced
this pull request
May 12, 2026
…view vscroll (#2729) ## 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 `> feature` into 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's `N/M` counter — except `no_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 equalled `visible_list_rows == 1` in the filtered steady state, so it looked like it worked, but under matcher lag the wait simply timed out at 30 s and `wait_for_stable_with_content` warned-and-proceeded — capturing the stale unfiltered screen with `@ main` still visible. ## Fix Replaced the indirect counter-parsing gate with an explicit `expected_rows: Option<usize>` parameter threaded through the input tuple and `wait_for_stable_with_content`. Stability now requires `visible_list_rows == expected_rows` when 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 pass `Some(1)`. Tests that don't depend on a specific row count pass `None`. `parse_match_count` and `display_matches_count` are deleted — they were checking the wrong thing. ## Test plan - [x] `cargo run -- hook pre-merge --yes` — 3666 tests pass. - [x] Switch picker suite (19 tests) passes under `--test-threads=8`. - [ ] Stress repro: the original flake reproduced ~1/19 in the very first repro attempt under contention, then did not reproduce in 100+ isolated iterations nor 14 iterations under explicit CPU stress. The fix is hypothesis-based but firmly grounded in the captured `.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 #2334 (which #2345 only accidentally guarded). Co-authored-by: Claude <[email protected]>
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]>
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]>
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.
Under heavy macOS parallel load, skim's matcher updates its
N/Mcounter ahead of the list-panel repaint, sowait_for_stablecould declare a screen stable while a filtered-out row was still visible — producing thetest_switch_picker_preview_panel_main_diffsnapshot diff tracked in #2334.Reproduced locally by running the test binary under 8-way parallel cargo test load (~1-in-120 failure rate). An instrumentation trace showed the captured t=0 screen with skim's counter at
1/4but two list rows still visible.Fix: add a consistency check that rejects stable states where skim's parsed match count doesn't equal the visible list-row count, in both the primary and fallback return paths of
wait_for_stable_with_content.Validated locally with 1480 iterations under 8-way parallel load on macOS: 0 failures. Full
switch_pickersuite (17 tests) passes.Closes #2334