mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-28 09:23:08 +08:00
fix(frontend): resolve URL path inconsistency caused by localStorage race condition
Fixed the issue where accessing the React frontend via ccw view with a URL path parameter would load a different workspace due to localStorage rehydration race condition. Root cause: zustand persist's onRehydrateStorage callback automatically called switchWorkspace with the cached projectPath before AppShell could process the URL parameter. Changes: - workflowStore.ts: Remove automatic switchWorkspace from onRehydrateStorage - AppShell.tsx: Centralize initialization logic with clear priority order: * Priority 1: URL ?path= parameter (explicit user intent) * Priority 2: localStorage fallback (implicit cache) * Added isWorkspaceInitialized state lock to prevent duplicate execution Fixes: URL showing ?path=/new/path but loading /old/path from cache
This commit is contained in:
@@ -541,14 +541,10 @@ export const useWorkflowStore = create<WorkflowStore>()(
|
||||
if (state?.projectPath) {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('[WorkflowStore] Found persisted projectPath, re-initializing workspace:', state.projectPath);
|
||||
console.log('[WorkflowStore] Rehydrated with persisted projectPath:', state.projectPath);
|
||||
}
|
||||
// Use setTimeout to ensure the store is fully initialized before calling switchWorkspace
|
||||
setTimeout(() => {
|
||||
if (state.switchWorkspace) {
|
||||
state.switchWorkspace(state.projectPath);
|
||||
}
|
||||
}, 0);
|
||||
// The initialization logic is now handled by AppShell.tsx
|
||||
// to correctly prioritize URL parameters over localStorage.
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user