From e7c65ca3082914485ff85d90ebec8f8a9c725da6 Mon Sep 17 00:00:00 2001 From: Jannis Braun <151788261+TheZwiss@users.noreply.github.com> Date: Mon, 27 Apr 2026 13:22:14 +0200 Subject: [PATCH] fix(desktop): preserve startMinimized preference across off/on cycle on Windows When autostart is disabled, Windows deletes the Run registry entry, so deriveStartMinimizedFromArgs(undefined) was returning false and silently resetting the user's startMinimized preference the next time autostart was re-enabled. Both the get- and set-auto-launch-settings handlers now fall back to the disk-cached value when no OS entry exists, matching the existing macOS/Linux fallback pattern. --- packages/desktop/src/main.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/desktop/src/main.ts b/packages/desktop/src/main.ts index 8c29fc6c..9c2d78a5 100644 --- a/packages/desktop/src/main.ts +++ b/packages/desktop/src/main.ts @@ -558,9 +558,16 @@ function registerIpcHandlers(): void { const ownEntry = osState.launchItems?.find( (item) => item.name === 'Backspace' || item.path?.toLowerCase() === process.execPath.toLowerCase(), ); + // When the Run entry exists, its args are the source of truth for startMinimized. + // When the entry is absent (autostart is off), there is no OS state to read, so we + // fall back to the disk cache — this preserves the user's preference across an + // off/on cycle so re-enabling restores their previous startMinimized choice. + const startMinimized = ownEntry + ? deriveStartMinimizedFromArgs(ownEntry.args) + : loadAutoLaunchSettings().startMinimized; return { openAtLogin: osState.executableWillLaunchAtLogin ?? false, - startMinimized: deriveStartMinimizedFromArgs(ownEntry?.args), + startMinimized, }; } // macOS and Linux: getLoginItemSettings doesn't expose args, so startMinimized @@ -587,7 +594,12 @@ function registerIpcHandlers(): void { (item) => item.name === 'Backspace' || item.path?.toLowerCase() === process.execPath.toLowerCase(), ); currentOpenAtLogin = osState.executableWillLaunchAtLogin ?? false; - currentStartMinimized = deriveStartMinimizedFromArgs(ownEntry?.args); + // See `get-auto-launch-settings`: when the entry is absent, fall back to disk + // cache so a partial update that re-enables openAtLogin restores the user's + // previously-saved startMinimized choice rather than resetting to false. + currentStartMinimized = ownEntry + ? deriveStartMinimizedFromArgs(ownEntry.args) + : loadAutoLaunchSettings().startMinimized; } else { const osState = app.getLoginItemSettings(); const saved = loadAutoLaunchSettings();