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)
|
// Check if selected project needs initialization (e.g., .auto-claude folder was deleted)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
// Don't show dialog while initialization is in progress
|
||||||
|
if (isInitializing) return;
|
||||||
|
|
||||||
if (selectedProject && !selectedProject.autoBuildPath && skippedInitProjectId !== selectedProject.id) {
|
if (selectedProject && !selectedProject.autoBuildPath && skippedInitProjectId !== selectedProject.id) {
|
||||||
// Project exists but isn't initialized - show init dialog
|
// Project exists but isn't initialized - show init dialog
|
||||||
setPendingProject(selectedProject);
|
setPendingProject(selectedProject);
|
||||||
setShowInitDialog(true);
|
setShowInitDialog(true);
|
||||||
}
|
}
|
||||||
}, [selectedProject, skippedInitProjectId]);
|
}, [selectedProject, skippedInitProjectId, isInitializing]);
|
||||||
|
|
||||||
// Load tasks when project changes
|
// Load tasks when project changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -235,12 +238,15 @@ export function App() {
|
|||||||
const handleInitialize = async () => {
|
const handleInitialize = async () => {
|
||||||
if (!pendingProject) return;
|
if (!pendingProject) return;
|
||||||
|
|
||||||
|
const projectId = pendingProject.id;
|
||||||
setIsInitializing(true);
|
setIsInitializing(true);
|
||||||
try {
|
try {
|
||||||
const result = await initializeProject(pendingProject.id);
|
const result = await initializeProject(projectId);
|
||||||
if (result?.success) {
|
if (result?.success) {
|
||||||
setShowInitDialog(false);
|
// Clear pendingProject FIRST before closing dialog
|
||||||
|
// This prevents onOpenChange from triggering skip logic
|
||||||
setPendingProject(null);
|
setPendingProject(null);
|
||||||
|
setShowInitDialog(false);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
setIsInitializing(false);
|
setIsInitializing(false);
|
||||||
@@ -417,7 +423,9 @@ export function App() {
|
|||||||
|
|
||||||
{/* Initialize Auto Claude Dialog */}
|
{/* Initialize Auto Claude Dialog */}
|
||||||
<Dialog open={showInitDialog} onOpenChange={(open) => {
|
<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();
|
handleSkipInit();
|
||||||
}
|
}
|
||||||
}}>
|
}}>
|
||||||
|
|||||||
@@ -199,12 +199,15 @@ export function Sidebar({
|
|||||||
const handleInitialize = async () => {
|
const handleInitialize = async () => {
|
||||||
if (!pendingProject) return;
|
if (!pendingProject) return;
|
||||||
|
|
||||||
|
const projectId = pendingProject.id;
|
||||||
setIsInitializing(true);
|
setIsInitializing(true);
|
||||||
try {
|
try {
|
||||||
const result = await initializeProject(pendingProject.id);
|
const result = await initializeProject(projectId);
|
||||||
if (result?.success) {
|
if (result?.success) {
|
||||||
setShowInitDialog(false);
|
// Clear pendingProject FIRST before closing dialog
|
||||||
|
// This prevents onOpenChange from triggering skip logic
|
||||||
setPendingProject(null);
|
setPendingProject(null);
|
||||||
|
setShowInitDialog(false);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
setIsInitializing(false);
|
setIsInitializing(false);
|
||||||
@@ -474,7 +477,12 @@ export function Sidebar({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Initialize Auto Claude Dialog */}
|
{/* 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>
|
<DialogContent>
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle className="flex items-center gap-2">
|
<DialogTitle className="flex items-center gap-2">
|
||||||
|
|||||||
Reference in New Issue
Block a user