feat(agent): support aborting agent execution in local and temporal modes

This commit is contained in:
yiling
2026-07-14 10:25:06 +08:00
parent e772581542
commit 8a942d4f4e
15 changed files with 428 additions and 39 deletions
+20
View File
@@ -43,6 +43,7 @@ interface ChatbotState {
projectId: string,
contextAssetId?: string,
) => Promise<void>
abortActiveSession: (teamId: string) => Promise<void>
}
export const useChatbotStore = create<ChatbotState>((set) => ({
@@ -303,4 +304,23 @@ export const useChatbotStore = create<ChatbotState>((set) => ({
set({ isStreaming: false })
}
},
abortActiveSession: async (teamId) => {
const { currentSessionId, isStreaming } = useChatbotStore.getState()
if (!currentSessionId || !isStreaming) return
try {
const res = await client.api.teams[':teamId'].chat.sessions[':sessionId'].abort.$post({
param: { teamId, sessionId: currentSessionId },
})
if (res.ok) {
toast.success('Agent execution stopped')
} else {
throw new Error('Failed to abort agent execution')
}
} catch (err) {
const errMsg = err instanceof Error ? err.message : 'Failed to abort execution'
toast.error(errMsg)
}
},
}))