fix(workspace): prevent stale placeholder data from corrupting workflow registry on switch#3642
Merged
waleedlatif1 merged 3 commits intostagingfrom Mar 17, 2026
Merged
Conversation
Calls abortAllInProgressTools in the stream_end handler so tools stuck in generating/executing state are resolved when the stream closes, regardless of whether a done event was received. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ow registry on switch - Guard completeMetadataLoad to skip when isPlaceholderData is true, preventing the previous workspace's workflows from briefly populating the registry during switch - Trigger beginMetadataLoad when isPlaceholderData is true to ensure loading state is shown correctly on direct URL navigation (no switchToWorkspace call) - Narrow useCreateWorkspace invalidation from workspaceKeys.all to workspaceKeys.lists() to avoid unnecessary refetches of permissions, settings, and members
|
You have used all Bugbot PR reviews included in your free trial for your GitHub account on this workspace. To continue using Bugbot reviews, enable Bugbot for your team in the Cursor dashboard. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
Greptile SummaryThis PR fixes a race condition where stale placeholder data from the previous workspace briefly populated the workflow registry during workspace switching, and also cleans up two related issues: missing Key changes:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant useWorkflows
participant TanStackQuery as TanStack Query
participant Registry as Workflow Registry
User->>useWorkflows: Switch workspace (workspaceId changes)
Note over TanStackQuery: keepPreviousData kicks in
TanStackQuery-->>useWorkflows: status='success', isPlaceholderData=true (stale data from old workspace)
Note over useWorkflows: BEFORE fix: completeMetadataLoad fires<br/>with stale data → corrupt registry
Note over useWorkflows: AFTER fix:
useWorkflows->>Registry: beginMetadataLoad(newWorkspaceId) [isPlaceholderData=true]
Note over Registry: Loading state shown
TanStackQuery->>TanStackQuery: Fetch new workspace workflows
TanStackQuery-->>useWorkflows: status='success', isPlaceholderData=false (real data)
useWorkflows->>Registry: completeMetadataLoad(newWorkspaceId, realData)
Note over Registry: Registry populated with correct workflows
Last reviewed commit: "fix(workspace): also..." |
Collaborator
Author
|
@greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
keepPreviousDatainuseWorkflowswas causing the previous workspace's workflows to briefly flash when switching workspaces — TanStack Query v5 setsstatus = 'success'andisPlaceholderData = truewhen placeholder data is available, so thecompleteMetadataLoadeffect was firing with stale data from the wrong workspacecompleteMetadataLoadwith!query.isPlaceholderDataso it only populates the registry with real fetched databeginMetadataLoadwhenisPlaceholderDatais true to correctly show loading state on direct URL navigation (whereswitchToWorkspaceis not called)useCreateWorkspaceinvalidation fromworkspaceKeys.alltoworkspaceKeys.lists()— the old code was unnecessarily invalidating permissions, settings, and members for all workspacesType of Change
Testing
Tested manually — workspace switching no longer flashes the previous workspace's content before showing the new one
Checklist