Skip to content

refactor(ui): split settings search and theme tests into focused modules - #2033

Merged
l0gicgate merged 1 commit into
mainfrom
refactor/1686-hotspot-code-health
Nov 2, 2026
Merged

l0gicgate merged 1 commit into
mainfrom
refactor/1686-hotspot-code-health

Conversation

@l0gicgate

Copy link
Copy Markdown
Contributor

Description

CodeScene's analysis after #2022 lists two remaining refactoring targets: the only files still below the code health threshold that also change often. This PR brings both to a healthy score without changing behaviour.

src/ui/settings/search.rs (6.77) had the matcher, the widget filter and the search field in one file, with the bumpy filter_tree, find_matches and Search::install and three complex conditionals. It is now a hub for the search field and page switching, with:

  • search/targets.rs: the static target table.
  • search/matching.rs: query normalisation and scoring. word_score reads as named predicates, score_text scores a Candidate instead of four strings, and find_matches records settings and keyboard rows through Matches::record.
  • search/filter.rs: the widget-tree filter, with the heading and empty-placeholder rules as their own functions.

src/ui/theme/tests.rs (6.14) held 28 unrelated tests. They now live in tests/catalog.rs, tests/custom.rs, tests/omarchy.rs and tests/live.rs, with the shared helpers left in tests.rs. The contrast check iterates one table of role and background pairs, the watch test drives a WatchCalls fixture, and the large assertion blocks became table-driven loops or a single comparison against expected tokens. Every test and assertion is kept.

CodeScene CLI scores:

file before after
src/ui/settings/search.rs 6.77 10.0 (matching.rs 9.68, filter.rs 10.0)
src/ui/theme/tests.rs 6.14 10.0 (all four new test modules 10.0)

Visual evidence

N/A: a refactor with no user-visible change.

How to test

  1. ./scripts/test-headless.py ui::theme:: runs the 37 theme tests, including the 19 GTK child runs under their new module paths.
  2. ./scripts/test-headless.py ui::settings:: runs the 80 settings tests, which cover search scoring, filtering, the compact search button and page switching.
  3. Open Settings and type in the search field: results, page buttons, the "No settings match your search." page and Escape clearing the field behave as before.

Expected result: every test passes and settings search behaves exactly as on main.

Related issue

Refs #1686

CodeScene's two remaining prioritized targets are src/ui/settings/search.rs
(6.77) and src/ui/theme/tests.rs (6.14), the only files below the health
threshold that change often.

The settings search keeps its field and page switching in search.rs and
moves the target table, scoring and the widget filter into submodules,
with the bumpy matcher, filter and install paths broken into named steps.
The theme tests split by topic into catalog, custom, omarchy and live
modules; the contrast check and large assertion blocks are table-driven
and the watch test drives a small WatchCalls fixture. No test or assertion
is dropped.
@github-actions github-actions Bot added the refactor Code restructuring without behavior change label Nov 2, 2026
@l0gicgate
l0gicgate merged commit 0ca2db7 into main Nov 2, 2026
10 of 11 checks passed
@l0gicgate
l0gicgate deleted the refactor/1686-hotspot-code-health branch November 2, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Code restructuring without behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant