Skip to content

Fix Windows systray icon regression - #4706

Merged
leaanthony merged 2 commits into
v3-alphafrom
claude/fix-windows-systray-regression-011CV4dzu6nm29eQigkz18Ho
Nov 12, 2025
Merged

leaanthony merged 2 commits into
v3-alphafrom
claude/fix-windows-systray-regression-011CV4dzu6nm29eQigkz18Ho

Conversation

@leaanthony

@leaanthony leaanthony commented Nov 12, 2025 •

Copy link
Copy Markdown
Member

Summary

Fixes a regression where the Windows systray icon no longer defaults to the application icon when no custom systray icon is provided.

Fixes #4704

Problem

After commit d58d4ba (#4653), the systray icon on Windows would display the default Wails icon instead of the application's custom icon when no explicit systray icon was set. This broke the expected behavior where the systray should automatically use the app's icon as a fallback.

Root Cause

The regression was introduced on line 228 of systemtray_windows.go where the default icon loading was changed from:

defaultIcon := w32.LoadIconWithResourceID(w32.GetModuleHandle(""), w32.RT_ICON)

To:

defaultIcon := getNativeApplication().windowClass.Icon

The getNativeApplication().windowClass.Icon approach doesn't correctly load the application's icon resource, while w32.LoadIconWithResourceID with w32.RT_ICON properly loads the app icon from the resource with the correct resource type identifier.

Solution

Revert the default icon loading back to using w32.LoadIconWithResourceID(w32.GetModuleHandle(""), w32.RT_ICON), which correctly loads the application's icon resource.

Testing

Verified the change addresses the specific line identified in the issue report
The fix restores the original behavior from before commit d58d4ba

Changes

Modified v3/pkg/application/systemtray_windows.go:228 to restore proper icon loading

Note: This is a minimal, surgical fix that only changes the single line that caused the regression, maintaining all other improvements from the refactor PR #4653.

Summary by CodeRabbit

Bug Fixes

  • Fixed an issue on Windows where the systray icon would fail to default to the application icon when no custom icon was configured. The system now properly retrieves and displays the application icon in the system tray with correct light and dark mode handling.

This fixes a regression introduced in commit d58d4ba where the systray
icon no longer defaults to the application icon when no custom icon is
provided.

The issue was that the default icon loading was changed from:
  defaultIcon := w32.LoadIconWithResourceID(w32.GetModuleHandle(""), w32.RT_ICON)

To:
  defaultIcon := getNativeApplication().windowClass.Icon

This caused the systray to display the default Wails icon instead of
the application's custom icon.

The fix reverts the default icon loading back to using
w32.LoadIconWithResourceID with w32.RT_ICON, which correctly loads
the application's icon resource.

Fixes: #4704
@coderabbitai

coderabbitai Bot commented Nov 12, 2025 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

A changelog entry documents a Windows systray icon bug fix that restores default app icon behavior when no custom icon is provided. The fix modifies the icon loading mechanism in the systray implementation to use resource-based icon retrieval instead of application window class reference.

Changes

Cohort / File(s) Change Summary
Changelog
v3/UNRELEASED_CHANGELOG.md
Added bug fix entry documenting Windows systray icon default behavior restoration.
Windows Systray Icon Loading
v3/pkg/application/systemtray_windows.go
Modified default icon retrieval in systray run() method from getNativeApplication().windowClass.Icon to w32.LoadIconWithResourceID(w32.GetModuleHandle(""), w32.RT_ICON) to properly load app icon as systray default.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Specific areas requiring attention:
    • Verify w32.LoadIconWithResourceID() correctly retrieves the application icon across different app configurations
    • Confirm the change restores functionality without introducing resource leaks or icon ownership issues
    • Validate light/dark mode icon selection logic remains unaffected

Possibly related PRs

Suggested labels

Bug

Poem

🐰 A systray once showed the wrong face,
The Wails icon held its place,
But now with resources so right,
Your app icon shines with delight!
The rabbit hops—the fix is tight! ✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/fix-windows-systray-regression-011CV4dzu6nm29eQigkz18Ho

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c3b169f and 08a5aac.

📒 Files selected for processing (2)
  • v3/UNRELEASED_CHANGELOG.md (1 hunks)
  • v3/pkg/application/systemtray_windows.go (1 hunks)

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@leaanthony
leaanthony changed the base branch from master to v3-alpha November 12, 2025 20:55
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying wails with  Cloudflare Pages  Cloudflare Pages

Latest commit: 08a5aac
Status:⚡️  Build in progress...

View logs

@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Nov 12, 2025
@leaanthony
leaanthony merged commit 54d5b98 into v3-alpha Nov 12, 2025
11 of 13 checks passed
@leaanthony
leaanthony deleted the claude/fix-windows-systray-regression-011CV4dzu6nm29eQigkz18Ho branch November 12, 2025 20:57
@sonarqubecloud

Copy link
Copy Markdown

@semgrep-code-wailsapp

Copy link
Copy Markdown

Semgrep found 1 ssc-cee3e6d5-d7c8-4c35-9815-076aa1ebfd49 finding:

  • v3/examples/dev/frontend/package-lock.json

Risk: Affected versions of rollup are vulnerable to Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').

Manual Review Advice: A vulnerability from this advisory is reachable if you use Rollup to bundle JavaScript with import.meta.url and the output format is set to cjs, umd, or iife formats, while allowing users to inject scriptless HTML elements with unsanitized name attributes

Fix: Upgrade this library to at least version 3.29.5 at wails/v3/examples/dev/frontend/package-lock.json:569.

Reference(s): GHSA-gcx4-mw62-g8wm, CVE-2024-47068

@coderabbitai coderabbitai Bot mentioned this pull request Feb 13, 2026
13 tasks done
Grantmartin2002 pushed a commit to Grantmartin2002/wails that referenced this pull request Apr 29, 2026
* Fix Windows systray icon regression (wailsapp#4704)

This fixes a regression introduced in commit d58d4ba where the systray
icon no longer defaults to the application icon when no custom icon is
provided.

The issue was that the default icon loading was changed from:
  defaultIcon := w32.LoadIconWithResourceID(w32.GetModuleHandle(""), w32.RT_ICON)

To:
  defaultIcon := getNativeApplication().windowClass.Icon

This caused the systray to display the default Wails icon instead of
the application's custom icon.

The fix reverts the default icon loading back to using
w32.LoadIconWithResourceID with w32.RT_ICON, which correctly loads
the application's icon resource.

Fixes: wailsapp#4704

* Update changelog for systray icon fix

---------

Co-authored-by: Claude <noreply@anthropic.com>
@taliesin-ai taliesin-ai added v3 and removed v3-alpha labels Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Improvements or additions to documentation v3 Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

V3 Windows - system tray icon no longer defaulting to app icon if none present

3 participants