Skip to content

Optimize action/plugin search caching with normalized CachedSearchEntry#930

Merged
multiplex55 merged 3 commits intomasterfrom
codex/add-cached-entry-type-for-searchable-text
Mar 14, 2026
Merged

Optimize action/plugin search caching with normalized CachedSearchEntry#930
multiplex55 merged 3 commits intomasterfrom
codex/add-cached-entry-type-for-searchable-text

Conversation

@multiplex55
Copy link
Owner

Motivation

  • Avoid repeated to_lowercase() and temporary string allocations during search and exact-match filtering by pre-normalizing searchable fields.
  • Make plugin command cache refresh deterministic and tied to existing reload paths so cached search entries stay consistent after plugin/settings changes.
  • Improve search correctness by including normalized action id in exact-mode filtering alongside label/desc/aliases.

Description

  • Added a CachedSearchEntry struct that stores label_lc, desc_lc, and action_lc, and replaced the old action_cache: Vec<(String,String)> with action_cache: Vec<CachedSearchEntry> and added command_search_cache: Vec<CachedSearchEntry> in src/gui/mod.rs.
  • Updated update_action_cache and update_command_cache to populate normalized cache entries via CachedSearchEntry::from_action so normalization happens once per reload.
  • Refactored matches_exact_display_text, search_actions, and search_plugins to consume pre-normalized CachedSearchEntry data and to check action_lc as an additional exact-match target, while preserving existing plugin-resolved bypass logic.
  • Ensured update_paths calls update_command_cache unconditionally so plugin/settings reloads refresh the command_search_cache and keep caches in sync.

Testing

  • Added unit tests: exact_display_match_is_case_insensitive_substring, action_and_command_search_cache_is_normalized, and update_paths_refreshes_command_search_cache_for_plugin_reload in src/gui/mod.rs to validate normalized caching and behavior.
  • Ran cargo fmt --all, which completed successfully.
  • Attempted to run cargo test gui::mod::tests:: -- --nocapture, but the test build failed in this environment due to a native dependency error from alsa-sys requiring system alsa/pkg-config (not available here), so full test execution could not complete.
  • cargo fmt --all --check was used to ensure formatting; repository formatting differences unrelated to this change were noted during the rollout and addressed by running cargo fmt.

Codex Task

@multiplex55 multiplex55 merged commit 894c375 into master Mar 14, 2026
1 check passed
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