Skip to content

Commit c260487

Browse files
author
Theodore Li
committed
Fix so run workflow switches tabs as well
1 parent 494f20e commit c260487

File tree

1 file changed

+8
-8
lines changed
  • apps/sim/app/workspace/[workspaceId]/home/hooks

1 file changed

+8
-8
lines changed

apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -657,15 +657,15 @@ export function useChat(
657657
: useWorkflowRegistry.getState().activeWorkflowId
658658
if (targetWorkflowId) {
659659
const meta = useWorkflowRegistry.getState().workflows[targetWorkflowId]
660-
if (
661-
addResource({
662-
type: 'workflow',
663-
id: targetWorkflowId,
664-
title: meta?.name ?? 'Workflow',
665-
})
666-
) {
667-
onResourceEventRef.current?.()
660+
const wasAdded = addResource({
661+
type: 'workflow',
662+
id: targetWorkflowId,
663+
title: meta?.name ?? 'Workflow',
664+
})
665+
if (!wasAdded && activeResourceIdRef.current !== targetWorkflowId) {
666+
setActiveResourceId(targetWorkflowId)
668667
}
668+
onResourceEventRef.current?.()
669669
}
670670
executeRunToolOnClient(id, name, args as Record<string, unknown>)
671671
}

0 commit comments

Comments
 (0)