Skip to content

Commit f115836

Browse files
authored
fix(tool confirmation): chat should continue if the user denies the tool use. (#554)
* fix(tool confirmation): chat should continue if the user denies the tool use. * fix: remove unused import.
1 parent 21f2d45 commit f115836

File tree

2 files changed

+13
-30
lines changed

2 files changed

+13
-30
lines changed

refact-agent/gui/src/components/ChatForm/ToolConfirmation.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback, useMemo } from "react";
1+
import React, { useMemo } from "react";
22
import {
33
PATCH_LIKE_FUNCTIONS,
44
useAppDispatch,
@@ -88,10 +88,6 @@ export const ToolConfirmation: React.FC<ToolConfirmationProps> = ({
8888
confirmToolUsage();
8989
};
9090

91-
const handleReject = useCallback(() => {
92-
rejectToolUsage(toolCallIds);
93-
}, [rejectToolUsage, toolCallIds]);
94-
9591
const message = getConfirmationMessage(
9692
commands,
9793
rules,
@@ -105,7 +101,7 @@ export const ToolConfirmation: React.FC<ToolConfirmationProps> = ({
105101
return (
106102
<PatchConfirmation
107103
handleAllowForThisChat={handleAllowForThisChat}
108-
rejectToolUsage={handleReject}
104+
rejectToolUsage={rejectToolUsage}
109105
confirmToolUsage={confirmToolUsage}
110106
/>
111107
);
@@ -171,7 +167,7 @@ export const ToolConfirmation: React.FC<ToolConfirmationProps> = ({
171167
color="red"
172168
variant="surface"
173169
size="1"
174-
onClick={handleReject}
170+
onClick={rejectToolUsage}
175171
>
176172
Stop
177173
</Button>

refact-agent/gui/src/hooks/useSendChatRequest.ts

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,9 @@ import {
5050
setChatMode,
5151
setIsWaitingForResponse,
5252
setLastUserMessageId,
53-
upsertToolCall,
5453
} from "../features/Chat";
5554

5655
import { v4 as uuidv4 } from "uuid";
57-
import { upsertToolCallIntoHistory } from "../features/History/historySlice";
5856

5957
type SubmitHandlerParams =
6058
| {
@@ -321,27 +319,16 @@ export const useSendChatRequest = () => {
321319
dispatch(setIsWaitingForResponse(false));
322320
}, [abort, dispatch]);
323321

324-
const rejectToolUsage = useCallback(
325-
(toolCallIds: string[]) => {
326-
abort();
327-
328-
toolCallIds.forEach((toolCallId) => {
329-
dispatch(
330-
upsertToolCallIntoHistory({ toolCallId, chatId, accepted: false }),
331-
);
332-
dispatch(upsertToolCall({ toolCallId, chatId, accepted: false }));
333-
});
334-
335-
dispatch(
336-
clearPauseReasonsAndHandleToolsStatus({
337-
wasInteracted: true,
338-
confirmationStatus: false,
339-
}),
340-
);
341-
dispatch(setIsWaitingForResponse(false));
342-
},
343-
[abort, chatId, dispatch],
344-
);
322+
const rejectToolUsage = useCallback(() => {
323+
abort();
324+
dispatch(
325+
clearPauseReasonsAndHandleToolsStatus({
326+
wasInteracted: true,
327+
confirmationStatus: false,
328+
}),
329+
);
330+
dispatch(setIsWaitingForResponse(false));
331+
}, [abort, dispatch]);
345332

346333
const retryFromIndex = useCallback(
347334
(index: number, question: UserMessage["content"]) => {

0 commit comments

Comments
 (0)