Skip to content

Fix theme extra colors lost after user customization#33021

Open
luapmartin wants to merge 2 commits intomusescore:masterfrom
luapmartin:luapmartin/fix-theme-extras
Open

Fix theme extra colors lost after user customization#33021
luapmartin wants to merge 2 commits intomusescore:masterfrom
luapmartin:luapmartin/fix-theme-extras

Conversation

@luapmartin
Copy link
Copy Markdown
Contributor

@luapmartin luapmartin commented Apr 15, 2026

Resolves: Audacity issue where theme extra colors (clip colors, waveform ruler colors, etc.) are lost when a user customizes any theme property (e.g. accent color). The saved theme only contains standard values, but on reload it fully replaces the theme loaded from .cfg files, wiping the extra color map. All ui.theme.extra["..."] lookups return undefined rendering affected colors as black.

  • I signed the CLA
  • The title of the PR describes the problem it addresses
  • Each commit's message describes its purpose and effects, and references the issue it resolves
  • If changes are extensive, there is a sequence of easily reviewable commits
  • The code in the PR follows the coding rules
  • There are no unnecessary changes
  • The code compiles and runs on my machine, preferably after each commit individually
  • I created a unit test or vtest to verify the changes I made (if applicable)
image

instead of

image

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 15, 2026

📝 Walkthrough

Walkthrough

The pull request modifies theme handling logic in two files. The ThemeConverter::fromMap function was updated to filter out unknown style keys during map-to-theme conversion, only populating theme values for recognized keys. Correspondingly, the UiConfiguration::updateThemes() function was changed to preserve existing theme fields when applying updates, selectively copying only recognized value entries instead of replacing the entire theme object. Both modifications exclude UNKNOWN key entries from the operation.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main issue being fixed: theme extra colors being lost after user customization.
Description check ✅ Passed The description is comprehensive and addresses all required template sections: issue resolution, motivation, and completed checklist items with detailed context.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/framework/ui/internal/uiconfiguration.cpp`:
- Around line 219-223: Add a regression unit test covering the persisted theme
merge path: write a test that uses ThemeConverter::fromMap() and
UiConfiguration::updateThemes() to round-trip a theme where you modify a
standard value (e.g., change a named color in ThemeInfo::values) while the
original cfg-backed ThemeInfo contains an extra color in ThemeInfo::extra,
persist and reload the themes (simulate saving/loading settings via the same
map/json path used by ThemeConverter::fromMap()), call
UiConfiguration::updateThemes() to merge, and assert that the reloaded/merged
theme preserves the extra color and the customized standard value; target the
test to exercise the code paths that build theme.values and merge into existing
cfg-backed ThemeInfo so regressions in merging extra are caught.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 80c94351-ae85-41c8-8d8c-7c09a350e5ee

📥 Commits

Reviewing files that changed from the base of the PR and between cb8093b and 02f0949.

📒 Files selected for processing (2)
  • src/framework/ui/internal/themeconverter.cpp
  • src/framework/ui/internal/uiconfiguration.cpp

Comment on lines +219 to +223
for (auto key : it->values.keys()) {
if (key != UNKNOWN) {
theme.values[key] = it->values[key];
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Add a regression test for the persisted theme merge path.

This fix now depends on ThemeConverter::fromMap() restoring only ThemeInfo::values and UiConfiguration::updateThemes() merging those values back into a cfg-backed theme that still owns ThemeInfo::extra. Please lock that in with a round-trip test that customizes a standard value, reloads themes from settings, and verifies an extra color is still present.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/framework/ui/internal/uiconfiguration.cpp` around lines 219 - 223, Add a
regression unit test covering the persisted theme merge path: write a test that
uses ThemeConverter::fromMap() and UiConfiguration::updateThemes() to round-trip
a theme where you modify a standard value (e.g., change a named color in
ThemeInfo::values) while the original cfg-backed ThemeInfo contains an extra
color in ThemeInfo::extra, persist and reload the themes (simulate
saving/loading settings via the same map/json path used by
ThemeConverter::fromMap()), call UiConfiguration::updateThemes() to merge, and
assert that the reloaded/merged theme preserves the extra color and the
customized standard value; target the test to exercise the code paths that build
theme.values and merge into existing cfg-backed ThemeInfo so regressions in
merging extra are caught.

theme = *it;
for (auto key : it->values.keys()) {
if (key != UNKNOWN) {
theme.values[key] = it->values[key];
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.

do we need to copy extra?

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.

2 participants