Skip to content

fix(windows): explicitly delete shell notify icon on teardown to prev… - #291

Open
HarshalPatel1972 wants to merge 2 commits into
getlantern:masterfrom
HarshalPatel1972:fix/windows-ghost-tray-icon
Open

HarshalPatel1972 wants to merge 2 commits into
getlantern:masterfrom
HarshalPatel1972:fix/windows-ghost-tray-icon

Conversation

@HarshalPatel1972

Copy link
Copy Markdown

Fixes #237

Problem

When applications using this library exit on Windows, the icon often remains stagnant in the taskbar notification system tray as a "ghost" icon. It only disappears when a user explicitly hovers their mouse pointer over it, forcing the Windows Shell to realize the backing thread/process is dead.

Fix

Intercepted WM_CLOSE and WM_ENDSESSION window messages inside wndProc to explicitly invoke t.nid.delete() (which triggers Shell_NotifyIconW with NIM_DELETE).

  • Wrapped the cleanup loop inside the t.muNID mutex lock.
  • Reset t.nid = nil post-deletion to safely protect the execution path against double-deletion issues if multiple teardown signals fire sequentially.

Tested on

Windows 11 (Go 1.26 verification build passes cleanly).

Copilot AI review requested due to automatic review settings May 29, 2026 22:51

Copilot AI 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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Improves Windows tray icon shutdown behavior to prevent “ghost” notification area icons by explicitly removing the tray icon earlier in the window lifecycle.

Changes:

  • Delete the tray icon during WM_CLOSE before destroying/unregistering the window class.
  • Add a double-delete guard by setting t.nid = nil after deletion in both WM_CLOSE and WM_ENDSESSION.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread systray_windows.go Resolved
Comment thread systray_windows.go Resolved
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.

Terminating process leaves icon visible

2 participants