From 8764954282099c17327b51d76c98d27b5d5b6c81 Mon Sep 17 00:00:00 2001 From: Vikhyath Mondreti Date: Thu, 26 Jun 2025 19:58:27 -0700 Subject: [PATCH] Revert "fix switch workspace bug (#560)" (#563) This reverts commit 0fb2f7c44ef8113ae43f6668f30d2ddc48b2ffc6. --- .../workspace-header/workspace-header.tsx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workspace-header/workspace-header.tsx b/apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workspace-header/workspace-header.tsx index 152306206f..4ffc0ba6de 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workspace-header/workspace-header.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workspace-header/workspace-header.tsx @@ -343,11 +343,11 @@ export const WorkspaceHeader = React.memo( setActiveWorkspace(workspace) setWorkspaceDropdownOpen(false) - // 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 + // Use full workspace switch which now handles localStorage automatically switchToWorkspace(workspace.id) + + // Update URL to include workspace ID + router.push(`/workspace/${workspace.id}/w`) }, [activeWorkspace?.id, switchToWorkspace, router, setWorkspaceDropdownOpen] ) @@ -372,11 +372,12 @@ export const WorkspaceHeader = React.memo( setWorkspaces((prev) => [...prev, newWorkspace]) setActiveWorkspace(newWorkspace) - // 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 + // 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 + router.push(`/workspace/${newWorkspace.id}/w`) } } catch (err) { logger.error('Error creating workspace:', err)