From 19ddac474a40267ba7748ce66a2dd8b3270c1e1b Mon Sep 17 00:00:00 2001 From: Zane Staggs Date: Tue, 19 Aug 2025 11:57:57 -0700 Subject: [PATCH 1/2] stop replacing chat window when changing working directory --- ui/desktop/src/main.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ui/desktop/src/main.ts b/ui/desktop/src/main.ts index f154ef0d511e..8fd829f06e7b 100644 --- a/ui/desktop/src/main.ts +++ b/ui/desktop/src/main.ts @@ -1036,9 +1036,8 @@ const openDirectoryDialog = async ( const currentWindow = BrowserWindow.getFocusedWindow(); if (replaceWindow && currentWindow) { - // Replace current window with new one + // Create a new window instead of replacing the current one await createChat(app, undefined, dirToAdd); - currentWindow.close(); } else { // Update the working directory in the current window's localStorage if (currentWindow) { From 44faacaf939e68192efd60df395e6a88d69150c1 Mon Sep 17 00:00:00 2001 From: Zane Staggs Date: Tue, 19 Aug 2025 12:03:31 -0700 Subject: [PATCH 2/2] remove unneeded replace option --- ui/desktop/src/main.ts | 48 ++++----------------------------------- ui/desktop/src/preload.ts | 2 +- 2 files changed, 6 insertions(+), 44 deletions(-) diff --git a/ui/desktop/src/main.ts b/ui/desktop/src/main.ts index 8fd829f06e7b..cb77c82d2edd 100644 --- a/ui/desktop/src/main.ts +++ b/ui/desktop/src/main.ts @@ -953,9 +953,7 @@ const buildRecentFilesMenu = () => { })); }; -const openDirectoryDialog = async ( - replaceWindow: boolean = false -): Promise => { +const openDirectoryDialog = async (): Promise => { // Get the current working directory from the focused window let defaultPath: string | undefined; const currentWindow = BrowserWindow.getFocusedWindow(); @@ -1033,44 +1031,8 @@ const openDirectoryDialog = async ( } addRecentDir(dirToAdd); - const currentWindow = BrowserWindow.getFocusedWindow(); - - if (replaceWindow && currentWindow) { - // Create a new window instead of replacing the current one - await createChat(app, undefined, dirToAdd); - } else { - // Update the working directory in the current window's localStorage - if (currentWindow) { - try { - const updateConfigScript = ` - try { - const currentConfig = JSON.parse(localStorage.getItem('gooseConfig') || '{}'); - const updatedConfig = { - ...currentConfig, - GOOSE_WORKING_DIR: '${dirToAdd.replace(/'/g, "\\'")}', - }; - localStorage.setItem('gooseConfig', JSON.stringify(updatedConfig)); - - // Trigger a config update event so the UI can refresh - window.dispatchEvent(new CustomEvent('goose-config-updated', { - detail: { GOOSE_WORKING_DIR: '${dirToAdd.replace(/'/g, "\\'")}' } - })); - } catch (e) { - console.error('Failed to update working directory in localStorage:', e); - } - `; - await currentWindow.webContents.executeJavaScript(updateConfigScript); - console.log(`Updated working directory to: ${dirToAdd}`); - } catch (error) { - console.error('Failed to update working directory:', error); - // Fallback: create new window - await createChat(app, undefined, dirToAdd); - } - } else { - // No current window, create new one - await createChat(app, undefined, dirToAdd); - } - } + // Create a new window with the selected directory + await createChat(app, undefined, dirToAdd); } return result; }; @@ -1109,8 +1071,8 @@ ipcMain.on('react-ready', () => { }); // Handle directory chooser -ipcMain.handle('directory-chooser', (_event, replace: boolean = false) => { - return openDirectoryDialog(replace); +ipcMain.handle('directory-chooser', (_event) => { + return openDirectoryDialog(); }); // Handle scheduling engine settings diff --git a/ui/desktop/src/preload.ts b/ui/desktop/src/preload.ts index 8de1613fce1d..8baac961f293 100644 --- a/ui/desktop/src/preload.ts +++ b/ui/desktop/src/preload.ts @@ -140,7 +140,7 @@ const electronAPI: ElectronAPI = { return config; }, hideWindow: () => ipcRenderer.send('hide-window'), - directoryChooser: (replace?: boolean) => ipcRenderer.invoke('directory-chooser', replace), + directoryChooser: () => ipcRenderer.invoke('directory-chooser'), createChatWindow: ( query?: string, dir?: string,