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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user