Elffuss BraidHub

kikocis/continue public

update message cancelaltion and rejection logic
Changesete8f6b7fe8bda226cbddd10e75422adbcf87b64302f0b3c3cb77cd1ed94a378ec
AuthorDallin Romney <dallinromney@gmail.com> · 2025-07-01 01:57 -07:00
CommitterDallin Romney <dallinromney@gmail.com> · 2025-07-01 01:57 -07:00
Parentsab40c6302033

Browse the files at this changeset

6 files changed

modified gui/src/components/AcceptRejectDiffButtons.tsx +14 −1
@@ -2,6 +2,9 @@
22 import { ApplyState } from "core";
33 import { useContext } from "react";
44 import { IdeMessengerContext } from "../context/IdeMessenger";
5+import { useAppDispatch, useAppSelector } from "../redux/hooks";
6+import { selectCurrentToolCallApplyState } from "../redux/selectors/selectCurrentToolCall";
7+import { cancelToolCall } from "../redux/slices/sessionSlice";
58 import { getMetaKeyLabel } from "../util";
69 import { ToolTip } from "./gui/Tooltip";
710
@@ -20,8 +23,18 @@
2023 (state) => state.status === "done",
2124 );
2225 const ideMessenger = useContext(IdeMessengerContext);
23-
26+ const currentToolCallApplyState = useAppSelector(
27+ selectCurrentToolCallApplyState,
28+ );
29+ const dispatch = useAppDispatch();
2430 async function handleAcceptOrReject(status: AcceptOrRejectOutcome) {
31+ if (currentToolCallApplyState?.status === "done") {
32+ dispatch(
33+ cancelToolCall({
34+ toolCallId: currentToolCallApplyState.toolCallId!,
35+ }),
36+ );
37+ }
2538 for (const { filepath = "", streamId } of pendingApplyStates) {
2639 ideMessenger.post(status, {
2740 filepath,
modified gui/src/components/mainInput/InputToolbar.tsx +1 −13
@@ -9,10 +9,6 @@
99 import { IdeMessengerContext } from "../../context/IdeMessenger";
1010 import { useAppDispatch, useAppSelector } from "../../redux/hooks";
1111 import { selectUseActiveFile } from "../../redux/selectors";
12-import {
13- selectCurrentToolCall,
14- selectCurrentToolCallApplyState,
15-} from "../../redux/selectors/selectCurrentToolCall";
1612 import { selectSelectedChatModel } from "../../redux/slices/configSlice";
1713 import { setHasReasoningEnabled } from "../../redux/slices/sessionSlice";
1814 import { exitEdit } from "../../redux/thunks/edit";
@@ -53,20 +49,12 @@
5349 const useActiveFile = useAppSelector(selectUseActiveFile);
5450 const isInEdit = useAppSelector((store) => store.session.isInEdit);
5551 const codeToEdit = useAppSelector((store) => store.editModeState.codeToEdit);
56- const toolCallState = useAppSelector(selectCurrentToolCall);
57- const currentToolCallApplyState = useAppSelector(
58- selectCurrentToolCallApplyState,
59- );
6052 const hasReasoningEnabled = useAppSelector(
6153 (store) => store.session.hasReasoningEnabled,
6254 );
6355
6456 const isEnterDisabled =
65- props.disabled ||
66- (isInEdit && codeToEdit.length === 0) ||
67- toolCallState?.status === "generated" ||
68- (currentToolCallApplyState &&
69- currentToolCallApplyState.status !== "closed");
57+ props.disabled || (isInEdit && codeToEdit.length === 0);
7058
7159 const toolsSupported = defaultModel && modelSupportsTools(defaultModel);
7260
modified gui/src/hooks/ParallelListeners.tsx +5 −6
@@ -268,7 +268,6 @@
268268 currentToolCallApplyState.streamId === state.streamId
269269 ) {
270270 if (state.status === "done" && autoAcceptEditToolDiffs) {
271- console.log("AUTO ACCEPTED");
272271 ideMessenger.post("acceptDiff", {
273272 streamId: state.streamId,
274273 filepath: state.filepath,
@@ -281,6 +280,11 @@
281280 toolCallId: currentToolCallApplyState.toolCallId!,
282281 }),
283282 );
283+ void dispatch(
284+ streamResponseAfterToolCall({
285+ toolCallId: currentToolCallApplyState.toolCallId!,
286+ }),
287+ );
284288 }
285289 // const output: ContextItem = {
286290 // name: "Edit tool output",
@@ -288,11 +292,6 @@
288292 // description: "",
289293 // };
290294 // dispatch(setToolCallOutput([]));
291- void dispatch(
292- streamResponseAfterToolCall({
293- toolCallId: currentToolCallApplyState.toolCallId!,
294- }),
295- );
296295 }
297296 }
298297 }
modified gui/src/pages/gui/Chat.tsx +1 −1
@@ -319,7 +319,7 @@
319319 inputId={item.message.id}
320320 />
321321 </>
322- ) : item.message.role === "tool" ? null : item.message.role ===
322+ ) : item.message.role === "tool" ? null : item.message.role === // /> // toolCallId={item.message.toolCallId} // contextItems={item.contextItems} // <ToolOutput
323323 "assistant" &&
324324 item.message.toolCalls &&
325325 item.toolCallState ? (
modified gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx +1 −1
@@ -73,7 +73,7 @@
7373 }
7474
7575 return (
76- <div className="flex flex-col pl-5 pr-2 pt-4">
76+ <div className="flex flex-col py-4 pl-5 pr-2">
7777 <div className="flex min-w-0 flex-row items-center justify-between gap-2">
7878 <div
7979 className={`text-description flex min-w-0 flex-row items-center justify-between gap-1.5 text-xs transition-colors duration-200 ease-in-out ${
modified gui/src/redux/util/constructMessages.ts +3 −1
@@ -114,7 +114,9 @@
114114 for (const toolCall of item.message.toolCalls) {
115115 let content: string = "No tool output";
116116 // TODO toolCallState only supports one tool call per message for now
117- if (
117+ if (item.toolCallState?.status === "canceled") {
118+ content = "The user cancelled this tool call.";
119+ } else if (
118120 item.toolCallState?.toolCallId === toolCall.id &&
119121 item.toolCallState?.output
120122 ) {