Skip to content

Tray icon and background host fixes - #32

Merged
ghosthack merged 2 commits into
mainfrom
claude/tray-fixes
Nov 26, 2026
Merged

ghosthack merged 2 commits into
mainfrom
claude/tray-fixes

Conversation

@ghosthack

Copy link
Copy Markdown
Owner

Follow-ups to #7 from a code review of the tray icon.

Tray icon

  • macOS: a single click on the menu-bar icon no longer opens the app. macOS fires the icon's action on the click that opens the menu, so it is now registered only on Windows and Linux, where it means a double-click.
  • macOS: the 2-second timeout on the light/dark check now applies. It waits before reading, so a hung defaults can't stall the host's main loop.
  • A second Open while the app started by the first is still running does nothing. Before, it started another app, which failed with "already running".
  • The light/dark flag is read and written only on the event thread. After Hide This Icon, the icon is removed once instead of every tick.

Background host

  • Linux: the host no longer connects to the X/Wayland display just to learn there is no tray. A short-lived --tray-probe process asks, and the host stays headless unless the probe finds a tray. Logging out of the desktop can therefore no longer end MCP and the phone page while sessions keep running.
  • Windows: the app now stops the host with a stop request (mcp-host.stop, naming the host's pid and start time) as well as a signal. Windows gets only the request, because destroy() there is TerminateProcess, so the shutdown hook never ran and a dead tray icon was left behind. The host polls for the request every 250 ms and exits cleanly. If the host has not exited after the existing wait, it is still force-stopped.
  • The shutdown hook waits up to 1 s for the icon to be removed instead of only queueing the removal.
  • Comments call it the "background host" rather than the "headless MCP host".

Testing

  • mvn -pl app -am test: 639 tests pass, including a new one for stop requests (a stale request for an earlier host with the same pid is ignored).
  • Ran --tray-probe on macOS: it exits 0 normally and 3 under -Djava.awt.headless=true.
  • Not yet tried by hand: the macOS single click, the Windows stop request and the Linux logout case.

🤖 Generated with Claude Code

tester and others added 2 commits November 26, 2026 01:57
…e appearance check, one Open at a time

- macOS fires the tray icon's action on the single click that opens its menu; only
  Windows and Linux open the app from it now.
- macDarkMenuBar waits (2 s) before reading, so a hung `defaults` can't stall the
  host's main loop.
- A second Open while the app started by the first is still running does nothing,
  instead of starting a second app that fails with "already running".
- The appearance flag is read and written only on the event thread; the icon is
  removed once after Hide This Icon, not every tick.
- Comments call the host the background host, not the headless MCP host.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cleanly on Windows

- On Linux the host no longer connects to the display just to find out there is no
  tray: a short-lived --tray-probe process asks, and the host stays headless unless it
  finds one, so logging out of the desktop can't end MCP and the phone page.
- The app stops the host with a stop request (mcp-host.stop, naming the host's pid and
  start time) as well as SIGTERM. Windows gets only the request, since destroy() there
  ends the process without running its shutdown hook; the host exits cleanly and its
  tray icon goes with it. The force-stop after the wait still applies.
- The shutdown hook waits (up to 1 s) for the icon to be removed instead of queueing it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ghosthack
ghosthack merged commit c034577 into main Nov 26, 2026
5 of 6 checks passed
@ghosthack
ghosthack deleted the claude/tray-fixes branch November 26, 2026 10:20
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.

1 participant