fix(shell): surface project IPC failures and AI settings save/test errors (#156)

ProjectPanel's createProject/renameProject/deleteProject calls had no error handling: an IPC rejection (disk error, permission denied) produced an unhandled rejection, onRefresh never ran, and the optimistic UI state was already cleared — the project silently didn't appear/rename/delete. SettingsModal's save() left dirty=true forever on failure with no feedback, and test() dropped rejections leaving the status pill blank. Add try/catch with window.alert for project ops (matching the sibling file-rename pattern) and .catch handlers that surface errors in the existing UI.

Co-authored-by: Aniruddha Adak <aniruddhaadak80@users.noreply.github.com>
This commit is contained in:
ANIRUDDHA ADAK
2026-08-26 14:34:26 +08:00
committed by GitHub
co-authored by Aniruddha Adak
parent 7eb5d59b59
commit 9711a4507c
2 changed files with 31 additions and 8 deletions
+18 -3
View File
@@ -194,7 +194,12 @@ function ProjectPanel({ projects, selectedId, onSelect, onRefresh }: ProjectPane
setCreating(false)
setNewName('')
if (!name) return
await window.aiOfficeProject?.createProject(name)
try {
await window.aiOfficeProject?.createProject(name)
} catch (error) {
window.alert(error instanceof Error ? error.message : String(error))
return
}
onRefresh()
}
@@ -204,7 +209,12 @@ function ProjectPanel({ projects, selectedId, onSelect, onRefresh }: ProjectPane
const id = renaming.id
setRenaming(null)
if (!name) return
await window.aiOfficeProject?.renameProject(id, name)
try {
await window.aiOfficeProject?.renameProject(id, name)
} catch (error) {
window.alert(error instanceof Error ? error.message : String(error))
return
}
onRefresh()
}
@@ -220,7 +230,12 @@ function ProjectPanel({ projects, selectedId, onSelect, onRefresh }: ProjectPane
const id = confirmDeleteId
setConfirmDeleteId(null)
if (!id) return
await window.aiOfficeProject?.deleteProject(id)
try {
await window.aiOfficeProject?.deleteProject(id)
} catch (error) {
window.alert(error instanceof Error ? error.message : String(error))
return
}
if (selectedId === id) onSelect(null)
onRefresh()
}
+13 -5
View File
@@ -204,17 +204,25 @@ function AiModelPane({ t }: { t: TFunc }) {
touch()
}
const save = () => {
void window.aiOffice.setAiSettings?.(settings).then(() => {
setDirty(false)
setSaved(true)
})
window.aiOffice
.setAiSettings?.(settings)
.then(() => {
setDirty(false)
setSaved(true)
})
.catch((error) => {
window.alert(error instanceof Error ? error.message : String(error))
})
}
const test = () => {
setTesting(true)
setTestResult(null)
void window.aiOffice
window.aiOffice
.testAiSettings?.(settings)
.then((r) => setTestResult(r ?? { ok: false }))
.catch((error) =>
setTestResult({ ok: false, error: error instanceof Error ? error.message : String(error) }),
)
.finally(() => setTesting(false))
}