Repository navigation
Conversation
1. Root cause: resolveMigratedFollowSystem() returned true when legacy.themeType==0, treating the DTK config default value as an explicit "follow system" user choice. On first launch (no prior migration), themeType is 0, so the terminal wrongly switched to follow-system mode and inherited the light color scheme. 2. Fix: return false for themeType==0 (conservative — keep existing colorScheme unchanged). Only the illegal-value branch (>2 or <0) still returns true, matching dtkgui normalization. 3. Impact: first Alt+F2 Quake terminal no longer inherits a light theme from the system on fresh installs. Users who explicitly set follow-system in a prior version are unaffected (migration already completed). Updated unit test to match corrected semantics. fix: 修复主题迁移误判DTK默认值为跟随系统 1. 根因:resolveMigratedFollowSystem() 在 themeType==0 时返回 true, 将 DTK 配置默认值误判为用户显式选择"跟随系统"。首次启动(未迁移过) 时 themeType 为 0,终端错误切换为跟随系统模式并继承浅色配色。 2. 方案:themeType==0 时保守返回 false,保持现有 colorScheme 不变。 仅非法值分支(>2 或 <0)仍返回 true,与 dtkgui 归一逻辑一致。 3. 影响:首次 Alt+F2 打开 Quake 终端不再继承系统浅色主题。已在旧版本 显式设置跟随系统的用户不受影响(迁移已完成)。同步更新单元测试。 Log: Fixed Quake terminal showing light theme on first launch due to theme migration misreading DTK default as follow-system Influence: - Test first launch with Alt+F2 Quake terminal shows dark theme - Test theme migration with themeType=0 keeps existing colorScheme - Verify users with explicit follow-system setting still work after migration Log: 修复首次 Alt+F2 打开 Quake 终端时因主题迁移误判显示浅色主题的问题 Influence: - 测试首次 Alt+F2 打开 Quake 终端显示深色主题 - 测试 themeType=0 时主题迁移保持现有配色不变 - 验证已设置跟随系统的用户迁移后功能正常 PMS: BUG-383981
Reviewer's GuideImplementationChange the migration decision so DTK’s default theme value is not mistaken for an explicit follow-system choice, while preserving the existing handling of invalid values.
TestsUpdate the unit test to assert that the DTK default value does not enable follow-system mode.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/settings/settings.cpp" line_range="770" />
<code_context>
- return legacy.themeType == 0;
+ // themeType=0 是 DTK 配置默认值,并非用户显式选择"跟随系统"——保守返回 false,
+ // 保持当前 colorScheme 不变,避免首次启动误判为跟随系统导致主题错误
+ return false;
}
</code_context>
<issue_to_address>
**Saved theme preference is lost**
When an upgraded installation has an unmigrated legacy `themeType=0` follow-system choice, `resolveMigratedFollowSystem()` returns false, so `migrateLegacyThemeMode()` stores `follow_system=false` and marks migration complete; `applyThemeMode()` pins the saved color scheme, and system theme changes no longer update the terminal.
Treat an explicit legacy `themeType=0` follow-system choice as enabled during migration.
Also at `tests/src/settings/ut_settings_test.cpp:257`.
</issue_to_address>
### Comment 2
<location path="src/settings/settings.cpp" line_range="770" />
<code_context>
- return legacy.themeType == 0;
+ // themeType=0 是 DTK 配置默认值,并非用户显式选择"跟随系统"——保守返回 false,
+ // 保持当前 colorScheme 不变,避免首次启动误判为跟随系统导致主题错误
+ return false;
}
</code_context>
<issue_to_address>
**Concurrent migration resets theme choice**
When two terminal processes initialize the same fresh configuration concurrently with legacy `themeType=0`, and the user enables follow-system in the first process before the second writes its migration result, process B can read the migration marker as unset, then Process A can finish migration and the user can enable follow-system before B reaches `setFollowSystemTheme(false)`. B overwrites that newer choice and marks migration complete, so the user's selected theme mode is lost.
Serialize migration across processes or recheck the migration marker immediately before applying the migrated value so a late migration cannot overwrite a newer user choice.
</issue_to_address>| return legacy.themeType == 0; | ||
| // themeType=0 是 DTK 配置默认值,并非用户显式选择"跟随系统"——保守返回 false, | ||
| // 保持当前 colorScheme 不变,避免首次启动误判为跟随系统导致主题错误 | ||
| return false; |
There was a problem hiding this comment.
🟡 Medium · Saved theme preference is lost
When an upgraded installation has an unmigrated legacy themeType=0 follow-system choice, resolveMigratedFollowSystem() returns false, so migrateLegacyThemeMode() stores follow_system=false and marks migration complete; applyThemeMode() pins the saved color scheme, and system theme changes no longer update the terminal.
Treat an explicit legacy themeType=0 follow-system choice as enabled during migration.
Also at tests/src/settings/ut_settings_test.cpp:257.
Prompt for AI agents
In `src/settings/settings.cpp` at line 770:
**Saved theme preference is lost**
When an upgraded installation has an unmigrated legacy `themeType=0` follow-system choice, `resolveMigratedFollowSystem()` returns false, so `migrateLegacyThemeMode()` stores `follow_system=false` and marks migration complete; `applyThemeMode()` pins the saved color scheme, and system theme changes no longer update the terminal.
Treat an explicit legacy `themeType=0` follow-system choice as enabled during migration.
Also at `tests/src/settings/ut_settings_test.cpp:257`.| return legacy.themeType == 0; | ||
| // themeType=0 是 DTK 配置默认值,并非用户显式选择"跟随系统"——保守返回 false, | ||
| // 保持当前 colorScheme 不变,避免首次启动误判为跟随系统导致主题错误 | ||
| return false; |
There was a problem hiding this comment.
🟡 Medium · Concurrent migration resets theme choice
When two terminal processes initialize the same fresh configuration concurrently with legacy themeType=0, and the user enables follow-system in the first process before the second writes its migration result, process B can read the migration marker as unset, then Process A can finish migration and the user can enable follow-system before B reaches setFollowSystemTheme(false). B overwrites that newer choice and marks migration complete, so the user's selected theme mode is lost.
Serialize migration across processes or recheck the migration marker immediately before applying the migrated value so a late migration cannot overwrite a newer user choice.
Prompt for AI agents
In `src/settings/settings.cpp` at line 770:
**Concurrent migration resets theme choice**
When two terminal processes initialize the same fresh configuration concurrently with legacy `themeType=0`, and the user enables follow-system in the first process before the second writes its migration result, process B can read the migration marker as unset, then Process A can finish migration and the user can enable follow-system before B reaches `setFollowSystemTheme(false)`. B overwrites that newer choice and marks migration complete, so the user's selected theme mode is lost.
Serialize migration across processes or recheck the migration marker immediately before applying the migrated value so a late migration cannot overwrite a newer user choice.
Root Cause Analysis
resolveMigratedFollowSystem()returnedtruewhenlegacy.themeType == 0, treating the DTK config default value as an explicit "follow system" user choice. On first launch (no prior migration),themeTypeis 0, so the terminal wrongly switched to follow-system mode and inherited the system's light color scheme — causing the Quake terminal (Alt+F2) to appear with a light theme instead of the expected dark theme.Key evidence:
src/settings/settings.cpp:770—return legacy.themeType == 0;was the buggy line. The migration path atsrc/settings/settings.cpp:718consumed this return value to decide whether to follow the system theme.Fix Approach
Changed
return legacy.themeType == 0;toreturn false;with an explanatory comment. This meansthemeType=0(DTK default) is no longer misinterpreted as an explicit "follow system" choice. The existing colorScheme is preserved unchanged. The illegal-value branch (themeType < 0 || themeType > 2) still returnstrue, matching dtkgui's normalization behavior.Change Safety Assessment
Code Safety
976a3a09(not a historical fix being reverted); only the return value changed, function signature unchangedSettings::migrateThemeMode()atsettings.cpp:718); behavior becomes more conservative — no new error paths introducedBusiness Impact Scope
Verification Suggestion
Test first Alt+F2 Quake terminal launch on a fresh install to verify dark theme. Verify theme migration with
themeType=0keeps existing colorScheme. Confirm users with explicit follow-system setting still work after migration.根因分析
resolveMigratedFollowSystem()在legacy.themeType == 0时返回true,将 DTK 配置默认值误判为用户显式选择"跟随系统"。首次启动(未迁移过)时themeType为 0,终端错误切换为跟随系统模式并继承系统浅色配色——导致 Quake 终端(Alt+F2)显示浅色主题而非预期的深色主题。关键证据:
src/settings/settings.cpp:770—return legacy.themeType == 0;为缺陷行。迁移路径src/settings/settings.cpp:718消费该返回值决定是否跟随系统主题。修复方案
将
return legacy.themeType == 0;改为return false;并添加注释说明。themeType=0(DTK 默认值)不再被误判为显式"跟随系统"选择,保持现有 colorScheme 不变。非法值分支(themeType < 0 || themeType > 2)仍返回true,与 dtkgui 归一逻辑一致。改动安全评估
代码安全评估
976a3a09引入(非历史修复被撤销);仅修改返回值,函数签名不变Settings::migrateThemeMode(),settings.cpp:718);行为更保守,不引入新错误路径业务影响范围
验证建议
在全新安装环境测试首次 Alt+F2 Quake 终端启动验证深色主题。验证
themeType=0时主题迁移保持现有配色不变。确认已设置跟随系统的用户迁移后功能正常。Summary by Sourcery
Correct theme migration so the DTK default value preserves the existing color scheme instead of incorrectly enabling follow-system mode.
Bug Fixes:
Tests: