@@ -194,12 +194,19 @@ export function handleResourceEvent(ctx: StreamLoopContext, parsed: ResourceEven
194194 if ( owner ?. entityType === 'project' && payload . resource . type === 'file' && payload . resource . id )
195195 invalidateProjectFileQueries ( queryClient , owner . entityId , payload . resource . id )
196196 const workspaceId = payload . resource . workspaceId ?? chatWorkspaceId
197- if ( ! workspaceId || ( chatWorkspaceId && workspaceId !== chatWorkspaceId ) ) return
197+ /** A Project file names no workspace, so an organization chat has none to check it against. */
198+ if (
199+ workspaceId
200+ ? chatWorkspaceId && workspaceId !== chatWorkspaceId
201+ : owner ?. entityType !== 'project'
202+ )
203+ return
198204 // Browser and terminal tabs are projected from the desktop app's live
199205 // lists, never from the stream; older servers announced them as resources.
200206 if ( payload . resource . type === 'browser' || payload . resource . type === 'terminal' ) return
201207 const resourceType = payload . resource . type
202- invalidateResourceQueries ( queryClient , workspaceId , resourceType , payload . resource . id )
208+ if ( workspaceId )
209+ invalidateResourceQueries ( queryClient , workspaceId , resourceType , payload . resource . id )
203210 if ( resourceType === 'workflow' && payload . op !== 'remove' && payload . resource . id ) {
204211 notifyWorkflowExternalUpdate ( payload . resource . id )
205212 }
@@ -246,7 +253,7 @@ export function handleResourceEvent(ctx: StreamLoopContext, parsed: ResourceEven
246253 : undefined
247254 const resource : MothershipResource = {
248255 ...payload . resource ,
249- ...( chatWorkspaceId ? { } : { workspaceId } ) ,
256+ ...( ! chatWorkspaceId && workspaceId ? { workspaceId } : { } ) ,
250257 type : payload . resource . type as MothershipResourceType ,
251258 title :
252259 typeof payload . resource . title === 'string' ? payload . resource . title : payload . resource . id ,
@@ -264,7 +271,7 @@ export function handleResourceEvent(ctx: StreamLoopContext, parsed: ResourceEven
264271 current === getChatResourceSelectionId ( resource ) ? null : current
265272 )
266273 } else removeResource ( resource )
267- if ( resourceType === 'workflow' ) {
274+ if ( resourceType === 'workflow' && workspaceId ) {
268275 removeWorkflowFromActiveCache ( queryClient , workspaceId , resource . id )
269276 }
270277 return
@@ -352,7 +359,7 @@ export function handleResourceEvent(ctx: StreamLoopContext, parsed: ResourceEven
352359 } else onResourceEvent ?.( getChatResourceSelectionId ( resource ) )
353360 }
354361
355- if ( resource . type === 'workflow' ) {
362+ if ( resource . type === 'workflow' && workspaceId ) {
356363 ensureWorkflowInRegistry ( resource . id , resource . title , workspaceId )
357364 }
358365}
0 commit comments