mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-31 06:42:03 +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}`;
|
||||
|
||||
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()}`,
|
||||
|
||||
Reference in New Issue
Block a user