Skip to content

test(mention): fail loudly when background search never settles - #373

Merged
srothgan merged 1 commit into
mainfrom
fix/mention-test-search-settle-timeout
Sep 7, 2026
Merged

srothgan merged 1 commit into
mainfrom
fix/mention-test-search-settle-timeout

Conversation

@srothgan

@srothgan srothgan commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Summary

run_search, the test helper that waits for the background file index in src/app/mention.rs, polled a fixed 200 × 5 ms (1 s) and then returned silently when the budget ran out. Callers then asserted against whatever half-scanned state existed.

  • Replaced the fixed iteration count with a deadline, raising the budget to 30 s
  • Turned an exhausted budget into an assertion failure that reports index_status, search_status and pending_match_sequence
  • Drained events before sleeping, so an already-settled search returns without waiting out a poll interval

Test-only change; no production code is touched.

Why

The Nightly run 34098364599 failed on both attempt 1 and attempt 2, only in Test (macos-latest); Ubuntu, Windows and every build and smoke job passed.

  • Attempt 1: completed_search_includes_shallow_and_deep_matches (search_status != Ready) and query_change_refilters_from_cache_without_restarting_walk (left: 2, right: 1)
  • Attempt 2: only the latter, same assertion

src/app/mention.rs and src/app/file_index.rs were both last changed by dd12688 (2026-08-23), and the Aug 24 and Aug 31 nightlies passed on that same code, so this is not a regression. The shared cause is the silent timeout: on a loaded macOS runner the walk does not settle inside 1 s, and the tests then assert against a partial index. The current assertions cannot distinguish "the index never settled" from "the matcher settled and still returned the wrong candidates", which is why the failure reads as a confusing 2 vs 1 mismatch.

This does not by itself prove the extra candidate is only a test artifact. apply_match_result replaces mention.candidates wholesale and for_each_candidate skips entries whose strip_prefix(root) fails, so neither duplicate accumulation nor macOS /var/private/var path pollution explains it; the remaining suspect is a stale nucleo snapshot around rebuild_stream(false) (src/app/file_index.rs:510). After this change, a recurrence reports which of the two it was.

Closes #

Validation

  • Automated: cargo fmt --all -- --check and cargo test --lib app::mention:: pass locally on Windows. That is weak evidence — the failure is a macOS-only timing flake and did not reproduce locally before the change either. CI is the real check.
  • Manual: N/A
  • Screenshot/video (if UI changed): N/A

Notes

  • Breaking changes: N/A
  • Docs updated: N/A
  • Governance/release impact: N/A
  • cargo clippy --all-targets --all-features -- -D warnings was not run locally; left to CI.

- Replace the fixed 200-iteration poll in `run_search` with a deadline so the wait scales past the previous 1s budget
- Assert on timeout instead of returning silently, reporting index status, search status and pending match sequence
- Drain events before sleeping so an already-settled search returns without an extra poll interval
- Extract `SEARCH_SETTLE_TIMEOUT` and `SEARCH_SETTLE_POLL_INTERVAL` to document that the budget targets the slowest CI runner
@srothgan srothgan added type: refactor Refactoring, performance, tests, and code style area: tui Terminal UI, rendering, input, and keymap labels Sep 7, 2026
@srothgan srothgan self-assigned this Sep 7, 2026
@srothgan
srothgan merged commit 8def7e3 into main Sep 7, 2026
16 checks passed
@srothgan
srothgan deleted the fix/mention-test-search-settle-timeout branch September 7, 2026 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: tui Terminal UI, rendering, input, and keymap type: refactor Refactoring, performance, tests, and code style

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant