Skip to content

fix(windows): closing the window without a tray icon minimizes it - #1291

Merged
leookun merged 1 commit into
mainfrom
fix/windows-tray-fallback
Nov 24, 2026
Merged

leookun merged 1 commit into
mainfrom
fix/windows-tray-fallback

Conversation

@leookun

@leookun leookun commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Refs #1107

The reporter's tray icon never registered on 2.0.1 (Shell_NotifyIconGetRect → E_FAIL), and WM_CLOSE hid the window anyway, leaving the app unreachable. Root cause not found yet, so this PR does two things:

  • WM_CLOSE with the tray on: if the icon is not up, try ShowIcon() once; if it is still not up, SW_MINIMIZE instead of SW_HIDE, so the taskbar button stays.
  • When both NIM_ADD and NIM_MODIFY fail, the runner sends trayFailed(GetLastError()) over baocode/attention, and Dart writes [tray] icon not added: error N to events.log. It is sent once and reset when the icon goes up, so the 15 s check does not repeat it.

Not compiled locally (macOS). The change follows the existing channel_->InvokeMethod / ShowIcon patterns; needs a Windows check by the maintainer.

🤖 Generated with BaoCode

With the tray on, closing the window hid it, whether or not the icon was
up: where it could not go up the app was left running with no way back
but launching it again (#1107). Closing now tries to put the icon up
first, and without one the window is minimized, its taskbar button left.
The icon failing to go up is written to events.log (Shell_NotifyIcon's
error), once until it does, to find out why.

Refs #1107

Co-Authored-By: BaoCode <noreply@baocode.dev>
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.

2 participants