mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-03-06 16:31:12 +08:00
fix: wait for zustand hydration before workspace initialization
Fix blank page on first load via `ccw view` by waiting for zustand persist hydration to complete before initializing workspace. - Add _hasHydrated state tracking in workflowStore - Add setHasHydrated action to mark hydration complete - Update AppShell to wait for hydration before calling switchWorkspace - Ensures projectPath is properly restored from localStorage before queries execute
This commit is contained in:
@@ -40,15 +40,23 @@ export function AppShell({
|
||||
// Workspace initialization from URL query parameter
|
||||
const switchWorkspace = useWorkflowStore((state) => state.switchWorkspace);
|
||||
const projectPath = useWorkflowStore((state) => state.projectPath);
|
||||
const hasHydrated = useWorkflowStore((state) => state._hasHydrated);
|
||||
const location = useLocation();
|
||||
|
||||
// Immersive mode (fullscreen) - hide chrome
|
||||
const isImmersiveMode = useAppStore(selectIsImmersiveMode);
|
||||
|
||||
// Workspace initialization logic (URL > localStorage)
|
||||
// Wait for zustand persist hydration to complete before initializing
|
||||
const [isWorkspaceInitialized, setWorkspaceInitialized] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
// Wait for hydration to complete before initializing workspace
|
||||
// This ensures projectPath is properly restored from localStorage
|
||||
if (!hasHydrated) {
|
||||
return;
|
||||
}
|
||||
|
||||
// This effect should only run once to decide the initial workspace.
|
||||
if (isWorkspaceInitialized) {
|
||||
return;
|
||||
@@ -76,7 +84,7 @@ export function AppShell({
|
||||
|
||||
// Mark as initialized regardless of whether a path was found.
|
||||
setWorkspaceInitialized(true);
|
||||
}, [isWorkspaceInitialized, projectPath, location.search, switchWorkspace]);
|
||||
}, [hasHydrated, isWorkspaceInitialized, projectPath, location.search, switchWorkspace]);
|
||||
|
||||
// Sidebar collapse state – default to collapsed (hidden)
|
||||
const [sidebarCollapsed, setSidebarCollapsed] = useState(() => {
|
||||
|
||||
Reference in New Issue
Block a user