Elffuss BraidHub

kikocis/continue public

8eb3ae7b8d16 · 859 BRawPermalink
1import { createAsyncThunk } from "@reduxjs/toolkit";
2import posthog from "posthog-js";
3import { cancelToolCall as cancelToolCallAction } from "../slices/sessionSlice";
4import { ThunkApiType } from "../store";
5import { findToolCallById } from "../util";
6
7export const cancelToolCallThunk = createAsyncThunk<
8 void,
9 { toolCallId: string },
10 ThunkApiType
11>("chat/cancelToolCall", async ({ toolCallId }, { dispatch, getState }) => {
12 const state = getState();
13 const toolCallState = findToolCallById(state.session.history, toolCallId);
14
15 if (toolCallState) {
16 // Track tool call rejection
17 posthog.capture("gui_tool_call_decision", {
18 decision: "reject",
19 toolName: toolCallState.toolCall.function.name,
20 toolCallId: toolCallId,
21 });
22 }
23
24 // Dispatch the actual cancel action
25 dispatch(cancelToolCallAction({ toolCallId }));
26});