From 6f04c48c31d1022513984be0276d52bc30df68f7 Mon Sep 17 00:00:00 2001 From: Siddharth Ganesan Date: Thu, 9 Apr 2026 13:01:49 -0700 Subject: [PATCH] tool joining --- .../[workspaceId]/home/hooks/use-chat.ts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts b/apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts index be5b1f311d..d99bbee05c 100644 --- a/apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts +++ b/apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts @@ -354,6 +354,7 @@ export function useChat( streamingFileRef.current = streamingFile const filePreviewSessionsRef = useRef>(new Map()) const activeFilePreviewToolCallIdRef = useRef(null) + const editContentParentToolCallIdRef = useRef>(new Map()) const [messageQueue, setMessageQueue] = useState([]) const messageQueueRef = useRef([]) @@ -527,6 +528,7 @@ export function useChat( streamingFileRef.current = null filePreviewSessionsRef.current.clear() activeFilePreviewToolCallIdRef.current = null + editContentParentToolCallIdRef.current.clear() setMessageQueue([]) }, [initialChatId, queryClient]) @@ -550,6 +552,7 @@ export function useChat( streamingFileRef.current = null filePreviewSessionsRef.current.clear() activeFilePreviewToolCallIdRef.current = null + editContentParentToolCallIdRef.current.clear() setMessageQueue([]) }, [isHomePage]) @@ -1024,6 +1027,10 @@ export function useChat( sessions.set(id, nextSession) activeFilePreviewToolCallIdRef.current = id streamingFileRef.current = nextSession + const previewToolIdx = toolMap.get(id) + if (previewToolIdx !== undefined && blocks[previewToolIdx].toolCall) { + blocks[previewToolIdx].toolCall!.status = 'executing' + } setStreamingFile(nextSession) break } @@ -1233,6 +1240,7 @@ export function useChat( setResources((rs) => rs.filter((r) => r.id !== 'streaming-file')) } } + editContentParentToolCallIdRef.current.delete(id) break } @@ -1280,6 +1288,25 @@ export function useChat( } } + if (name === 'edit_content') { + const parentToolCallId = + activeFilePreviewToolCallIdRef.current ?? streamingFileRef.current?.toolCallId + const parentIdx = + parentToolCallId !== null && parentToolCallId !== undefined + ? toolMap.get(parentToolCallId) + : undefined + if (parentIdx !== undefined && blocks[parentIdx].toolCall) { + toolMap.set(id, parentIdx) + editContentParentToolCallIdRef.current.set(id, parentToolCallId!) + const tc = blocks[parentIdx].toolCall! + tc.status = 'executing' + tc.result = undefined + tc.error = undefined + flush() + break + } + } + if (!toolMap.has(id)) { toolMap.set(id, blocks.length) blocks.push({ @@ -2098,6 +2125,7 @@ export function useChat( streamingFileRef.current = null filePreviewSessionsRef.current.clear() activeFilePreviewToolCallIdRef.current = null + editContentParentToolCallIdRef.current.clear() setResources((rs) => rs.filter((resource) => resource.id !== 'streaming-file')) const execState = useExecutionStore.getState()