fix(v3/windows): fix ICO tray icons and follow taskbar theme - #6030
fix(v3/windows): fix ICO tray icons and follow taskbar theme#6030leaanthony wants to merge 6 commits into
Conversation
Adds an AST-based test asserting that IsCurrentlyDarkMode reads AppsUseLightTheme and IsSystemCurrentlyDarkMode reads SystemUsesLightTheme, both from the Themes\Personalize key and both reporting dark mode when the value is 0. This guards the distinction the tray icon fix relies on: application windows follow the apps theme while the taskbar and its tray icons follow the system theme, so an accidental key swap or a flipped comparison is caught at build time. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MECVhq4AGVic4Zvo8VJBKg
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review. WalkthroughWindows theme tracking now includes system dark mode. Tray icons use the system theme. Windows icon loading now supports validated PNG and ICO resources with size and bit-depth selection. Theme detection tests and system tray documentation were updated. ChangesWindows dark-mode and icon handling
Estimated code review effort: 4 (Complex) | ~45 minutes Merge Risk: ⚪ Minimal · up to This PR corrects Windows ICO tray icon handling and aligns tray icon selection with the taskbar theme; no actionable merge-blocking risk remains after normal checks. Sequence Diagram(s)sequenceDiagram
participant Windows
participant Application
participant w32
participant SystemTray
Windows->>Application: WM_SETTINGCHANGE
Application->>w32: Read application and system dark-mode state
w32-->>Application: Theme state values
Application->>Application: Emit SystemThemeChanged when either value changes
SystemTray->>w32: Read system dark-mode state
w32-->>SystemTray: Select dark or light tray icon
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description covers the issue context, fixes, motivation, testing, documentation update, and checklist. It is mostly complete, although it does not provide Full details: Docstring CoverageExplanation Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 5 files. (1 skipped: 1 unsupported.) ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: build constraints exclude all Go files in /v3/pkg/w32" 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. Comment |
There was a problem hiding this comment.
Pull request overview
This PR fixes Windows v3 system tray icon behavior by (1) correctly extracting a single embedded image from .ico containers before calling CreateIconFromResourceEx, and (2) making tray icon light/dark selection follow the taskbar/system surfaces theme (SystemUsesLightTheme) rather than the apps theme (AppsUseLightTheme). It also adds an AST-based test to lock in the registry value-name distinction and updates systray documentation accordingly.
Changes:
- Add
IsSystemCurrentlyDarkMode()to readSystemUsesLightThemefrom the Personalize registry key. - Update Windows systray icon selection to use system-surface theme detection.
- Add a table-driven AST test ensuring both dark-mode detection functions open the correct registry key/value and treat
0as dark mode.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
v3/pkg/w32/theme.go |
Adds system-surface dark mode detection via SystemUsesLightTheme. |
v3/pkg/w32/theme_test.go |
Adds AST-based regression test to prevent swapping AppsUseLightTheme vs SystemUsesLightTheme. |
v3/pkg/w32/icon.go |
Implements ICO directory parsing and selects a best-fit embedded image resource for icon creation. |
v3/pkg/application/systemtray_windows.go |
Switches tray icon selection to system-surface dark mode detection. |
v3/pkg/application/application_windows.go |
Tracks both app and system-surface theme state to emit theme-change events when either changes. |
docs/src/content/docs/features/menus/systray.mdx |
Documents SetDarkModeIcon as supported on Windows and macOS. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| directoryEnd := icoHeaderSize + imageCount*icoDirEntrySize | ||
|
|
||
| entries := make([]icoImageEntry, 0, imageCount) | ||
| for index := range imageCount { |
|
Closing — superseded. #6016 was merged with the identical content (same tree), so this branch has nothing left to contribute. Generated by Claude Code |
Description
Replaces #6016 (same content, branched into this repo). Original work by @nik9play — their commits are preserved here, with one test commit added on top.
This fixes two Windows system tray icon problems:
SetIcondid not work, and the icon fell back to the default Wails icon. The complete .ico container was passed toCreateIconFromResourceEx, which expects a single icon image resource. The implementation now parses the .ico directory, validates its entries, and selects the best embedded image for the requested dimensions and display bit depth.AppsUseLightTheme. That preference controls application appearance, which can differ from the taskbar theme. Tray icons now useSystemUsesLightTheme, while application windows continue to useAppsUseLightTheme.The added test (
TestDarkModeDetectionReadsExpectedRegistryValuesinv3/pkg/w32/theme_test.go) covers that second point: it is table-driven over both detection functions and asserts that each opens theThemes\Personalizekey, reads its own value name (AppsUseLightThemevsSystemUsesLightTheme), and reports dark mode when the value is0. Covering both together is what guards the distinction — a swap of the two key names would otherwise be silent.The systray documentation now states that
SetDarkModeIconis supported on Windows and macOS.Type of change
How Has This Been Tested?
Per #6016, the affected Windows packages were tested with
go test ./pkg/w32 ./pkg/application, and small example apps confirmed both the ICO tray icon and the light/dark taskbar behaviour (screenshots in #6016).For the added test:
GOOS=windows go vet ./pkg/w32andGOOS=windows go test -c ./pkg/w32are clean. Because the test only parsestheme.goas source, its assertions were also exercised on a non-Windows host and mutation-checked — reverting the tray function toAppsUseLightTheme, flipping== 0to!= 0, and misspelling the registry path each fail with a specific message.Checklist:
🤖 Generated with Claude Code
https://claude.ai/code/session_01MECVhq4AGVic4Zvo8VJBKg
Generated by Claude Code
Summary by CodeRabbit
New Features
Documentation