Skip to content

fix(settings): keep the icon when a Settings icon field is cleared - #1100

Merged
Oud-Idk merged 1 commit into
LargeModGames:mainfrom
Seyamalam:fix/1062-icon-trim
Nov 20, 2026
Merged

Oud-Idk merged 1 commit into
LargeModGames:mainfrom
Seyamalam:fix/1062-icon-trim

Conversation

@Seyamalam

@Seyamalam Seyamalam commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Settings stored icon values untrimmed while the config.yml loader trims them and skips empty values, so the two disagreed. Clearing Active Source Icon or List Highlight Icon saved "": the device-picker marker and the list cursor disappeared for the rest of the session, and the default quietly came back on the next launch. A padded one-cell icon like " » " was rejected by the width check even though the same value in config.yml loads fine.

apply_settings_changes now trims each icon value once: the six one-cell icons are width-checked on the trimmed value and stored trimmed, and Active Source Icon / List Highlight Icon keep their current value when the trimmed value is empty, same as the loader. The free-form label icons (Liked, Shuffle, Paused, Repeat) are untouched, also matching the loader.

Fixes #1062

Testing

  • cargo fmt --all -- --check — clean
  • cargo clippy --no-default-features --features telemetry,tui -- -D warnings — clean (only the pre-existing vergen manifest warning)
  • cargo test --no-default-features --features telemetry,tui — 1960 passed; 0 failed
  • cargo test --no-default-features --features telemetry,tui settings_apply — 8 passed, both new tests listed
  • Before the fix, the two new tests failed: clearing_the_active_source_or_list_highlight_icon_keeps_the_current_icon (saved "" instead of keeping ●) and a_padded_one_cell_icon_is_saved_trimmed (rejected " » ")

Additional notes

The Settings row still shows the cleared value after a save, the same as a rejected gauge icon today; reverting the row is out of scope per the issue.


💬 Questions or want to chat with other contributors? Join the spotatui Discord.

Summary by CodeRabbit

  • Bug Fixes
    • Icon settings now trim surrounding whitespace before saving.
    • Clearing the Active Source or List Highlight icon keeps its current value.
    • Icons that don’t fit the required single-cell width remain unchanged and show an error.

The Settings save path stored icon values untrimmed while the config
loader trims them and skips empty values, so the two disagreed: a
cleared Active Source or List Highlight Icon saved an empty string,
and a padded one-cell icon like " >> " was rejected though the same
value in config.yml loads.

Trim once in apply_settings_changes: width-check and store the trimmed
value for the six one-cell icons, and keep the current icon for the
two free-form icons when the trimmed value is empty.

Fixes LargeModGames#1062
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Settings now trims icon values before validation and storage. Empty or whitespace-only Active Source Icon and List Highlight Icon inputs preserve their current values. Tests cover the updated behavior.

Changes: Settings icon handling

Layer / File(s) Summary
Trim and preserve icon values
src/core/app/settings_apply.rs, CHANGELOG.md
The six width-validated icon settings are trimmed before width checks and storage. Empty or whitespace-only Active Source Icon and List Highlight Icon inputs leave the current values unchanged. Tests cover these cases and padded icon values.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: Minimal · up to 6cc2a

Settings now accepts padded one-cell icons, and clearing the Active Source or List Highlight icon keeps the current icon. The change is narrow, covered by new tests, and has no identified merge-blocking risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title uses the conventional-commit prefix "fix" with the scope "settings", which matches the required format. It describes the main change: clearing a Settings icon field keeps the current icon. T…
Linked Issues check Passed Single directly linked issue #1062. No stack evidence was supplied, so the assessment covers the current PR only.

Objective 1 [#1062]: Clearing Active Source Icon or List Highlight Icon keeps the cur…
Out of Scope Changes check Passed The whole-PR diff (merge base b8fa4fe to head 6cc2ab3) touches src/core/app/settings_apply.rs only, within the scope of #1062. Every hunk in that file is in the one-cell arm, the `active_source_icon…
Full details: Title check

Explanation

The title uses the conventional-commit prefix "fix" with the scope "settings", which matches the required format. It describes the main change: clearing a Settings icon field keeps the current icon. The title is concise, but the subject is written in the third person ("keep", not the imperative "keep" form used as an instruction), so it fits the imperative requirement. The title also omits the trimming change for one-cell icons, which is a secondary part of the PR, so it is partially related in scope but still captures the main point.

Full details: Linked Issues check

Explanation

Single directly linked issue #1062. No stack evidence was supplied, so the assessment covers the current PR only.

Objective 1 [#1062]: Clearing Active Source Icon or List Highlight Icon keeps the current icon. Addressed. In apply_settings_changes (src/core/app/settings_apply.rs), the behavior.active_source_icon and behavior.list_highlight_icon arms now compute let icon = v.trim(); and assign only when !icon.is_empty(). Empty and spaces-only values leave the defaults ● and ▶ in place. The padded value " ◆ " is stored as "◆". Test: clearing_the_active_source_or_list_highlight_icon_keeps_the_current_icon.

Objective 2 [#1062]: The six one-cell icons (playing, gauge filled/unfilled, episode played, sort ascending/descending) are trimmed before the width check and storage. Addressed. The shared arm computes icon = v.trim(), checks UnicodeWidthStr::width(icon) == 1, and stores icon.to_string() in all six inner arms. A padded " » " is saved as "»". An empty value has width 0 and goes to the existing rejection path with the icon_width message. Test: a_padded_one_cell_icon_is_saved_trimmed, which also asserts status_message() is None.

Objective 3 [#1062]: Free-form label icons (liked, shuffle, paused, repeat) are not trimmed. Addressed. The diff does not change those arms.

Objective 4 [#1062]: Config loader unchanged, no new status message for empty values, tools/gates.count unchanged. Addressed. The diff touches only src/core/app/settings_apply.rs. The diff for tools/gates.count is empty.

Note: the PR objectives text lists a padded free-form icon trim among the acceptance criteria. The issue body states that free-form label icons are excluded from trimming. The current PR follows the issue body. This PR does not add a test for a padded free-form icon, and the issue body does not require one.

Uncertainty: I did not run the test suite. Test results rely on the diff and the author's reported results.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff (merge base b8fa4fe to head 6cc2ab3) touches src/core/app/settings_apply.rs only, within the scope of #1062. Every hunk in that file is in the one-cell arm, the active_source_icon and list_highlight_icon arms, or the new tests in mod tests. No unrelated refactoring or behavior change appears. The tools/gates.count diff is empty, as the issue requires. The raw summary reports a single added line under CHANGELOG.md ## [Unreleased] ### Fixed, which the issue requests. I did not inspect the changelog file directly. That entry is documentation for the in-scope fix and is not a code change.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
Simplify code

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between b8fa4fe and 6cc2ab3.

Files selected for processing: 2

  • CHANGELOG.md
  • src/core/app/settings_apply.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@codecov

codecov Bot commented Nov 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kapok-4o kapok-4o 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.

Looks good. The two new tests fail against main's implementation and pass here. The save path now matches the loader, preserves custom icons when cleared, and leaves padded label icons alone. Slim tests, default settings tests, and the slim/default/GUI clippy checks pass. I have no changes to request.

@Oud-Idk Oud-Idk 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.

Good catch on trimming early.

" " has a display width of 1 and isn't .is_empty(), so whitespace would slip past naive checks on both paths. Matching config.yml's trimming behavior and keeping the existing icon when blank makes total sense. LGTM

@Oud-Idk
Oud-Idk merged commit 5419d0b into LargeModGames:main Nov 20, 2026
35 checks passed
@Seyamalam
Seyamalam deleted the fix/1062-icon-trim branch November 20, 2026 17:27
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.

Settings: a cleared Active Source Icon or List Highlight Icon is saved empty, then dropped on the next launch

3 participants