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
2 changes: 2 additions & 0 deletions ui/desktop/src/components/bottom_menu/DirSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FolderDot } from 'lucide-react';
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../ui/Tooltip';
import { updateWorkingDir } from '../../api';
import { toast } from 'react-toastify';
import { setCurrentWorkingDir } from '../../utils/workingDir';

interface DirSwitcherProps {
className: string;
Expand Down Expand Up @@ -42,6 +43,7 @@ export const DirSwitcher: React.FC<DirSwitcherProps> = ({
const newDir = result.filePaths[0];

window.electron.addRecentDir(newDir);
setCurrentWorkingDir(newDir);
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The Hub component (ui/desktop/src/components/Hub.tsx:40) maintains its own workingDir state initialized from getInitialWorkingDir(). When a user changes the directory in the Hub view, the module-level state is updated, but Hub's local state is not. This means if a user changes the directory while in Hub view, then creates a new chat, the new chat will get the updated directory from getInitialWorkingDir(), but Hub's ChatInput will still display the old directory. Consider calling onWorkingDirChange?.(newDir) unconditionally before the if (sessionId) check to ensure all components stay in sync.

Copilot uses AI. Check for mistakes.

if (sessionId) {
onWorkingDirChange?.(newDir);
Expand Down
10 changes: 9 additions & 1 deletion ui/desktop/src/utils/workingDir.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
// Track the current working dir for this window (updated when user changes it)
let currentWorkingDir: string | null = null;

export const setCurrentWorkingDir = (dir: string): void => {
currentWorkingDir = dir;
};

export const getInitialWorkingDir = (): string => {
return (window.appConfig?.get('GOOSE_WORKING_DIR') as string) || '';
// Use the current dir if set, otherwise fall back to initial config
return currentWorkingDir ?? (window.appConfig?.get('GOOSE_WORKING_DIR') as string) ?? '';
};
Loading