Skip to content

[bug] 2.0.1: tray icon never appears, and closing the window leaves the app hidden with no icon #1107

Open

Description

@stelvetica

What happens

On BaoCode 2.0.1+34 (Windows x64), the tray icon never shows up. Clicking the window's X hides the window (closeRequested → hide in events.log) and the process keeps running, but there is no BaoCode icon in the notification area nor in the "Show hidden icons" overflow. The only way back is to launch baocode.exe again (the single-instance reopen path).

This started after updating from 1.9.x to 2.0.1 (installed 2026-11-18 09:12 local time).

Environment

Settings (not the cause)

%APPDATA%\baocode\User\settings.json contains no tray.enabled key, so the default (true, see AttentionSettings) applies — the user never turned the icon off. Windows' own "Other system tray icons" entry for BaoCode is also on.

Evidence

  1. events.log — close hides, and the window only comes back through a second launch:
2026-11-18T10:48:29.609649 [window] <- closeRequested 0
2026-11-18T10:48:29.612647 [window] -> hide 0
2026-11-18T10:48:35.439816 [window] <- reopen
...
2026-11-18T12:11:07.262490 [window] <- closeRequested 0
2026-11-18T12:11:07.264493 [window] -> hide 0
  1. While the window was hidden, UI Automation enumeration of Shell_TrayWnd (visible area) and of TopLevelWindowForOverflowXamlIsland (the "Show hidden icons" flyout) returned 14 tray icons; none of them is BaoCode.

  2. Shell_NotifyIconGetRect({ hWnd = <BaoCode Flutter window>, uID = 1 }) returns 0x80004005 (E_FAIL) for both of the app's Flutter windows — no icon is registered for this run.

  3. Windows still has a stale notification-icon registration for the executable:

HKCU\Control Panel\NotifyIconSettings\6072978505427888638
  UID=1
  InitialTooltip=BaoCode
  IsPromoted=1

So an earlier run did register the icon, but the current run does not add it.

Reading the code

The 15-second watchdog added in #958 should re-add the icon whenever IconThere() is false, and Shell_NotifyIconGetRect says it is false — so either the timer is not firing in 2.0.1, or NIM_ADD keeps failing silently.

Related: WM_CLOSE in attention.cpp hides the window whenever tray_ is set, even if icon_added_ is false. That is what leaves the app unreachable instead of falling through to a quit.

Workaround

Relaunching baocode.exe brings the hidden window back. Toggling Settings → Notifications → Tray off/on recreates the icon for some users (the workaround in #860).

Happy to supply more logs or test a build.

Activity

  1. added
    accepted
    on Nov 18, 2026
  2. leookun commented on Nov 24, 2026

    @leookun
    Collaborator

    Thanks for the thorough investigation. #1291 is a first step:

    • If the tray icon is not up when you close the window, BaoCode now tries to add it once more, and if that still fails it minimizes the window instead of hiding it, so the app can't get stuck invisible anymore.
    • When adding the icon fails, the Windows error code is written to events.log as [tray] icon not added: error N.

    The root cause isn't known yet, so I'm leaving this open. After the next release, if the icon is still missing, could you post that [tray] line from events.log?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions