fix(ui): preserve working directory when creating new chat (#6789)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import { FolderDot } from 'lucide-react';
|
|||||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../ui/Tooltip';
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../ui/Tooltip';
|
||||||
import { updateWorkingDir } from '../../api';
|
import { updateWorkingDir } from '../../api';
|
||||||
import { toast } from 'react-toastify';
|
import { toast } from 'react-toastify';
|
||||||
|
import { setCurrentWorkingDir } from '../../utils/workingDir';
|
||||||
|
|
||||||
interface DirSwitcherProps {
|
interface DirSwitcherProps {
|
||||||
className: string;
|
className: string;
|
||||||
@@ -42,6 +43,7 @@ export const DirSwitcher: React.FC<DirSwitcherProps> = ({
|
|||||||
const newDir = result.filePaths[0];
|
const newDir = result.filePaths[0];
|
||||||
|
|
||||||
window.electron.addRecentDir(newDir);
|
window.electron.addRecentDir(newDir);
|
||||||
|
setCurrentWorkingDir(newDir);
|
||||||
|
|
||||||
if (sessionId) {
|
if (sessionId) {
|
||||||
onWorkingDirChange?.(newDir);
|
onWorkingDirChange?.(newDir);
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
export const getInitialWorkingDir = (): string => {
|
// Track the current working dir for this window (updated when user changes it)
|
||||||
return (window.appConfig?.get('GOOSE_WORKING_DIR') as string) || '';
|
let currentWorkingDir: string | null = null;
|
||||||
|
|
||||||
|
export const setCurrentWorkingDir = (dir: string): void => {
|
||||||
|
currentWorkingDir = dir;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getInitialWorkingDir = (): string => {
|
||||||
|
// Use the current dir if set, otherwise fall back to initial config
|
||||||
|
return currentWorkingDir ?? (window.appConfig?.get('GOOSE_WORKING_DIR') as string) ?? '';
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user