From 56cedec2ae94ac3f8a9091e2e338b7b01eb5e61f Mon Sep 17 00:00:00 2001 From: AndyMik90 Date: Fri, 19 Dec 2025 01:23:56 +0100 Subject: [PATCH] fix: prevent dialog skip during project initialization - Added checks to ensure the initialization dialog does not trigger skip logic while a project is being initialized. - Refactored project ID handling in the initialization process for consistency across components. - Improved user experience by preventing unintended dialog closures during initialization. This change enhances the reliability of the project initialization workflow in the application. --- auto-claude-ui/src/renderer/App.tsx | 16 ++++++++++++---- .../src/renderer/components/Sidebar.tsx | 14 +++++++++++--- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/auto-claude-ui/src/renderer/App.tsx b/auto-claude-ui/src/renderer/App.tsx index d2b18284..c1d0422f 100644 --- a/auto-claude-ui/src/renderer/App.tsx +++ b/auto-claude-ui/src/renderer/App.tsx @@ -130,12 +130,15 @@ export function App() { // Check if selected project needs initialization (e.g., .auto-claude folder was deleted) useEffect(() => { + // Don't show dialog while initialization is in progress + if (isInitializing) return; + if (selectedProject && !selectedProject.autoBuildPath && skippedInitProjectId !== selectedProject.id) { // Project exists but isn't initialized - show init dialog setPendingProject(selectedProject); setShowInitDialog(true); } - }, [selectedProject, skippedInitProjectId]); + }, [selectedProject, skippedInitProjectId, isInitializing]); // Load tasks when project changes useEffect(() => { @@ -235,12 +238,15 @@ export function App() { const handleInitialize = async () => { if (!pendingProject) return; + const projectId = pendingProject.id; setIsInitializing(true); try { - const result = await initializeProject(pendingProject.id); + const result = await initializeProject(projectId); if (result?.success) { - setShowInitDialog(false); + // Clear pendingProject FIRST before closing dialog + // This prevents onOpenChange from triggering skip logic setPendingProject(null); + setShowInitDialog(false); } } finally { setIsInitializing(false); @@ -417,7 +423,9 @@ export function App() { {/* Initialize Auto Claude Dialog */} { - if (!open) { + // Only trigger skip if user manually closed the dialog + // Don't trigger if pendingProject is null (successful init) or if initializing + if (!open && pendingProject && !isInitializing) { handleSkipInit(); } }}> diff --git a/auto-claude-ui/src/renderer/components/Sidebar.tsx b/auto-claude-ui/src/renderer/components/Sidebar.tsx index 75b05965..cf3aa6d1 100644 --- a/auto-claude-ui/src/renderer/components/Sidebar.tsx +++ b/auto-claude-ui/src/renderer/components/Sidebar.tsx @@ -199,12 +199,15 @@ export function Sidebar({ const handleInitialize = async () => { if (!pendingProject) return; + const projectId = pendingProject.id; setIsInitializing(true); try { - const result = await initializeProject(pendingProject.id); + const result = await initializeProject(projectId); if (result?.success) { - setShowInitDialog(false); + // Clear pendingProject FIRST before closing dialog + // This prevents onOpenChange from triggering skip logic setPendingProject(null); + setShowInitDialog(false); } } finally { setIsInitializing(false); @@ -474,7 +477,12 @@ export function Sidebar({ {/* Initialize Auto Claude Dialog */} - + { + // Only allow closing if user manually closes (not during initialization) + if (!open && !isInitializing) { + handleSkipInit(); + } + }}>