File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed
app/workspace/[workspaceId]/home/hooks Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,22 @@ function isActiveStreamConflictError(input: unknown): boolean {
147147 return input . includes ( 'A response is already in progress for this chat' )
148148}
149149
150+ /**
151+ * Extracts tool call IDs from snapshot events so that replayed client-executable
152+ * tool calls are not re-executed after a page refresh.
153+ */
154+ function extractToolCallIdsFromSnapshot ( snapshot ?: StreamSnapshot | null ) : Set < string > {
155+ const ids = new Set < string > ( )
156+ if ( ! snapshot ?. events ) return ids
157+ for ( const entry of snapshot . events ) {
158+ const event = entry . event
159+ if ( event . type === 'tool_call' && typeof event . toolCallId === 'string' ) {
160+ ids . add ( event . toolCallId )
161+ }
162+ }
163+ return ids
164+ }
165+
150166function buildReplayStream ( events : StreamEventEnvelope [ ] ) : ReadableStream < Uint8Array > {
151167 const encoder = new TextEncoder ( )
152168 return new ReadableStream < Uint8Array > ( {
@@ -860,7 +876,7 @@ export function useChat(
860876 sendingRef . current = true
861877 streamingContentRef . current = ''
862878 streamingBlocksRef . current = [ ]
863- clientExecutionStartedRef . current . clear ( )
879+ clientExecutionStartedRef . current = extractToolCallIdsFromSnapshot ( snapshot )
864880
865881 const assistantId = crypto . randomUUID ( )
866882
Original file line number Diff line number Diff line change @@ -21,7 +21,6 @@ import { useWorkflowDiffStore } from '@/stores/workflow-diff/store'
2121import { captureBaselineSnapshot } from '@/stores/workflow-diff/utils'
2222import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
2323import type { WorkflowState } from '@/stores/workflows/workflow/types'
24- import { executeRunToolOnClient } from './run-tool-execution'
2524import type { ClientContentBlock , ClientStreamingContext } from './types'
2625
2726const logger = createLogger ( 'CopilotClientSseHandlers' )
@@ -988,10 +987,6 @@ export const sseHandlers: Record<string, SSEHandler> = {
988987 return
989988 }
990989
991- if ( clientExecutable && initialState === ClientToolCallState . executing ) {
992- executeRunToolOnClient ( id , toolName , args || existing ?. params || { } )
993- }
994-
995990 if ( toolName === 'oauth_request_access' && args && typeof window !== 'undefined' ) {
996991 try {
997992 window . dispatchEvent (
You can’t perform that action at this time.
0 commit comments