Skip to content

feat(search): invalidate file index cache on git file changes#518

Open
beruro wants to merge 1 commit into
developfrom
feat/file-index-invalidation
Open

feat(search): invalidate file index cache on git file changes#518
beruro wants to merge 1 commit into
developfrom
feat/file-index-invalidation

Conversation

@beruro

@beruro beruro commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • invalidate file-path indexes from repository watcher events instead of short TTL rebuilds
  • coalesce frontend invalidation bursts and clear pending work on listener teardown
  • single-flight equivalent index builds and reject stale generations after invalidation
  • preserve the existing 32 MiB per-repository and 64 MiB global cache bounds

Verification

  • cargo test --manifest-path src-tauri/Cargo.toml -p search file:: (9 passed)
  • cargo check --manifest-path src-tauri/Cargo.toml -p org2
  • tsc --noEmit -p tsconfig.json
  • focused Vitest suites for file index invalidation and Tauri file search (7 passed)
  • git diff --check

Performance review

  • watcher events perform only cheap invalidation; no scan or polling timer is introduced
  • burst debounce is scoped per repository and cleared on listener teardown
  • equivalent builds share one flight; invalidation generations reject stale completions
  • cache remains bounded by entry count and byte budgets

- Add an `invalidate_file_index_cache` command backed by a dedicated
  `FilePathIndexCache` (search/file/index_cache.rs), replacing the ad-hoc
  prune/insert helpers on the plain HashMap.
- Emit git-watch file-change events (event_emitter) and, on the frontend,
  invalidate the affected project's fuzzy file index via a new
  `fileIndexInvalidation` hook wired through GitStatusContext, so stale
  entries don't linger after files change on disk.
- Add `invalidateFileIndexCache` / `shouldPrewarmFileIndex` fileSearch helpers.

Adds unit tests for the invalidation hook and the fileSearch helpers.
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.

1 participant