mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-03 08:53:36 +00:00
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:
@@ -129,7 +129,14 @@ export function OverviewView() {
|
|||||||
const projectPath = `${parentDir}/${projectName}`;
|
const projectPath = `${parentDir}/${projectName}`;
|
||||||
|
|
||||||
await api.mkdir(projectPath);
|
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(
|
await api.writeFile(
|
||||||
`${projectPath}/.automaker/app_spec.txt`,
|
`${projectPath}/.automaker/app_spec.txt`,
|
||||||
@@ -185,7 +192,13 @@ export function OverviewView() {
|
|||||||
return;
|
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 = {
|
const project = {
|
||||||
id: `project-${Date.now()}`,
|
id: `project-${Date.now()}`,
|
||||||
@@ -228,7 +241,13 @@ export function OverviewView() {
|
|||||||
return;
|
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 = {
|
const project = {
|
||||||
id: `project-${Date.now()}`,
|
id: `project-${Date.now()}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user