mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
fix(workspace): prevent stale placeholder data from corrupting workflow registry on switch
This commit is contained in:
@@ -113,10 +113,15 @@ 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 (
|
||||
@@ -124,11 +129,20 @@ export function useWorkflows(
|
||||
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') {
|
||||
|
||||
@@ -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() })
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
@@ -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)
|
||||
@@ -967,6 +968,7 @@ export const sseHandlers: Record<string, SSEHandler> = {
|
||||
}
|
||||
finalizeThinkingBlock(context)
|
||||
updateStreamingMessage(set, context)
|
||||
abortAllInProgressTools(set, get)
|
||||
},
|
||||
default: () => {},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user