Windows tray support is a desktop-only entry point for the Electron main process. It does not change web, mobile remote control, ZCode Agent, task stream, protocol, relay, or shared-host attachment behavior.
Windows close-to-tray behavior is enabled by default. Users can disable closeToTrayOnWindows from Settings when they want the close button to exit through the existing close flow.
app.whenReady(). Linux creation follows the capability checks in Linux close-to-tray.packages/desktop/src/main/desktopTray.ts module state so Electron does not garbage collect it.primaryWindowCoordinator.ensurePrimaryWindow("tray-show-current-window"), reusing the current window restore/create logic.executeDesktopCommandForApp and existing DesktopCommandIds; no new IPC protocol is introduced.app.quit() path, so before-quit confirmation and host process cleanup stay centralized.DesktopCommandIds.ExportLogs, matching the desktop application menu's archive creation and system file reveal. The existing tray command flow restores the primary window before exporting. Labels follow the current application locale through the existing desktop menu translations.Windows and supported Linux desktops share this context menu, so both use the same replacement. Other data-cleanup entry points are unchanged.
tray Export Logs → restore primary window → DesktopCommandIds.ExportLogs
↓
existing main exportLogs → archive / system file reveal
closeToTrayOnWindows is a Windows desktop-only app setting. It defaults to true for new installations.
The release that changes this default performs a one-time migration tracked by closeToTrayOnWindowsMigrationInitialized:
closeToTrayOnWindows value is set to true even when the old file contains false, because old settings do not record whether that value came from the previous default or an explicit user action.closeToTrayOnWindowsMigrationInitialized: true are persisted together. Persistence uses the setting service's serialized update path so it cannot overwrite a concurrent settings update.closeToTrayOnWindows value is authoritative. If the user disables the setting after migration, later reads and upgrades preserve false.A new installation starts with close-to-tray enabled and is considered migrated. Its first settings write persists the marker together with the user's current choice.
settings read
|
+-- migration marker missing --> force close-to-tray on --> persist marker
|
+-- migration marker present --> preserve stored true/false
When enabled:
BrowserWindow.close() path, so they also hide the window.primaryWindowCoordinator.ensurePrimaryWindow("tray-show-current-window"), which restores hidden or minimized windows before focusing them.show() for an existing hidden window before focusing it.app.quit(), so the close handler does not convert that quit into a hide.The shared settings schema is the source of truth for the default and migration result. The Settings page and Electron main-process bootstrap use the same true fallback so the displayed toggle and close handler cannot disagree while settings are unavailable.
false, preservation of migrated false, and preservation of migrated true.manual-review/pending/windows-tray-export-logs.test.ts checks the actual Windows tray menu and invokes its native menu callback, verifying a ZIP archive and a system file reveal request. It does not automate clicking the Windows notification area itself; non-Windows hosts skip this case.The pending case needs no model request. Run it separately with the shared replay fixture to avoid capture-mode credentials:
E2E_PROVIDER_REPLAY_FIXTURE_PATH=packages/desktop/test/e2e/fixtures/upstream/common.json pnpm --filter @zcode/desktop test:e2e -- --spec ./test/e2e/manual-review/pending/windows-tray-export-logs.test.ts
2026-10-09 validation: 53 related unit tests passed, including Windows/Linux menu dispatch; typecheck, E2E typecheck, lint (68 existing warnings), architecture and formatting checks passed. A fresh desktop build passed all 4 macOS Preview help-menu E2E cases and generated real ZIP archives. The Windows tray callback and Windows/Linux native notification-area interaction remain unverified on devices. Export replay evidence: packages/desktop/.e2e-artifacts/desktop-e2e-20261009044422815-p40172-3ffb6e230eb79c0a/summary.json.
Development reads the tray icon from packages/desktop/build/icon.ico.
Packaged builds copy the same ICO into Electron resources as tray_icon.ico through packages/desktop/electron-builder.config.js; main resolves it from process.resourcesPath.
The tray and close-to-tray behavior are main-process desktop concerns. They do not change web, mobile remote control, task stream delivery, replayable snapshots, relay behavior, or shared-host attachment semantics.