diff --git a/src/App.tsx b/src/App.tsx index 2f428ea9e..29281535c 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -196,9 +196,21 @@ function MainApp() { }); async function handleAddWorkspace() { - const workspace = await addWorkspace(); - if (workspace) { - setActiveThreadId(null, workspace.id); + try { + const workspace = await addWorkspace(); + if (workspace) { + setActiveThreadId(null, workspace.id); + } + } catch (error) { + const message = error instanceof Error ? error.message : String(error); + addDebugEntry({ + id: `${Date.now()}-client-add-workspace-error`, + timestamp: Date.now(), + source: "error", + label: "workspace/add error", + payload: message, + }); + alert(`Failed to add workspace.\n\n${message}`); } } diff --git a/src/services/tauri.ts b/src/services/tauri.ts index de9146b28..6789e45a0 100644 --- a/src/services/tauri.ts +++ b/src/services/tauri.ts @@ -5,9 +5,12 @@ import type { GitFileDiff, GitFileStatus, GitLogResponse, ReviewTarget } from ". export async function pickWorkspacePath(): Promise { const selection = await open({ directory: true, multiple: false }); - if (!selection || Array.isArray(selection)) { + if (!selection) { return null; } + if (Array.isArray(selection)) { + return selection[0] ?? null; + } return selection; }