Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(workspace): prevent stale placeholder data from corrupting workfl…
…ow registry on switch
  • Loading branch information
waleedlatif1 authored Mar 17, 2026
commit 75a3e2c3a813390aa3e6086723a78169d0336336
22 changes: 18 additions & 4 deletions apps/sim/hooks/queries/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,36 @@ export function useWorkflows(
})

useEffect(() => {
if (syncRegistry && scope === 'active' && workspaceId && query.status === 'pending') {
if (
syncRegistry &&
scope === 'active' &&
workspaceId &&
(query.status === 'pending' || query.isPlaceholderData)
) {
beginMetadataLoad(workspaceId)
}
}, [syncRegistry, scope, workspaceId, query.status, beginMetadataLoad])
}, [syncRegistry, scope, workspaceId, query.status, query.isPlaceholderData, beginMetadataLoad])

useEffect(() => {
if (
syncRegistry &&
scope === 'active' &&
workspaceId &&
query.status === 'success' &&
query.data
query.data &&
!query.isPlaceholderData
) {
completeMetadataLoad(workspaceId, query.data)
}
}, [syncRegistry, scope, workspaceId, query.status, query.data, completeMetadataLoad])
}, [
syncRegistry,
scope,
workspaceId,
query.status,
query.data,
query.isPlaceholderData,
completeMetadataLoad,
])

useEffect(() => {
if (syncRegistry && scope === 'active' && workspaceId && query.status === 'error') {
Expand Down
11 changes: 3 additions & 8 deletions apps/sim/hooks/queries/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,9 @@ export function useCreateWorkspace() {
const data = await response.json()
return data.workspace as Workspace
},
onSuccess: (data) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.all })
if (data?.id) {
queryClient.removeQueries({ queryKey: workspaceKeys.detail(data.id) })
queryClient.removeQueries({ queryKey: workspaceKeys.settings(data.id) })
queryClient.removeQueries({ queryKey: workspaceKeys.permissions(data.id) })
queryClient.removeQueries({ queryKey: workspaceKeys.members(data.id) })
}
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.lists() })
queryClient.invalidateQueries({ queryKey: workspaceKeys.adminLists() })
},
})
}
Expand Down
4 changes: 3 additions & 1 deletion apps/sim/lib/copilot/client-sse/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { STREAM_STORAGE_KEY } from '@/lib/copilot/constants'
import { asRecord } from '@/lib/copilot/orchestrator/sse/utils'
import type { SSEEvent } from '@/lib/copilot/orchestrator/types'
import {
abortAllInProgressTools,
isBackgroundState,
isRejectedState,
isReviewState,
Expand Down Expand Up @@ -956,7 +957,7 @@ export const sseHandlers: Record<string, SSEHandler> = {
}))
context.streamComplete = true
},
stream_end: (_data, context, _get, set) => {
stream_end: (_data, context, get, set) => {
if (context.pendingContent) {
if (context.isInThinkingBlock && context.currentThinkingBlock) {
appendThinkingContent(context, context.pendingContent)
Expand All @@ -967,6 +968,7 @@ export const sseHandlers: Record<string, SSEHandler> = {
}
finalizeThinkingBlock(context)
updateStreamingMessage(set, context)
abortAllInProgressTools(set, get)
},
default: () => {},
}
Loading