Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions refact-agent/gui/src/components/ChatForm/ToolConfirmation.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useMemo } from "react";
import React, { useMemo } from "react";
import {
PATCH_LIKE_FUNCTIONS,
useAppDispatch,
Expand Down Expand Up @@ -88,10 +88,6 @@ export const ToolConfirmation: React.FC<ToolConfirmationProps> = ({
confirmToolUsage();
};

const handleReject = useCallback(() => {
rejectToolUsage(toolCallIds);
}, [rejectToolUsage, toolCallIds]);

const message = getConfirmationMessage(
commands,
rules,
Expand All @@ -105,7 +101,7 @@ export const ToolConfirmation: React.FC<ToolConfirmationProps> = ({
return (
<PatchConfirmation
handleAllowForThisChat={handleAllowForThisChat}
rejectToolUsage={handleReject}
rejectToolUsage={rejectToolUsage}
confirmToolUsage={confirmToolUsage}
/>
);
Expand Down Expand Up @@ -171,7 +167,7 @@ export const ToolConfirmation: React.FC<ToolConfirmationProps> = ({
color="red"
variant="surface"
size="1"
onClick={handleReject}
onClick={rejectToolUsage}
>
Stop
</Button>
Expand Down
33 changes: 10 additions & 23 deletions refact-agent/gui/src/hooks/useSendChatRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@ import {
setChatMode,
setIsWaitingForResponse,
setLastUserMessageId,
upsertToolCall,
} from "../features/Chat";

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

type SubmitHandlerParams =
| {
Expand Down Expand Up @@ -321,27 +319,16 @@ export const useSendChatRequest = () => {
dispatch(setIsWaitingForResponse(false));
}, [abort, dispatch]);

const rejectToolUsage = useCallback(
(toolCallIds: string[]) => {
abort();

toolCallIds.forEach((toolCallId) => {
dispatch(
upsertToolCallIntoHistory({ toolCallId, chatId, accepted: false }),
);
dispatch(upsertToolCall({ toolCallId, chatId, accepted: false }));
});

dispatch(
clearPauseReasonsAndHandleToolsStatus({
wasInteracted: true,
confirmationStatus: false,
}),
);
dispatch(setIsWaitingForResponse(false));
},
[abort, chatId, dispatch],
);
const rejectToolUsage = useCallback(() => {
abort();
dispatch(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's this a behaviour, that was present before?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eeyup, I guess I missed changing it back on this one #538

clearPauseReasonsAndHandleToolsStatus({
wasInteracted: true,
confirmationStatus: false,
}),
);
dispatch(setIsWaitingForResponse(false));
}, [abort, dispatch]);

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