diff --git a/src/browser/App.tsx b/src/browser/App.tsx index 935d2b74ec..eda286922d 100644 --- a/src/browser/App.tsx +++ b/src/browser/App.tsx @@ -141,7 +141,7 @@ function AppInner() { selectedWorkspace, setSelectedWorkspace, pendingNewWorkspaceProject, - pendingNewWorkspaceSectionId, + pendingNewWorkspaceSubProjectPath, pendingNewWorkspaceDraftId, beginWorkspaceCreation, } = useWorkspaceContext(); @@ -169,6 +169,7 @@ function AppInner() { refreshProjects, removeProject, openProjectCreateModal, + projectCreateInitialPath, isProjectCreateModalOpen, closeProjectCreateModal, addProject, @@ -1154,7 +1155,7 @@ function AppInner() { projectName={projectName} leftSidebarCollapsed={sidebarCollapsed} onToggleLeftSidebarCollapsed={handleToggleSidebar} - pendingSectionId={pendingNewWorkspaceSectionId} + pendingSubProjectPath={pendingNewWorkspaceSubProjectPath} pendingDraftId={pendingNewWorkspaceDraftId} onWorkspaceCreated={(metadata, options) => { // IMPORTANT: Add workspace to store FIRST (synchronous) to ensure @@ -1217,6 +1218,7 @@ function AppInner() { ({ workspaceId: selectedWorkspace?.workspaceId })} /> { diff --git a/src/browser/components/ProjectCreateModal/ProjectCreateModal.tsx b/src/browser/components/ProjectCreateModal/ProjectCreateModal.tsx index 123b1a0d8a..4aaa36fc72 100644 --- a/src/browser/components/ProjectCreateModal/ProjectCreateModal.tsx +++ b/src/browser/components/ProjectCreateModal/ProjectCreateModal.tsx @@ -40,7 +40,9 @@ function useDirectoryPicker(params: { const browse = useCallback(async () => { if (isDesktop) { try { - const selectedPath = await api?.projects.pickDirectory(); + // Seed the native directory picker with the user's current input so + // Browse opens at that path when it's already an existing directory. + const selectedPath = await api?.projects.pickDirectory({ initialPath }); if (selectedPath) { onSelectPath(selectedPath); } @@ -53,7 +55,7 @@ function useDirectoryPicker(params: { if (hasWebFsPicker) { setIsDirPickerOpen(true); } - }, [api, errorLabel, hasWebFsPicker, isDesktop, onSelectPath]); + }, [api, errorLabel, hasWebFsPicker, initialPath, isDesktop, onSelectPath]); const directoryPickerModal = hasWebFsPicker ? ( void; onSuccess: (normalizedPath: string, projectConfig: ProjectConfig) => void; @@ -75,6 +78,8 @@ interface ProjectCreateModalProps { interface ProjectCreateFormProps { onSuccess: (normalizedPath: string, projectConfig: ProjectConfig) => void; + /** Optional initial path for parent-scoped sub-project creation. */ + initialPath?: string; /** * Optional close handler for modal-style usage. * When provided, the form will call it on cancel and after a successful add. @@ -102,6 +107,7 @@ export interface ProjectCreateFormHandle { export const ProjectCreateForm = React.forwardRef( function ProjectCreateForm( { + initialPath, onSuccess, onClose, showCancelButton = false, @@ -116,10 +122,14 @@ export const ProjectCreateForm = React.forwardRef { + setPath(initialPath ?? ""); + }, [initialPath]); + const setCreating = useCallback( (next: boolean) => { setIsCreating(next); @@ -776,6 +786,7 @@ export interface ProjectAddFormHandle { } interface ProjectAddFormProps { + initialPath?: string; onSuccess: (normalizedPath: string, projectConfig: ProjectConfig) => void; onClose?: () => void; isOpen: boolean; @@ -912,6 +923,7 @@ export const ProjectAddForm = React.forwardRef = ({ + initialPath, isOpen, onClose, onSuccess, @@ -984,6 +997,7 @@ export const ProjectCreateModal: React.FC = ({