Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 5 additions & 44 deletions ui/desktop/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -953,9 +953,7 @@ const buildRecentFilesMenu = () => {
}));
};

const openDirectoryDialog = async (
replaceWindow: boolean = false
): Promise<OpenDialogReturnValue> => {
const openDirectoryDialog = async (): Promise<OpenDialogReturnValue> => {
// Get the current working directory from the focused window
let defaultPath: string | undefined;
const currentWindow = BrowserWindow.getFocusedWindow();
Expand Down Expand Up @@ -1033,45 +1031,8 @@ const openDirectoryDialog = async (
}

addRecentDir(dirToAdd);
const currentWindow = BrowserWindow.getFocusedWindow();

if (replaceWindow && currentWindow) {
Copy link
Collaborator Author

@zanesq zanesq Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was left over from when we were attempting to launch in the same window but had to change it last minute. Can bring it back when we work on unifying chat to one window

// Replace current window with new one
await createChat(app, undefined, dirToAdd);
currentWindow.close();
} 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;
};
Expand Down Expand Up @@ -1110,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
Expand Down
2 changes: 1 addition & 1 deletion ui/desktop/src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading