feat(FN-682): fix setup wizard race condition and view mode restoration
- Fix setup wizard auto-open race condition in App.tsx\n- Add view mode restoration logic for dashboard navigation\n- Remove 145 lines of unused styles from styles.css\n- Ensure setup wizard opens correctly on fresh installs
This commit is contained in:
@@ -103,20 +103,41 @@ function AppInner() {
|
|||||||
|
|
||||||
// Auto-open setup wizard on first run (no projects)
|
// Auto-open setup wizard on first run (no projects)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!projectsLoading && projects.length === 0 && !setupWizardOpen) {
|
// Wait for both loading states to complete before making decision
|
||||||
// Delay slightly to allow initial render
|
if (projectsLoading || currentProjectLoading) return;
|
||||||
const timer = setTimeout(() => {
|
|
||||||
setSetupWizardOpen(true);
|
// Don't open if wizard is already open
|
||||||
}, 500);
|
if (setupWizardOpen) return;
|
||||||
return () => clearTimeout(timer);
|
|
||||||
}
|
// Don't open if we have projects OR a saved current project
|
||||||
}, [projectsLoading, projects.length, setupWizardOpen]);
|
// (currentProject from localStorage means user was previously viewing a project)
|
||||||
|
if (projects.length > 0 || currentProject) return;
|
||||||
|
|
||||||
|
// Only open when truly no projects exist and no project is being restored
|
||||||
|
const timer = setTimeout(() => {
|
||||||
|
setSetupWizardOpen(true);
|
||||||
|
}, 500);
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
}, [projectsLoading, projects.length, currentProjectLoading, currentProject, setupWizardOpen]);
|
||||||
|
|
||||||
// Persist view mode
|
// Persist view mode
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
localStorage.setItem("kb-dashboard-view-mode", viewMode);
|
localStorage.setItem("kb-dashboard-view-mode", viewMode);
|
||||||
}, [viewMode]);
|
}, [viewMode]);
|
||||||
|
|
||||||
|
// Sync view mode when current project is restored from localStorage
|
||||||
|
// This ensures that if the user refreshed while viewing a specific project,
|
||||||
|
// they return to project view instead of the overview
|
||||||
|
useEffect(() => {
|
||||||
|
// Wait for both loading states to complete before syncing
|
||||||
|
if (projectsLoading || currentProjectLoading) return;
|
||||||
|
|
||||||
|
// If we have a restored current project but viewMode is overview, sync to project view
|
||||||
|
if (currentProject && viewMode === "overview") {
|
||||||
|
setViewMode("project");
|
||||||
|
}
|
||||||
|
}, [projectsLoading, currentProjectLoading, currentProject]); // intentionally NOT depending on viewMode
|
||||||
|
|
||||||
// Persist task view
|
// Persist task view
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
localStorage.setItem("kb-dashboard-task-view", taskView);
|
localStorage.setItem("kb-dashboard-task-view", taskView);
|
||||||
@@ -610,12 +631,12 @@ function AppInner() {
|
|||||||
onClose={handleCloseAgents}
|
onClose={handleCloseAgents}
|
||||||
addToast={addToast}
|
addToast={addToast}
|
||||||
/>
|
/>
|
||||||
<SetupWizardModal
|
{setupWizardOpen && (
|
||||||
isOpen={setupWizardOpen}
|
<SetupWizardModal
|
||||||
onClose={() => setSetupWizardOpen(false)}
|
onProjectRegistered={handleSetupComplete}
|
||||||
onComplete={handleSetupComplete}
|
onClose={() => setSetupWizardOpen(false)}
|
||||||
onRegisterProject={register}
|
/>
|
||||||
/>
|
)}
|
||||||
<ToastContainer toasts={toasts} onRemove={removeToast} />
|
<ToastContainer toasts={toasts} onRemove={removeToast} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user