Skip to content

Add settings search highlighting - #8646

Merged
IllianiBird merged 11 commits into
MegaMek:mainfrom
VicenteCartas:vc/settings-search-highlight
Aug 7, 2026
Merged

Add settings search highlighting#8646
IllianiBird merged 11 commits into
MegaMek:mainfrom
VicenteCartas:vc/settings-search-highlight

Conversation

@VicenteCartas

@VicenteCartas VicenteCartas commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add rendered-text search indexing for shared settings pages while preserving explicit route aliases and excluding internal route IDs
  • highlight matching tokens with a non-mutating JLayer overlay that supports plain text, Swing HTML, read-only editor panes, table cells, and standard table headers
  • preserve section expansion state during filtering, avoid changing unrelated pages, and use simple viewport scrolling to prevent overlay artifacts
  • add focused coverage for normalization, HTML geometry, renderer text, filtered and offscreen table rows, viewport clipping, lazy indexing, and reversible expansion behavior

Acknowledgements

This work builds on @hokvel's experimental MekHQ PR MegaMek/mekhq#9566, which introduced the user-visible-text-only search direction and highlighted matches in Campaign Options. This PR generalizes those ideas into the shared settings framework and replaces HTML text mutation with a non-mutating JLayer overlay after testing showed that HTML insertion could alter layout.

Validation

  • ./gradlew :megamek:test --tests "megamek.client.ui.settings.*" :megamek:checkstyleMain :megamek:checkstyleTest
  • manual long-page scrolling with active highlights using the mouse wheel and scrollbar
  • manual highlight-legibility checks in light and dark themes in MegaMek and MekHQ

Video

Recording.2026-08-05.135348.mp4

Copilot AI lite review requested due to automatic review settings August 5, 2026 07:33
@VicenteCartas
VicenteCartas requested a review from a team as a code owner August 5, 2026 07:33
@VicenteCartas
VicenteCartas marked this pull request as draft August 5, 2026 07:34
@VicenteCartas VicenteCartas added GUI/UX User interface and user experience AI Assisted Development This project/code contains AI use under the supervision of a human developer. With Human testing. labels Aug 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds normalized settings-search indexing and a non-mutating highlight overlay for settings pages, so matches can be visually emphasized across common Swing components (including HTML text and table renderers) while preserving navigation behavior and section expansion state.

Changes:

  • Introduces SettingsSearchText utilities for extracting rendered display text (plain/HTML/table/header) and mapping normalized tokens back to source offsets.
  • Adds SettingsSearchHighlightLayerUI and wires it into SettingsContentHost to paint highlight overlays without modifying underlying component text/layout.
  • Updates settings routing/pane logic to index rendered route/page text, exclude internal route IDs, preserve expansion state during filtering, and adds extensive unit/UI tests.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
megamek/src/megamek/client/ui/settings/SettingsSearchText.java New rendered-text extraction + normalization/range mapping utilities for search/highlighting.
megamek/src/megamek/client/ui/settings/SettingsSearchHighlightLayerUI.java New LayerUI overlay that computes and paints match highlight bounds across supported Swing components.
megamek/src/megamek/client/ui/settings/SettingsRoute.java Switches route search indexing to rendered path text and rendered section text (excluding internal IDs).
megamek/src/megamek/client/ui/settings/SettingsPane.java Tracks current route + expansion state across filtering; applies highlights and restores expansion state on clear.
megamek/src/megamek/client/ui/settings/SettingsPagePanel.java Expands search indexing to include rendered titles/summaries/static content and full-page text; exposes expansion state APIs.
megamek/src/megamek/client/ui/settings/SettingsNavigationPanel.java Publishes normalized filter changes via listener callback.
megamek/src/megamek/client/ui/settings/SettingsContentHost.java Wraps content scrollpane in JLayer and enables simple scroll mode to support overlay repainting.
megamek/unittests/megamek/client/ui/settings/SettingsSearchTextTest.java New tests for rendered text extraction, normalization, tokenization, and range mapping.
megamek/unittests/megamek/client/ui/settings/SettingsSearchHighlightLayerUITest.java New headless UI tests verifying overlay painting behavior and geometry across component types.
megamek/unittests/megamek/client/ui/settings/SettingsRouteTest.java Adds coverage ensuring internal IDs aren’t searchable and HTML labels don’t leak tokens.
megamek/unittests/megamek/client/ui/settings/SettingsPaneTest.java Adds coverage for filter-driven expansion behavior, restoration, highlighting, and stale index clearing.
megamek/unittests/megamek/client/ui/settings/SettingsPagePanelTest.java Adds coverage for page/body search text, rendered HTML, static components, and table/header search text behavior.
megamek/unittests/megamek/client/ui/settings/SettingsNavigationPanelTest.java Adds coverage that filter callbacks publish normalized text.
megamek/unittests/megamek/client/ui/settings/SettingsContentHostTest.java Adds coverage for highlight non-mutation and viewport SIMPLE_SCROLL_MODE.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread megamek/src/megamek/client/ui/settings/SettingsRoute.java
@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.30375% with 110 lines in your changes missing coverage. Please review.
✅ Project coverage is 32.77%. Comparing base (60cccd2) to head (cb3a9db).
⚠️ Report is 92 commits behind head on main.

Files with missing lines Patch % Lines
...nt/ui/settings/SettingsSearchHighlightLayerUI.java 70.85% 32 Missing and 40 partials ⚠️
...megamek/client/ui/settings/SettingsSearchText.java 83.43% 8 Missing and 18 partials ⚠️
...k/src/megamek/client/ui/settings/SettingsPane.java 85.00% 1 Missing and 5 partials ⚠️
.../megamek/client/ui/settings/SettingsPagePanel.java 91.11% 0 Missing and 4 partials ⚠️
...ek/client/ui/settings/SettingsNavigationPanel.java 75.00% 0 Missing and 1 partial ⚠️
.../src/megamek/client/ui/settings/SettingsRoute.java 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8646      +/-   ##
============================================
+ Coverage     32.58%   32.77%   +0.19%     
- Complexity    23857    24221     +364     
============================================
  Files          3428     3441      +13     
  Lines        333573   334799    +1226     
  Branches      58537    58797     +260     
============================================
+ Hits         108694   109747    +1053     
- Misses       212381   212435      +54     
- Partials      12498    12617     +119     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@VicenteCartas
VicenteCartas marked this pull request as ready for review August 5, 2026 21:23

@IllianiBird IllianiBird left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing serious stands out

@IllianiBird
IllianiBird merged commit 19c580c into MegaMek:main Aug 7, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Assisted Development This project/code contains AI use under the supervision of a human developer. With Human testing. GUI/UX User interface and user experience

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants