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.
This commit is contained in:
@@ -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 */}
|
||||
<Dialog open={showInitDialog} onOpenChange={(open) => {
|
||||
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();
|
||||
}
|
||||
}}>
|
||||
|
||||
@@ -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({
|
||||
</div>
|
||||
|
||||
{/* Initialize Auto Claude Dialog */}
|
||||
<Dialog open={showInitDialog} onOpenChange={setShowInitDialog}>
|
||||
<Dialog open={showInitDialog} onOpenChange={(open) => {
|
||||
// Only allow closing if user manually closes (not during initialization)
|
||||
if (!open && !isInitializing) {
|
||||
handleSkipInit();
|
||||
}
|
||||
}}>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle className="flex items-center gap-2">
|
||||
|
||||
Reference in New Issue
Block a user