Skip to content

fix: Terminal theme color not updating with application theme changes - #542

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
JWWTSL:master
Jun 15, 2026
Merged

fix: Terminal theme color not updating with application theme changes#542
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
JWWTSL:master

Conversation

@JWWTSL

@JWWTSL JWWTSL commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

log: TermWidget::onThemeTypeChanged responds to the DTK DGuiApplicationHelper::themeTypeChanged signal. However, it only checks whether extendColorScheme is empty. Since two out of the three terminal theme states have an empty extendColorScheme, the theme fails to update correctly in those cases.

pms: bug-365877

Summary by Sourcery

Ensure terminal color scheme updates correctly when following the system theme and remains stable when a fixed theme is selected.

Bug Fixes:

  • Fix terminal theme not updating when configured to follow the system light/dark theme due to ambiguous extendColorScheme state.

Enhancements:

  • Preserve user-selected fixed light or dark terminal themes by ignoring system theme change signals in that mode.

Chores:

  • Update source file copyright years to include 2026.

log: TermWidget::onThemeTypeChanged responds to the DTK DGuiApplicationHelper::themeTypeChanged signal. However, it only checks whether extendColorScheme is empty. Since two out of the three terminal theme states have an empty extendColorScheme, the theme fails to update correctly in those cases.

pms: bug-365877
@sourcery-ai

sourcery-ai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates TermWidget theme-change handling so that terminal colors only follow system light/dark changes when the terminal is configured to follow the system theme, avoiding unintended theme switches when a fixed light/dark theme is selected.

Sequence diagram for updated theme change handling in TermWidget

sequenceDiagram
    participant DGuiApplicationHelper
    participant TermWidget
    participant Settings

    DGuiApplicationHelper->>TermWidget: onThemeTypeChanged(builtInTheme)
    TermWidget->>Settings: extendColorScheme()
    Settings-->>TermWidget: expandThemeStr

    alt [expandThemeStr is not empty]
        Note right of TermWidget: Use extended theme (unchanged)
    else [expandThemeStr is empty]
        TermWidget->>DGuiApplicationHelper: paletteType()
        DGuiApplicationHelper-->>TermWidget: paletteType
        alt [paletteType is not UnknownType]
            Note right of TermWidget: Fixed light/dark theme, ignore signal
            TermWidget-->>DGuiApplicationHelper: return
        else [paletteType is UnknownType]
            Note right of TermWidget: Follow system light/dark
            TermWidget->>TermWidget: setColorScheme(theme)
            TermWidget->>Settings: setColorScheme(theme)
        end
    end
Loading

File-Level Changes

Change Details Files
Refine terminal theme update logic to distinguish between fixed themes and follow-system mode when handling system theme changes.
  • Read extendColorScheme from Settings as before to detect whether an extended theme is configured
  • Document in comments that both fixed light/dark and follow-system states have empty extendColorScheme and must be distinguished via paletteType
  • Add a guard that returns early from onThemeTypeChanged when paletteType is not UnknownType, meaning a fixed light or dark theme is selected
  • Keep existing behavior of mapping DGuiApplicationHelper::LightType to "Light" and other values to "Dark", and persisting this in Settings when in follow-system mode
src/views/termwidget.cpp
Update copyright years in TermWidget source file.
  • Extend copyright range from 2019 ~ 2020 to 2019 ~ 2026 in the file header
src/views/termwidget.cpp

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 left some high level feedback:

  • The logic branching on paletteType() != DGuiApplicationHelper::UnknownType is a bit opaque; consider extracting this into a named helper (e.g. isFollowSystemThemeEnabled()) or centralizing the state check so the meaning of UnknownType and the three theme modes is clearer and less error-prone if the enum or modes change later.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The logic branching on `paletteType() != DGuiApplicationHelper::UnknownType` is a bit opaque; consider extracting this into a named helper (e.g. `isFollowSystemThemeEnabled()`) or centralizing the state check so the meaning of `UnknownType` and the three theme modes is clearer and less error-prone if the enum or modes change later.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@JWWTSL

JWWTSL commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot
deepin-bot Bot merged commit d3a23b2 into linuxdeepin:master Jun 15, 2026
16 checks passed
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: JWWTSL, 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

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