Skip to content

新增“切换系统强调色”行动,修复媒体规则抖动并统一主题切换逻辑#73

Merged
Programmer-MrWang merged 3 commits into
mainfrom
codex/add-color-theme-switching-feature
May 16, 2026
Merged

新增“切换系统强调色”行动,修复媒体规则抖动并统一主题切换逻辑#73
Programmer-MrWang merged 3 commits into
mainfrom
codex/add-color-theme-switching-feature

Conversation

@Programmer-MrWang
Copy link
Copy Markdown
Owner

Motivation

  • 增加允许用户通过颜色板选择并即时切换 Windows 系统强调色的自动化行动以满足自定义主题需求。
  • 修复规则集“正在播放媒体音乐”在 规则集更新 触发器下的频繁抖动问题,避免误触发自动化工作流。
  • 使插件中“自动匹配主界面背景色到 ClassIsland 主题”的切换方式与 ClassIsland 的“应用设置->应用主题”路径更一致,避免直接调用主题服务带来的状态不同步。

Description

  • 新增行动 SwitchSystemAccentColorActionActions/SwitchSystemAccentColorAction.cs)及其设置模型 AccentColorSettingsSettings/AccentColorSettings.cs)和设置控件 AccentColorSettingsControlControls/AccentColorSettingsControl.cs),通过注册表写入实现即时切换强调色。
  • Plugin.cs 中注册新行动并将其加入“系统个性化”菜单和功能开关页(添加动作注册与菜单项)。
  • 修正媒体规则实现(在 Plugin.cs 中的 HandleMediaMusicPlayingRule):保持使用 SMTC 遍历会话判断是否存在任意 Playing 会话的核心逻辑,同时加入 800ms 短时缓存与异常回退以降低高频触发抖动。
  • AdaptiveThemeSyncService 的自动应用主题逻辑改为优先通过反射写入 SettingsService.Settings.Theme(方法 ApplyThemeLikeAppSettings),无法访问时回退到 IThemeService.SetTheme(...),使行为更接近 ClassIsland 的“应用设置”实现。

Testing

  • 尝试构建:运行 dotnet build -v minimal 但当前运行环境缺少 .NET SDK,构建未能执行(dotnet: command not found)。
  • 已运行仓库检查与文本搜索以验证变更点(对文件添加/修改进行了静态检查);并已提交更改(git 提交成功)。

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a243443a7d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Plugin.cs
Comment on lines +663 to +664
_lastMediaRuleCheckAt = now;
return _lastMediaRuleResult;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Clear cached playing state when SMTC query throws

If media was previously detected as playing, this catch path returns that stale true value on every SMTC failure, so the rule can remain permanently true after playback has already stopped whenever RequestAsync()/GetSessions() starts throwing (for example, intermittent WinRT/permission failures). Because this rule drives automations, returning the last positive state on exceptions can cause repeated false triggers; the failure path should invalidate or age out the cached result instead of reusing it indefinitely.

Useful? React with 👍 / 👎.

Comment on lines +178 to +182
var settingsServiceObj = IAppHost.TryGetService<object>();
if (settingsServiceObj != null)
{
var type = settingsServiceObj.GetType();
if (type.Name == "SettingsService")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Resolve settings service instead of requesting object

This lookup asks DI for object, which typically does not resolve to arbitrary registered services in the default .NET container, so the reflection branch is effectively unreachable and the method always falls back to IThemeService.SetTheme(...). That means the new “apply like app settings” synchronization logic does not actually run, so the intended fix for theme-state consistency is not applied.

Useful? React with 👍 / 👎.

@Programmer-MrWang
Copy link
Copy Markdown
Owner Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 588cec70da

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Plugin.cs
@Programmer-MrWang Programmer-MrWang merged commit 5da76b8 into main May 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant