feat(electron): add Windows startup and system tray support (#2112)

Add Windows launch-at-login with background startup support and extend the
native tray integration to Windows.

Add a Windows-only setting to minimize or close the main window to the
system tray, persist it through desktop settings, and expose it in Settings
search and all locale dictionaries.

Keep tray state synchronized with live sessions on both macOS and Windows,
while preserving the existing macOS behavior.
This commit is contained in:
achcyano
2026-07-10 12:40:48 +03:00
committed by GitHub
parent 51e6ae7e3f
commit 4296efb64d
20 changed files with 325 additions and 39 deletions
+40
View File
@@ -54,6 +54,7 @@ export type DesktopSettings = {
opencodeBinary?: string;
desktopLanAccessEnabled?: boolean;
desktopKeepAwakeEnabled?: boolean;
desktopMinimizeToTrayEnabled?: boolean;
desktopUiPassword?: string;
projects?: ProjectEntry[];
activeProjectId?: string;
@@ -247,6 +248,11 @@ type KeepAwakeStatus = {
active: boolean;
};
type MinimizeToTrayStatus = {
supported: boolean;
enabled: boolean;
};
export const getDesktopLaunchAtLogin = async (): Promise<LaunchAtLoginStatus | null> => {
if (!canUseElectronDesktopIPC() || !isDesktopLocalOriginActive()) {
return null;
@@ -281,6 +287,40 @@ export const setDesktopLaunchAtLogin = async (enabled: boolean): Promise<LaunchA
}
};
export const getDesktopMinimizeToTray = async (): Promise<MinimizeToTrayStatus | null> => {
if (!canUseElectronDesktopIPC() || !isDesktopLocalOriginActive()) {
return null;
}
try {
const result = await invokeDesktop<MinimizeToTrayStatus>('desktop_get_minimize_to_tray');
if (!result || typeof result.supported !== 'boolean' || typeof result.enabled !== 'boolean') {
return null;
}
return result;
} catch (error) {
console.warn('Failed to get minimize to tray status', error);
return null;
}
};
export const setDesktopMinimizeToTray = async (enabled: boolean): Promise<MinimizeToTrayStatus | null> => {
if (!canUseElectronDesktopIPC() || !isDesktopLocalOriginActive()) {
return null;
}
try {
const result = await invokeDesktop<MinimizeToTrayStatus>('desktop_set_minimize_to_tray', { enabled });
if (!result || typeof result.supported !== 'boolean' || typeof result.enabled !== 'boolean') {
return null;
}
return result;
} catch (error) {
console.warn('Failed to set minimize to tray status', error);
return null;
}
};
export const getDesktopKeepAwake = async (): Promise<KeepAwakeStatus | null> => {
if (!canUseElectronDesktopIPC() || !isDesktopLocalOriginActive()) {
return null;