Skip to content

fix: prevent apps launched in terminal from changing its theme - #601

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
Kakueeen:fix/terminal-theme-isolation
Nov 24, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
Kakueeen:fix/terminal-theme-isolation

Conversation

@Kakueeen

@Kakueeen Kakueeen commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Root cause

DTK stores the application theme in the shared key org.deepin.dtk.preference.themeType keyed by app id. Processes started from the terminal inherit the terminal identity (DSG_APP_ID / cgroup), so their theme changes reach the terminal through themeTypeChanged and are written into the terminal config.

Fix

  • Set DGuiApplicationHelper::DontSaveApplicationTheme at startup, so the terminal no longer reads, watches or writes the shared app theme key.
  • Persist the follow-system state in local config options (basic.interface.follow_system, basic.interface.theme_migrated), migrate the old key once on upgrade, and record the choice at the theme menu commit point.
  • Extract migrateLegacyThemeMode() / applyThemeMode() in Settings to keep the init logic readable.

Impact

  • The terminal keeps its own light/dark/follow-system theme and ignores theme changes from apps launched in it.
  • Those apps no longer inherit the current terminal theme, and the terminal no longer participates in the shared application theme key.

Test plan

  1. Launch dde-file-manager or ll-cli run org.deepin.editor from the terminal and change its theme — the terminal theme stays unchanged.
  2. Switch the system theme — only the follow-system mode of the terminal changes.
  3. Restart the terminal — the light/dark/follow-system selection is kept.
  4. Upgrade from an old version — the follow-system state is migrated once from the old application theme key.
  5. Unit tests: 430/430 pass.

PMS: https://pms.uniontech.com/bug-view-365877.html

Summary by Sourcery

Isolate the terminal’s theme management from the shared application theme state while preserving existing user preferences.

Bug Fixes:

  • Prevent applications launched from the terminal from changing the terminal’s theme or inheriting its theme state.

Enhancements:

  • Persist the terminal’s light, dark, and follow-system theme selection locally and migrate legacy theme state once during upgrade.

Tests:

  • Add coverage for theme-selection persistence and legacy theme-state migration.

1. Root cause: DTK stores the application theme in the shared key
   org.deepin.dtk.preference.themeType keyed by app id; processes started
   from the terminal inherit the terminal identity (DSG_APP_ID / cgroup),
   so their theme changes reach the terminal through themeTypeChanged and
   are written into the terminal config
2. Fix: set DGuiApplicationHelper::DontSaveApplicationTheme at startup so
   the terminal no longer reads, watches or writes the shared app theme
   key; persist the follow-system state in a local config option, migrate
   the old key once on upgrade, and record the choice at the theme menu
   commit point
3. Impact: the terminal keeps its own light/dark/follow-system theme and
   ignores theme changes from apps launched in it; those apps no longer
   inherit the current terminal theme, and the terminal no longer takes
   part in the shared application theme key

Log: fix terminal theme being changed by apps launched from it

Influence:
1. Launch dde-file-manager or ll-cli run org.deepin.editor from the
   terminal and change its theme, the terminal theme stays unchanged
2. Switch the system theme, only the follow-system mode of the terminal
   changes
3. Restart the terminal, the light/dark/follow-system selection is kept
4. Upgrade from an old version, the follow-system state is migrated once
   from the old application theme key

fix: 修复终端主题被其启动的应用带跑的问题

1. 根因:DTK 的应用主题按应用身份存放在共享键
   org.deepin.dtk.preference.themeType;终端里启动的进程继承终端身份
   (DSG_APP_ID / cgroup),其主题修改经 themeTypeChanged 传到终端并
   写入终端配置
2. 方案:启动时设置 DGuiApplicationHelper::DontSaveApplicationTheme,
   终端不再读取、监听和写入共享应用主题键;跟随系统状态改为本地配置
   持久化,升级时从旧键迁移一次,并在主题菜单提交点记录选择
3. 影响:终端保持自己的浅色/深色/跟随系统主题,不再被其启动的应用
   影响;这些应用不再继承终端当前主题,终端也不再参与共享应用主题键

Log: 修复终端主题被其启动的应用带跑的问题

Influence:
1. 从终端启动 dde-file-manager 或 ll-cli run org.deepin.editor 并修改
   其主题,终端主题不变
2. 切换系统主题,仅跟随系统模式下终端跟随变化
3. 重启终端,浅色/深色/跟随系统选择保持
4. 老版本升级,跟随系统状态从旧应用主题键迁移一次

PMS: BUG-365877
@sourcery-ai

sourcery-ai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Reviewer's Guide

Schema and migrations

Add local configuration entries for persisting the follow-system selection and recording whether legacy theme state has been migrated.

  • src/assets/other/default-config.json L51-62

API

Expose local theme-mode persistence, migration state, and migration-resolution helpers used by settings initialization and the theme menu.

  • src/settings/settings.h L175-202, L375-382

Uses of the API

Persist the selected follow-system state when a theme-menu choice is committed, including after hover preview has already changed the palette type.

  • src/main/mainwindow.cpp L2956-2959

Implementation

Stop DTK from sharing the terminal's application theme and replace shared-slot theme handling with local state, one-time legacy migration, and explicit palette application.

  • src/main/main.cpp L16, L32, L69-73
  • src/settings/settings.cpp L169-174, L189-196, L678-770 (+3 small edits)

Tests

Cover theme-menu persistence after hover preview, legacy migration resolution, and local follow-system setting persistence.

  • tests/src/main/ut_mainwindow_test.cpp L709-744
  • tests/src/settings/ut_settings_test.cpp L244-281

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 8 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/main/mainwindow.cpp" line_range="2959" />
<code_context>
+    // 只有点击提交才落盘“是否跟随系统”(hover 预览走 themeActionHoveredSlot)。
+    // 不能依赖 paletteTypeChanged 信号:悬停已把 paletteType 改成本次要选的类型时,
+    // 点击里的 setPaletteType 是空操作,不会发出信号,状态就会落回旧值。
+    Settings::instance()->setFollowSystemTheme(action == autoThemeAction);
 }

</code_context>
<issue_to_address>
**Canceled dialog disables system following**

When the user is following the system and opens then cancels the custom-theme dialog, `themeActionTriggeredSlot()` calls `switchThemeAction()` to open the dialog, then stores `false` with `setFollowSystemTheme()` before a theme is applied. Canceling leaves the current palette unchanged, but `applyThemeMode()` restores a fixed theme on restart.

Only store `false` after a custom theme has actually been applied, and leave the follow-system setting unchanged when the dialog is canceled.
</issue_to_address>

### Comment 2
<location path="src/settings/settings.cpp" line_range="731" />
<code_context>
+{
+    auto helper = DGuiApplicationHelper::instance();
+    if (followSystemTheme() && extendColorScheme().isEmpty()) {
+        // 跟随系统模式:paletteType 保持 UnknownType,由系统主题驱动浅/深;
+        // colorScheme 可能因上次关闭后系统主题变化而过期,需同步为当前系统主题
+        if (helper->paletteType() != DGuiApplicationHelper::UnknownType) {
</code_context>
<issue_to_address>
**Explicit console color is replaced**

When a caller requests a fixed console color while follow-system mode is enabled, `setConsoleColorScheme()` changes the stored color and clears the extended scheme without clearing `follow_system`, so `applyThemeMode()` treats the request as follow-system mode and replaces the explicit color with the current system theme on restart.

Clear follow-system mode when `setConsoleColorScheme()` receives an explicit fixed color.
</issue_to_address>

### Comment 3
<location path="src/main/mainwindow.cpp" line_range="2959" />
<code_context>
+    // 只有点击提交才落盘“是否跟随系统”(hover 预览走 themeActionHoveredSlot)。
+    // 不能依赖 paletteTypeChanged 信号:悬停已把 paletteType 改成本次要选的类型时,
+    // 点击里的 setPaletteType 是空操作,不会发出信号,状态就会落回旧值。
+    Settings::instance()->setFollowSystemTheme(action == autoThemeAction);
 }

</code_context>
<issue_to_address>
**Dynamic theme still follows system changes**

When a community dynamic theme is committed while follow-system mode is enabled, `switchThemeAction()` updates the extended scheme but leaves the palette type `UnknownType`; storing `false` with `setFollowSystemTheme()` does not change that palette type, so system theme changes still alter the terminal's appearance until restart.

Ensure committing a dynamic theme sets a palette type that no longer follows system theme changes.
</issue_to_address>

### Comment 4
<location path="src/settings/settings.cpp" line_range="190" />
<code_context>
         setColorScheme("Dark");
         setExtendColorScheme("");
+        setFollowSystemTheme(false);
+        setLegacyThemeModeMigrated(true);
         qCDebug(tsettings) << "Color scheme initialized";
-    } else if (DGuiApplicationHelper::instance()->paletteType() == DGuiApplicationHelper::UnknownType
</code_context>
<issue_to_address>
**Legacy follow mode is lost**

When an upgrade has an invalid or missing saved color scheme, or is built without `DTKCORE_CLASS_DConfigFile`, the migration is marked complete without preserving the old follow-system choice: the invalid-color-scheme branch forces dark and sets the migrated flag, while builds without DConfig compile out the legacy read and still mark migration complete. Upgraded users in either case lose their previous follow-system selection.

Only mark migration complete after the legacy state has been read or an explicit policy has chosen to discard it, and preserve the old follow state for upgrades that take the default-theme path.

Also at `src/settings/settings.cpp:708`.
</issue_to_address>

### Comment 5
<location path="src/settings/settings.cpp" line_range="708-724" />
<code_context>
 #include <DGuiApplicationHelper>
 #include <DKeySequenceEdit>
 #include <DSysInfo>
+#ifdef DTKCORE_CLASS_DConfigFile
+#include <DConfig>
+#endif
</code_context>
<issue_to_address>
**Legacy follow mode is lost**

When the legacy DConfig group or `themeType` value is unavailable during the first upgraded launch, `migrateLegacyThemeMode()` converts an unreadable legacy value to `followSystem=false` and still sets `theme_migrated=true`, so the migration is never retried and an upgraded terminal that previously followed the system starts in a fixed theme.

Only mark migration complete after confirming the legacy setting was read, or preserve a retry path when the legacy value is unavailable.
</issue_to_address>

### Comment 6
<location path="src/settings/settings.cpp" line_range="708" />
<code_context>
 #include <DGuiApplicationHelper>
 #include <DKeySequenceEdit>
 #include <DSysInfo>
+#ifdef DTKCORE_CLASS_DConfigFile
+#include <DConfig>
+#endif
</code_context>
<issue_to_address>
**Legacy follow mode is lost without DConfig**

When the terminal is upgraded on a build where `DTKCORE_CLASS_DConfigFile` is undefined and the prior theme mode was follow-system, `DTKCORE_CLASS_DConfigFile` being undefined skips the only read of the legacy theme key, leaving `legacy.valid` false; `resolveMigratedFollowSystem` then stores `false` and marks migration complete. Existing users on that build retain an explicit theme instead of their previous follow-system choice.

Provide a legacy-theme read for builds without DConfig, or avoid marking migration complete when the old value cannot be read.
</issue_to_address>

### Comment 7
<location path="src/main/main.cpp" line_range="73" />
<code_context>
+    // 避免从终端启动的应用修改主题时把终端一起带跑,也避免终端主题泄漏给子进程。
+    // 该属性只影响本进程对应用主题槽的读写,跟随系统主题仍由系统主题驱动。
+    // 必须在任何 DGuiApplicationHelper 主题接口调用之前设置。
+    DGuiApplicationHelper::setAttribute(DGuiApplicationHelper::DontSaveApplicationTheme, true);
     qCDebug(mainprocess) << "Application starting with arguments:" << QCoreApplication::arguments();
     if (checkImmutableMode())
</code_context>
<issue_to_address>
**Launched apps retain stale theme**

When an upgrade leaves a legacy `themeType` value for the terminal’s shared app identity, a legacy shared theme value remains after upgrade because the terminal only reads it during migration and never clears it; `DontSaveApplicationTheme` applies to the terminal process, not children sharing its app identity, so launched apps can still load the old terminal theme.

After migrating, remove or reset the legacy shared value if doing so is safe for other processes using that identity, or otherwise ensure launched apps cannot consume it.

Also at `src/settings/settings.cpp:712-715`.
</issue_to_address>

### Comment 8
<location path="tests/src/settings/ut_settings_test.cpp" line_range="270-273" />
<code_context>
+    const bool oldFollow = settings->followSystemTheme();
+    const bool oldMigrated = settings->legacyThemeModeMigrated();
+
+    settings->setFollowSystemTheme(true);
+    EXPECT_TRUE(settings->followSystemTheme());
+    settings->setFollowSystemTheme(false);
+    EXPECT_FALSE(settings->followSystemTheme());
+    settings->setLegacyThemeModeMigrated(true);
+    EXPECT_TRUE(settings->legacyThemeModeMigrated());
</code_context>
<issue_to_address>
**Persistence check misses lost settings**

When `setFollowSystemTheme` updates only the in-memory option and fails to persist it, `followSystemThemePersistence` immediately reads the same in-memory option after each setter, so a `setFollowSystemTheme` implementation that never commits to persistent storage still passes these assertions; callers then lose the selection after restart.

Reload settings or recreate the settings object before asserting the saved follow-system value.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src/main/mainwindow.cpp
// 只有点击提交才落盘“是否跟随系统”(hover 预览走 themeActionHoveredSlot)。
// 不能依赖 paletteTypeChanged 信号:悬停已把 paletteType 改成本次要选的类型时,
// 点击里的 setPaletteType 是空操作,不会发出信号,状态就会落回旧值。
Settings::instance()->setFollowSystemTheme(action == autoThemeAction);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Canceled dialog disables system following

When the user is following the system and opens then cancels the custom-theme dialog, themeActionTriggeredSlot() calls switchThemeAction() to open the dialog, then stores false with setFollowSystemTheme() before a theme is applied. Canceling leaves the current palette unchanged, but applyThemeMode() restores a fixed theme on restart.

Only store false after a custom theme has actually been applied, and leave the follow-system setting unchanged when the dialog is canceled.

Prompt for AI agents
In `src/main/mainwindow.cpp` at line 2959:

**Canceled dialog disables system following**

When the user is following the system and opens then cancels the custom-theme dialog, `themeActionTriggeredSlot()` calls `switchThemeAction()` to open the dialog, then stores `false` with `setFollowSystemTheme()` before a theme is applied. Canceling leaves the current palette unchanged, but `applyThemeMode()` restores a fixed theme on restart.

Only store `false` after a custom theme has actually been applied, and leave the follow-system setting unchanged when the dialog is canceled.

Comment thread src/settings/settings.cpp
{
auto helper = DGuiApplicationHelper::instance();
if (followSystemTheme() && extendColorScheme().isEmpty()) {
// 跟随系统模式:paletteType 保持 UnknownType,由系统主题驱动浅/深;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Explicit console color is replaced

When a caller requests a fixed console color while follow-system mode is enabled, setConsoleColorScheme() changes the stored color and clears the extended scheme without clearing follow_system, so applyThemeMode() treats the request as follow-system mode and replaces the explicit color with the current system theme on restart.

Clear follow-system mode when setConsoleColorScheme() receives an explicit fixed color.

Prompt for AI agents
In `src/settings/settings.cpp` at line 731:

**Explicit console color is replaced**

When a caller requests a fixed console color while follow-system mode is enabled, `setConsoleColorScheme()` changes the stored color and clears the extended scheme without clearing `follow_system`, so `applyThemeMode()` treats the request as follow-system mode and replaces the explicit color with the current system theme on restart.

Clear follow-system mode when `setConsoleColorScheme()` receives an explicit fixed color.

Comment thread src/main/mainwindow.cpp
// 只有点击提交才落盘“是否跟随系统”(hover 预览走 themeActionHoveredSlot)。
// 不能依赖 paletteTypeChanged 信号:悬停已把 paletteType 改成本次要选的类型时,
// 点击里的 setPaletteType 是空操作,不会发出信号,状态就会落回旧值。
Settings::instance()->setFollowSystemTheme(action == autoThemeAction);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High · Dynamic theme still follows system changes

When a community dynamic theme is committed while follow-system mode is enabled, switchThemeAction() updates the extended scheme but leaves the palette type UnknownType; storing false with setFollowSystemTheme() does not change that palette type, so system theme changes still alter the terminal's appearance until restart.

Ensure committing a dynamic theme sets a palette type that no longer follows system theme changes.

Prompt for AI agents
In `src/main/mainwindow.cpp` at line 2959:

**Dynamic theme still follows system changes**

When a community dynamic theme is committed while follow-system mode is enabled, `switchThemeAction()` updates the extended scheme but leaves the palette type `UnknownType`; storing `false` with `setFollowSystemTheme()` does not change that palette type, so system theme changes still alter the terminal's appearance until restart.

Ensure committing a dynamic theme sets a palette type that no longer follows system theme changes.

Comment thread src/settings/settings.cpp
setColorScheme("Dark");
setExtendColorScheme("");
setFollowSystemTheme(false);
setLegacyThemeModeMigrated(true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Legacy follow mode is lost

When an upgrade has an invalid or missing saved color scheme, or is built without DTKCORE_CLASS_DConfigFile, the migration is marked complete without preserving the old follow-system choice: the invalid-color-scheme branch forces dark and sets the migrated flag, while builds without DConfig compile out the legacy read and still mark migration complete. Upgraded users in either case lose their previous follow-system selection.

Only mark migration complete after the legacy state has been read or an explicit policy has chosen to discard it, and preserve the old follow state for upgrades that take the default-theme path.

Also at src/settings/settings.cpp:708.

Prompt for AI agents
In `src/settings/settings.cpp` at line 190:

**Legacy follow mode is lost**

When an upgrade has an invalid or missing saved color scheme, or is built without `DTKCORE_CLASS_DConfigFile`, the migration is marked complete without preserving the old follow-system choice: the invalid-color-scheme branch forces dark and sets the migrated flag, while builds without DConfig compile out the legacy read and still mark migration complete. Upgraded users in either case lose their previous follow-system selection.

Only mark migration complete after the legacy state has been read or an explicit policy has chosen to discard it, and preserve the old follow state for upgrades that take the default-theme path.

Also at `src/settings/settings.cpp:708`.

Comment thread src/settings/settings.cpp
Comment on lines +708 to +724
#ifdef DTKCORE_CLASS_DConfigFile
DConfig legacyConfig(QStringLiteral("org.deepin.dtk.preference"));
if (legacyConfig.isValid()) {
const QVariant legacyValue = legacyConfig.value(QStringLiteral("themeType"));
if (legacyValue.isValid()) {
legacy.valid = true;
legacy.themeType = legacyValue.toInt();
}
}
#endif
const bool followSystem = resolveMigratedFollowSystem(legacy, extendColorScheme());
qCInfo(tsettings) << "Migrating theme mode from legacy app theme slot, valid:" << legacy.valid
<< ", legacyThemeType:"
<< (legacy.valid ? QString::number(legacy.themeType) : QStringLiteral("unavailable"))
<< ", followSystem:" << followSystem;
setFollowSystemTheme(followSystem);
setLegacyThemeModeMigrated(true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Legacy follow mode is lost

When the legacy DConfig group or themeType value is unavailable during the first upgraded launch, migrateLegacyThemeMode() converts an unreadable legacy value to followSystem=false and still sets theme_migrated=true, so the migration is never retried and an upgraded terminal that previously followed the system starts in a fixed theme.

Only mark migration complete after confirming the legacy setting was read, or preserve a retry path when the legacy value is unavailable.

Prompt for AI agents
In `src/settings/settings.cpp` at lines 708-724:

**Legacy follow mode is lost**

When the legacy DConfig group or `themeType` value is unavailable during the first upgraded launch, `migrateLegacyThemeMode()` converts an unreadable legacy value to `followSystem=false` and still sets `theme_migrated=true`, so the migration is never retried and an upgraded terminal that previously followed the system starts in a fixed theme.

Only mark migration complete after confirming the legacy setting was read, or preserve a retry path when the legacy value is unavailable.

Comment thread src/settings/settings.cpp
{
// 老版本升级:跟随系统的状态只存在于旧的应用主题槽里,读取一次后不再使用
LegacyThemeState legacy{false, -1};
#ifdef DTKCORE_CLASS_DConfigFile

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Legacy follow mode is lost without DConfig

When the terminal is upgraded on a build where DTKCORE_CLASS_DConfigFile is undefined and the prior theme mode was follow-system, DTKCORE_CLASS_DConfigFile being undefined skips the only read of the legacy theme key, leaving legacy.valid false; resolveMigratedFollowSystem then stores false and marks migration complete. Existing users on that build retain an explicit theme instead of their previous follow-system choice.

Provide a legacy-theme read for builds without DConfig, or avoid marking migration complete when the old value cannot be read.

Prompt for AI agents
In `src/settings/settings.cpp` at line 708:

**Legacy follow mode is lost without DConfig**

When the terminal is upgraded on a build where `DTKCORE_CLASS_DConfigFile` is undefined and the prior theme mode was follow-system, `DTKCORE_CLASS_DConfigFile` being undefined skips the only read of the legacy theme key, leaving `legacy.valid` false; `resolveMigratedFollowSystem` then stores `false` and marks migration complete. Existing users on that build retain an explicit theme instead of their previous follow-system choice.

Provide a legacy-theme read for builds without DConfig, or avoid marking migration complete when the old value cannot be read.

Comment thread src/main/main.cpp
// 避免从终端启动的应用修改主题时把终端一起带跑,也避免终端主题泄漏给子进程。
// 该属性只影响本进程对应用主题槽的读写,跟随系统主题仍由系统主题驱动。
// 必须在任何 DGuiApplicationHelper 主题接口调用之前设置。
DGuiApplicationHelper::setAttribute(DGuiApplicationHelper::DontSaveApplicationTheme, true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Launched apps retain stale theme

When an upgrade leaves a legacy themeType value for the terminal’s shared app identity, a legacy shared theme value remains after upgrade because the terminal only reads it during migration and never clears it; DontSaveApplicationTheme applies to the terminal process, not children sharing its app identity, so launched apps can still load the old terminal theme.

After migrating, remove or reset the legacy shared value if doing so is safe for other processes using that identity, or otherwise ensure launched apps cannot consume it.

Also at src/settings/settings.cpp:712-715.

Prompt for AI agents
In `src/main/main.cpp` at line 73:

**Launched apps retain stale theme**

When an upgrade leaves a legacy `themeType` value for the terminal’s shared app identity, a legacy shared theme value remains after upgrade because the terminal only reads it during migration and never clears it; `DontSaveApplicationTheme` applies to the terminal process, not children sharing its app identity, so launched apps can still load the old terminal theme.

After migrating, remove or reset the legacy shared value if doing so is safe for other processes using that identity, or otherwise ensure launched apps cannot consume it.

Also at `src/settings/settings.cpp:712-715`.

Comment on lines +270 to +273
settings->setFollowSystemTheme(true);
EXPECT_TRUE(settings->followSystemTheme());
settings->setFollowSystemTheme(false);
EXPECT_FALSE(settings->followSystemTheme());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Persistence check misses lost settings

When setFollowSystemTheme updates only the in-memory option and fails to persist it, followSystemThemePersistence immediately reads the same in-memory option after each setter, so a setFollowSystemTheme implementation that never commits to persistent storage still passes these assertions; callers then lose the selection after restart.

Reload settings or recreate the settings object before asserting the saved follow-system value.

Prompt for AI agents
In `tests/src/settings/ut_settings_test.cpp` at lines 270-273:

**Persistence check misses lost settings**

When `setFollowSystemTheme` updates only the in-memory option and fails to persist it, `followSystemThemePersistence` immediately reads the same in-memory option after each setter, so a `setFollowSystemTheme` implementation that never commits to persistent storage still passes these assertions; callers then lose the selection after restart.

Reload settings or recreate the settings object before asserting the saved follow-system value.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Kakueeen, lzwind

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Kakueeen

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

This pr force merged! (status: unstable)

@deepin-bot
deepin-bot Bot merged commit 976a3a0 into linuxdeepin:master Nov 24, 2026
13 of 14 checks passed
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.

3 participants