Skip to content

refactor(fleet-ui): consolidate Spotlight onto fuzzy implementation#167

Merged
NagyVikt merged 1 commit into
mainfrom
refactor/spotlight-consolidate
May 16, 2026
Merged

refactor(fleet-ui): consolidate Spotlight onto fuzzy implementation#167
NagyVikt merged 1 commit into
mainfrom
refactor/spotlight-consolidate

Conversation

@NagyVikt
Copy link
Copy Markdown
Contributor

Summary

There were two Spotlight implementations in fleet-ui with diverging behavior:

  • fleet_ui::overlay::Spotlight — substring filter (overlay::filter), used only by fleet-waves.
  • fleet_ui::spotlight_overlay::Spotlight — fuzzy ranking via SpotlightFilter (skim matcher), used by fleet-state and fleet-plan-tree.

On top of that, all three binaries kept their own near-identical SPOTLIGHT_ITEMS const + 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_overlay now 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-waves drop their local SPOTLIGHT_ITEMS const + spotlight_filter() helper and import the shared versions.
  • fleet-waves migrates from substring to fuzzy. Spotlight::render(frame, area, state, items) becomes Spotlight::render(frame, area, state) (items moved inside Spotlight); Spotlight::new() becomes Spotlight::new(SHARED_SPOTLIGHT_ITEMS.to_vec()).
  • fleet_ui::overlay retains its other responsibilities (centered_overlay, render_overlay, card_shadow, and the context_menu submodule with ContextMenu / MenuItem / Section). Only the Spotlight pieces are removed; consumers like fleet-ui/tests/button_snapshot.rs and tests/overlay_context_menu.rs continue to work unchanged.
  • The legacy tests/overlay_spotlight.rs integration test (which asserted substring semantics) and its snapshot are removed. Coverage is preserved by spotlight_overlay::tests::spotlight_default_render_design_b, which renders the fuzzy variant.

Migrated binaries

  • fleet-state
  • fleet-plan-tree
  • fleet-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 — green
  • cargo test -p fleet-ui — 43 tests pass (lib + integration). spotlight_overlay::tests::spotlight_default_render_design_b and spotlight_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_order
    • fleet-plan-tree::spotlight_tests::spotlight_open_and_close_reset_state
    • fleet-waves::tests::spotlight_catalogue_matches_fleet_dashboard_order
    • fleet-waves::tests::spotlight_open_and_close_reset_state
  • Manual smoke: open Spotlight in fleet-waves after 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 on title || sub. It now matches by fuzzy ranking on group + title + sub (with a PANE group bias from spotlight_overlay). This is the canonical behavior already shipped in fleet-state and fleet-plan-tree; the substring variant was an outlier.

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).
@NagyVikt NagyVikt merged commit 47439e6 into main May 16, 2026
2 checks passed
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