fix switch workspace bug (#560)

Co-authored-by: Vikhyath Mondreti <vikhyathmondreti@Vikhyaths-Air.attlocal.net>
This commit is contained in:
Vikhyath Mondreti
2025-06-26 18:44:06 -07:00
committed by GitHub
parent 1a719470b8
commit 0fb2f7c44e

View File

@@ -343,11 +343,11 @@ export const WorkspaceHeader = React.memo<WorkspaceHeaderProps>(
setActiveWorkspace(workspace)
setWorkspaceDropdownOpen(false)
// Use full workspace switch which now handles localStorage automatically
switchToWorkspace(workspace.id)
// Update URL to include workspace ID
// Update URL first so sidebar filters use the new workspace ID
router.push(`/workspace/${workspace.id}/w`)
// Then switch workspace which will clear workflows and fetch new ones
switchToWorkspace(workspace.id)
},
[activeWorkspace?.id, switchToWorkspace, router, setWorkspaceDropdownOpen]
)
@@ -372,12 +372,11 @@ export const WorkspaceHeader = React.memo<WorkspaceHeaderProps>(
setWorkspaces((prev) => [...prev, newWorkspace])
setActiveWorkspace(newWorkspace)
// Use switchToWorkspace to properly load workflows for the new workspace
// This will clear existing workflows, set loading state, and fetch workflows from DB
switchToWorkspace(newWorkspace.id)
// Update URL to include new workspace ID
// Update URL first so sidebar filters use the new workspace ID
router.push(`/workspace/${newWorkspace.id}/w`)
// Then switch workspace which will clear workflows and fetch new ones
switchToWorkspace(newWorkspace.id)
}
} catch (err) {
logger.error('Error creating workspace:', err)