refactor(fleet-ui): consolidate Spotlight onto fuzzy implementation#167
Merged
Conversation
There were two Spotlight implementations with diverging behavior: - `fleet_ui::overlay::Spotlight` did substring filtering (`filter()`), used only by `fleet-waves`. - `fleet_ui::spotlight_overlay::Spotlight` did fuzzy ranking via `SpotlightFilter` (skim matcher), used by `fleet-state` and `fleet-plan-tree`. On top of that, each of the three binaries kept its own near-identical 9-item `SPOTLIGHT_ITEMS` const plus its own local `spotlight_filter()` helper — three copies of the same PANE/SESSION/FLEET catalogue. This consolidates everything onto the fuzzy implementation: - `spotlight_overlay` now exposes `SHARED_SPOTLIGHT_ITEMS` (the union of the three per-binary catalogues; all three were already identical) and a `shared_spotlight_filter(query)` helper backed by skim. - `fleet-state`, `fleet-plan-tree`, and `fleet-waves` drop their local consts and helpers and import the shared catalogue/filter. - `fleet-waves` migrates from the substring API to the fuzzy one. The `Spotlight::render(frame, area, state, items)` call becomes `Spotlight::render(frame, area, state)` (items now live inside the Spotlight value). - The Spotlight pieces are removed from `fleet_ui::overlay` — the module retains its other responsibilities (`centered_overlay`, `render_overlay`, `card_shadow`, and the `context_menu` submodule), which are still consumed by other crates. - The legacy `tests/overlay_spotlight.rs` integration test (which asserted substring filter semantics) is removed; its snapshot is superseded by `spotlight_overlay::tests::spotlight_default_render_design_b`. Net delta: 7 files, +123/-860. Migrated binaries: fleet-state, fleet-plan-tree, fleet-waves. SPOTLIGHT_ITEMS constants removed: 3 (one per binary).
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.
Summary
There were two
Spotlightimplementations infleet-uiwith diverging behavior:fleet_ui::overlay::Spotlight— substring filter (overlay::filter), used only byfleet-waves.fleet_ui::spotlight_overlay::Spotlight— fuzzy ranking viaSpotlightFilter(skim matcher), used byfleet-stateandfleet-plan-tree.On top of that, all three binaries kept their own near-identical
SPOTLIGHT_ITEMSconst +spotlight_filter()helper — three copies of the same 9-item PANE/SESSION/FLEET catalogue.This PR consolidates everything onto the fuzzy implementation and lifts the shared catalogue into
fleet-ui.Changes
spotlight_overlaynow exposes:SHARED_SPOTLIGHT_ITEMS: &[SpotlightItem<'static>]— the 9 canonical items.shared_spotlight_filter(query)— fuzzy-ranks the shared catalogue.fleet-state,fleet-plan-tree,fleet-wavesdrop their localSPOTLIGHT_ITEMSconst +spotlight_filter()helper and import the shared versions.fleet-wavesmigrates from substring to fuzzy.Spotlight::render(frame, area, state, items)becomesSpotlight::render(frame, area, state)(items moved insideSpotlight);Spotlight::new()becomesSpotlight::new(SHARED_SPOTLIGHT_ITEMS.to_vec()).fleet_ui::overlayretains its other responsibilities (centered_overlay,render_overlay,card_shadow, and thecontext_menusubmodule withContextMenu/MenuItem/Section). Only the Spotlight pieces are removed; consumers likefleet-ui/tests/button_snapshot.rsandtests/overlay_context_menu.rscontinue to work unchanged.tests/overlay_spotlight.rsintegration test (which asserted substring semantics) and its snapshot are removed. Coverage is preserved byspotlight_overlay::tests::spotlight_default_render_design_b, which renders the fuzzy variant.Migrated binaries
fleet-statefleet-plan-treefleet-waves(this is the behavior change: substring -> fuzzy)Per-binary consts removed: 3
All three were identical, so deduplication was lossless. Differences were limited to whitespace/ordering.
Line-count delta
7 files changed, +123 insertions, -860 deletions(net -737).Test plan
cargo check --workspace— greencargo test -p fleet-ui— 43 tests pass (lib + integration).spotlight_overlay::tests::spotlight_default_render_design_bandspotlight_filter::tests::*all green.cargo test -p fleet-state -p fleet-plan-tree -p fleet-waves— 17 tests pass, including:fleet-plan-tree::spotlight_tests::spotlight_catalogue_matches_watcher_orderfleet-plan-tree::spotlight_tests::spotlight_open_and_close_reset_statefleet-waves::tests::spotlight_catalogue_matches_fleet_dashboard_orderfleet-waves::tests::spotlight_open_and_close_reset_statefleet-wavesafter merge; typing should produce fuzzy matches (e.g. "spt" surfaces "Split" entries) rather than strict substring matches.Reviewer note: fleet-waves behavior change
fleet-waves's Spotlight previously matched by case-insensitive substring ontitle || sub. It now matches by fuzzy ranking ongroup + title + sub(with aPANEgroup bias fromspotlight_overlay). This is the canonical behavior already shipped infleet-stateandfleet-plan-tree; the substring variant was an outlier.