From 947a3ecf77d6aef1a744eecfabfccab96ed6c78d Mon Sep 17 00:00:00 2001 From: McGluut <189849001+McGluut@users.noreply.github.com> Date: Mon, 18 May 2026 10:58:11 +0200 Subject: [PATCH 1/4] fix(desktop): avoid extra startup window for deep links --- ui/desktop/src/main.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/desktop/src/main.ts b/ui/desktop/src/main.ts index 81c861b04bea..323694db5b72 100644 --- a/ui/desktop/src/main.ts +++ b/ui/desktop/src/main.ts @@ -381,6 +381,7 @@ if (MAIN_WINDOW_VITE_DEV_SERVER_URL) { // Apply single instance lock on Windows and Linux where it's needed for deep links // macOS uses the 'open-url' event instead let gotTheLock = true; +let openUrlHandledLaunch = false; if (process.platform !== 'darwin') { gotTheLock = app.requestSingleInstanceLock(); @@ -449,13 +450,13 @@ if (process.platform !== 'darwin') { const protocolUrl = process.argv.find((arg) => arg.startsWith('goose://')); if (protocolUrl) { app.whenReady().then(() => { + openUrlHandledLaunch = true; handleProtocolUrl(protocolUrl); }); } } const pendingDeepLinks = new Map(); // windowId -> deep link URL -let openUrlHandledLaunch = false; function getResumeSessionId(parsedUrl: URL): string | null { try { From 28f685e31433e6c10a085b709e67199ebe15d0d4 Mon Sep 17 00:00:00 2001 From: McGluut <189849001+McGluut@users.noreply.github.com> Date: Mon, 18 May 2026 11:27:46 +0200 Subject: [PATCH 2/4] fix(desktop): guard startup deep link parsing --- ui/desktop/src/main.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ui/desktop/src/main.ts b/ui/desktop/src/main.ts index 323694db5b72..1fb59e6166c1 100644 --- a/ui/desktop/src/main.ts +++ b/ui/desktop/src/main.ts @@ -450,8 +450,16 @@ if (process.platform !== 'darwin') { const protocolUrl = process.argv.find((arg) => arg.startsWith('goose://')); if (protocolUrl) { app.whenReady().then(() => { + let parsedUrl: URL; + try { + parsedUrl = new URL(protocolUrl); + } catch (error) { + log.warn('[Main] Ignoring invalid startup protocol URL:', errorMessage(error)); + return; + } + openUrlHandledLaunch = true; - handleProtocolUrl(protocolUrl); + handleProtocolUrl(protocolUrl, parsedUrl); }); } } @@ -478,10 +486,10 @@ async function createResumeChatWindow(parsedUrl: URL, dir?: string): Promise 0 ? recentDirs[0] : null; From 519cd27d648194fad605b275a48e408f64b1b8bd Mon Sep 17 00:00:00 2001 From: McGluut <189849001+McGluut@users.noreply.github.com> Date: Mon, 18 May 2026 12:07:28 +0200 Subject: [PATCH 3/4] fix(desktop): await startup deep link dispatch --- ui/desktop/src/main.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ui/desktop/src/main.ts b/ui/desktop/src/main.ts index 1fb59e6166c1..d5bf4e3e345e 100644 --- a/ui/desktop/src/main.ts +++ b/ui/desktop/src/main.ts @@ -449,7 +449,7 @@ if (process.platform !== 'darwin') { // Handle protocol URLs on Windows and Linux startup const protocolUrl = process.argv.find((arg) => arg.startsWith('goose://')); if (protocolUrl) { - app.whenReady().then(() => { + app.whenReady().then(async () => { let parsedUrl: URL; try { parsedUrl = new URL(protocolUrl); @@ -459,7 +459,15 @@ if (process.platform !== 'darwin') { } openUrlHandledLaunch = true; - handleProtocolUrl(protocolUrl, parsedUrl); + try { + await handleProtocolUrl(protocolUrl, parsedUrl); + } catch (error) { + log.error('[Main] Failed to handle startup protocol URL:', errorMessage(error)); + if (BrowserWindow.getAllWindows().length === 0) { + const { dirPath } = parseArgs(); + await createNewWindow(app, dirPath); + } + } }); } } From a6045e483e5b78c285ea957081f98a4ea85e05fe Mon Sep 17 00:00:00 2001 From: Douwe Osinga Date: Mon, 18 May 2026 10:47:05 -0400 Subject: [PATCH 4/4] fix: make parsedUrl required in handleProtocolUrl Both call sites already have the parsed URL available, so there is no reason for the parameter to be optional. --- ui/desktop/src/main.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ui/desktop/src/main.ts b/ui/desktop/src/main.ts index d5bf4e3e345e..08d9512040fe 100644 --- a/ui/desktop/src/main.ts +++ b/ui/desktop/src/main.ts @@ -431,7 +431,7 @@ if (process.platform !== 'darwin') { } // For non-bot URLs, continue with normal handling - handleProtocolUrl(protocolUrl); + handleProtocolUrl(protocolUrl, parsedUrl); } // Only focus existing windows for non-bot/recipe URLs @@ -494,10 +494,9 @@ async function createResumeChatWindow(parsedUrl: URL, dir?: string): Promise 0 ? recentDirs[0] : null;