fix(ui): verify initializeProject succeeds before mutating state

Check the return value of initializeProject in all three create handlers
(handleCreateBlankProject, handleCreateFromTemplate, handleCreateFromCustomUrl)
and return early with an error toast if initialization fails, preventing
addProject/setCurrentProject/navigate from being called on failure.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Stefan de Vogelaere
2026-01-23 02:37:10 +01:00
parent fb6d6bbf2f
commit 68d78f2f5b

View File

@@ -129,7 +129,14 @@ export function OverviewView() {
const projectPath = `${parentDir}/${projectName}`;
await api.mkdir(projectPath);
await initializeProject(projectPath);
const initResult = await initializeProject(projectPath);
if (!initResult.success) {
toast.error('Failed to initialize project', {
description: initResult.error || 'Unknown error occurred',
});
return;
}
await api.writeFile(
`${projectPath}/.automaker/app_spec.txt`,
@@ -185,7 +192,13 @@ export function OverviewView() {
return;
}
await initializeProject(cloneResult.projectPath);
const initResult = await initializeProject(cloneResult.projectPath);
if (!initResult.success) {
toast.error('Failed to initialize project', {
description: initResult.error || 'Unknown error occurred',
});
return;
}
const project = {
id: `project-${Date.now()}`,
@@ -228,7 +241,13 @@ export function OverviewView() {
return;
}
await initializeProject(cloneResult.projectPath);
const initResult = await initializeProject(cloneResult.projectPath);
if (!initResult.success) {
toast.error('Failed to initialize project', {
description: initResult.error || 'Unknown error occurred',
});
return;
}
const project = {
id: `project-${Date.now()}`,