Skip to content
Open
Changes from 2 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
13 changes: 10 additions & 3 deletions src/renderer/components/WorktreeConfigModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ interface WorktreeConfigModalProps {
onDisableConfig: () => void;
}

/** Get parent directory from a path (works with both / and \ separators) */
function getParentDir(path: string): string {
return path.replace(/[/\\][^/\\]+$/, '');
}

/**
* Validates that a directory exists (works over SSH for remote sessions)
*/
Expand Down Expand Up @@ -49,8 +54,10 @@ export function WorktreeConfigModal({
const onCloseRef = useRef(onClose);
onCloseRef.current = onClose;

// Form state
const [basePath, setBasePath] = useState(session.worktreeConfig?.basePath || '');
// Form state — default base path to parent directory of the agent's cwd
const [basePath, setBasePath] = useState(
session.worktreeConfig?.basePath || getParentDir(session.cwd)
);
const [watchEnabled, setWatchEnabled] = useState(session.worktreeConfig?.watchEnabled ?? true);
const [newBranchName, setNewBranchName] = useState('');
const [isCreating, setIsCreating] = useState(false);
Expand Down Expand Up @@ -86,7 +93,7 @@ export function WorktreeConfigModal({
useEffect(() => {
if (isOpen) {
checkGhCli();
setBasePath(session.worktreeConfig?.basePath || '');
setBasePath(session.worktreeConfig?.basePath || getParentDir(session.cwd));
setWatchEnabled(session.worktreeConfig?.watchEnabled ?? true);
setNewBranchName('');
setError(null);
Expand Down