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
3 changes: 2 additions & 1 deletion electron/main/ipc-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,11 +586,12 @@ export function setupIpcHandlers(pythonBridge: PythonBridge, getWindow: WindowGe
})

// Directory picker
ipcMain.handle('fs:selectDirectory', async () => {
ipcMain.handle('fs:selectDirectory', async (_event, defaultPath?: string) => {
const win = getWindow()
if (!win) return null
const result = await dialog.showOpenDialog(win, {
properties: ['openDirectory', 'createDirectory'],
...(defaultPath && { defaultPath }),
})
return result.canceled ? null : result.filePaths[0]
})
Expand Down
4 changes: 2 additions & 2 deletions electron/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ contextBridge.exposeInMainWorld('electron', {
ipcRenderer.invoke('fs:saveModel', defaultName),
readFileBase64: (filePath: string): Promise<string> =>
ipcRenderer.invoke('fs:readFileBase64', filePath),
selectDirectory: (): Promise<string | null> =>
ipcRenderer.invoke('fs:selectDirectory'),
selectDirectory: (defaultPath?: string): Promise<string | null> =>
ipcRenderer.invoke('fs:selectDirectory', defaultPath),
savePath: (args: { filters: { name: string; extensions: string[] }[]; defaultPath?: string }): Promise<string | null> =>
ipcRenderer.invoke('fs:savePath', args),
listDir: (dirPath: string): Promise<string[]> =>
Expand Down
6 changes: 3 additions & 3 deletions src/areas/settings/components/StorageSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export function StorageSection(): JSX.Element {
}

async function handleBrowseModels() {
const newPath = await window.electron.fs.selectDirectory()
const newPath = await window.electron.fs.selectDirectory(modelsDir)
if (!newPath || newPath === modelsDir) return

const models = await window.electron.fs.listDir(modelsDir)
Expand All @@ -129,7 +129,7 @@ export function StorageSection(): JSX.Element {
}

async function handleBrowseWorkspace() {
const newPath = await window.electron.fs.selectDirectory()
const newPath = await window.electron.fs.selectDirectory(workspaceDir)
if (!newPath || newPath === workspaceDir) return

const items = await window.electron.fs.listDir(workspaceDir)
Expand All @@ -143,7 +143,7 @@ export function StorageSection(): JSX.Element {
}

async function handleBrowseWorkflows() {
const newPath = await window.electron.fs.selectDirectory()
const newPath = await window.electron.fs.selectDirectory(workflowsDir)
if (!newPath || newPath === workflowsDir) return

const items = await window.electron.fs.listDir(workflowsDir)
Expand Down
2 changes: 1 addition & 1 deletion src/areas/setup/FirstRunSetup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function ChoosePathPanel({
}, [defaultPath])

async function handleBrowse() {
const picked = await window.electron.fs.selectDirectory()
const picked = await window.electron.fs.selectDirectory(selectedPath || undefined)
if (picked) setSelectedPath(picked)
}

Expand Down
2 changes: 1 addition & 1 deletion src/shared/types/electron.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ declare global {
selectMeshFile: () => Promise<string | null>
saveModel: (defaultName: string) => Promise<string | null>
readFileBase64: (filePath: string) => Promise<string>
selectDirectory: () => Promise<string | null>
selectDirectory: (defaultPath?: string) => Promise<string | null>
savePath: (args: { filters: { name: string; extensions: string[] }[]; defaultPath?: string }) => Promise<string | null>
listDir: (dirPath: string) => Promise<string[]>
moveDirectory: (args: { src: string; dest: string }) => Promise<{ success: boolean; error?: string }>
Expand Down