Skip to content

Debounce completion index rebuilds for action/command cache updates#896

Merged
multiplex55 merged 2 commits intomasterfrom
codex/add-dirty-flags-and-optimize-caches
Feb 19, 2026
Merged

Debounce completion index rebuilds for action/command cache updates#896
multiplex55 merged 2 commits intomasterfrom
codex/add-dirty-flags-and-optimize-caches

Conversation

@multiplex55
Copy link
Copy Markdown
Owner

Motivation

  • Prevent expensive immediate rebuilds of the completion index on frequent watch events and avoid stale suggestions leaking during event bursts.
  • Keep update_suggestions behavior unchanged while ensuring rebuilds are coalesced and only the relevant caches trigger a rebuild.

Description

  • Add a short debounce window constant COMPLETION_REBUILD_DEBOUNCE and per-source dirty flags action_completion_dirty and command_completion_dirty on LauncherApp to track which part of the completion index needs rebuilding.
  • Change update_action_cache and update_command_cache to mark only their respective dirty flag and call schedule_completion_rebuild instead of directly running update_completion_index.
  • Introduce schedule_completion_rebuild, maybe_rebuild_completion_index, and rebuild_completion_index_now helpers to clear stale completion_index/suggestions, defer the rebuild for the debounce period, and handle immediate rebuild at startup.
  • Call maybe_rebuild_completion_index at the end of process_watch_events so bursts of WatchEvents are coalesced; leave update_suggestions logic intact once the index is rebuilt.
  • Add unit tests in the src/gui/mod.rs test module: watch_event_bursts_delay_completion_rebuild_until_debounce_window and completion_suggestions_clear_until_rebuild_and_match_latest_entries to validate debouncing and suggestion freshness.

Testing

  • Ran cargo fmt which completed successfully.
  • Attempted to run the new tests with cargo test, and specifically exercised watch_event_bursts_delay_completion_rebuild_until_debounce_window, but the test run could not complete in this environment because building the dependency graph failed due to a missing system library (alsa.pc) required by alsa-sys (system pkg-config dependency), so tests did not finish here.

Codex Task

@multiplex55 multiplex55 merged commit 986e394 into master Feb 19, 2026
1 check passed
@multiplex55 multiplex55 deleted the codex/add-dirty-flags-and-optimize-caches branch February 20, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant