Elffuss BraidHub

kikocis/continue public

move the tool truncation icon to a different PR
Changesetf4d972701df9451a75e2137d0c2a981eebb5823f83f7906b274e18e1fc3e56a1
AuthorDallin Romney <dallinromney@gmail.com> · 2025-07-01 12:40 -07:00
CommitterDallin Romney <dallinromney@gmail.com> · 2025-07-01 12:40 -07:00
Parentsae97b3eabfe1

Browse the files at this changeset

7 files changed

modified gui/src/components/mainInput/icons.ts +0 −2
@@ -18,7 +18,6 @@
1818 PlusIcon,
1919 SparklesIcon,
2020 TrashIcon,
21- WrenchScrewdriverIcon,
2221 } from "@heroicons/react/24/outline";
2322 import { DiscordIcon } from "../svg/DiscordIcon";
2423 import { GithubIcon } from "../svg/GithubIcon";
@@ -56,5 +55,4 @@
5655 "gitlab-mr": GitlabIcon,
5756 http: GlobeAltIcon,
5857 trash: TrashIcon,
59- toolCall: WrenchScrewdriverIcon,
6058 };
modified gui/src/pages/gui/Chat.tsx +2 −1
@@ -319,7 +319,7 @@
319319 inputId={item.message.id}
320320 />
321321 </>
322- ) : item.message.role === "tool" ? null : item.message.role === // /> // toolCallId={item.message.toolCallId} // contextItems={item.contextItems} // <ToolOutput
322+ ) : item.message.role === "tool" ? null : item.message.role ===
323323 "assistant" &&
324324 item.message.toolCalls &&
325325 item.toolCallState ? (
@@ -330,6 +330,7 @@
330330 key={i}
331331 toolCallState={item.toolCallState!}
332332 toolCall={toolCall}
333+ output={history[index + 1]?.contextItems}
333334 historyIndex={index}
334335 />
335336 );
modified gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx +21 −27
@@ -1,5 +1,5 @@
11 import { ChevronRightIcon } from "@heroicons/react/24/outline";
2-import { Tool, ToolCallState } from "core";
2+import { ContextItemWithId, Tool, ToolCallState } from "core";
33 import { ComponentType, useContext, useMemo, useState } from "react";
44 import {
55 ContextItemsPeekItem,
@@ -7,28 +7,26 @@
77 } from "../../../components/mainInput/belowMainInput/ContextItemsPeek";
88 import { IdeMessengerContext } from "../../../context/IdeMessenger";
99 import { ArgsItems, ArgsToggleIcon } from "./ToolCallArgs";
10-import { toolCallStateToContextItems } from "./toolCallStateToContextItem";
1110 import { ToolCallStatusMessage } from "./ToolCallStatusMessage";
12-import { ToolTruncateHistoryIcon } from "./ToolTruncateHistoryIcon";
1311
1412 interface SimpleToolCallUIProps {
1513 toolCallState: ToolCallState;
1614 tool: Tool | undefined;
15+ contextItems: ContextItemWithId[];
1716 icon?: ComponentType<React.SVGProps<SVGSVGElement>>;
18- historyIndex: number;
1917 }
2018
2119 export function SimpleToolCallUI({
20+ contextItems,
2221 icon: Icon,
2322 toolCallState,
2423 tool,
25- historyIndex,
2624 }: SimpleToolCallUIProps) {
2725 const ideMessenger = useContext(IdeMessengerContext);
28- const shownContextItems = useMemo(() => {
29- const contextItems = toolCallStateToContextItems(toolCallState);
30- return contextItems.filter((item) => !item.hidden);
31- }, [toolCallState]);
26+
27+ const ctxItems = useMemo(() => {
28+ return contextItems?.filter((ctxItem) => !ctxItem.hidden) ?? [];
29+ }, [contextItems]);
3230
3331 const [open, setOpen] = useState(false);
3432 const [isHovered, setIsHovered] = useState(false);
@@ -38,8 +36,8 @@
3836 return Object.entries(toolCallState.parsedArgs);
3937 }, [toolCallState.parsedArgs]);
4038
41- const isToggleable = shownContextItems.length > 1;
42- const isSingleItem = shownContextItems.length === 1;
39+ const isToggleable = ctxItems.length > 1;
40+ const isSingleItem = ctxItems.length === 1;
4341 const shouldShowContent = isToggleable ? open : false;
4442 const isClickable = isToggleable || isSingleItem;
4543
@@ -47,7 +45,7 @@
4745 if (isToggleable) {
4846 setOpen((prev) => !prev);
4947 } else if (isSingleItem) {
50- openContextItem(shownContextItems[0], ideMessenger);
48+ openContextItem(ctxItems[0], ideMessenger);
5149 }
5250 }
5351
@@ -73,7 +71,7 @@
7371 }
7472
7573 return (
76- <div className="flex flex-col py-4 pl-5 pr-2">
74+ <div className="flex flex-col pl-5 pr-2 pt-4">
7775 <div className="flex min-w-0 flex-row items-center justify-between gap-2">
7876 <div
7977 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 ${
@@ -89,19 +87,15 @@
8987 </div>
9088 <ToolCallStatusMessage tool={tool} toolCallState={toolCallState} />
9189 </div>
92- <div className="flex flex-row items-center gap-1.5">
93- {!!toolCallState.output?.length && (
94- <ToolTruncateHistoryIcon historyIndex={historyIndex} />
95- )}
96- {args.length > 0 ? (
97- <ArgsToggleIcon
98- isShowing={showingArgs}
99- setIsShowing={setShowingArgs}
100- toolCallId={toolCallState.toolCallId}
101- />
102- ) : null}
103- </div>
90+ {args.length > 0 && (
91+ <ArgsToggleIcon
92+ isShowing={showingArgs}
93+ setIsShowing={setShowingArgs}
94+ toolCallId={toolCallState.toolCallId}
95+ />
96+ )}
10497 </div>
98+
10599 <ArgsItems args={args} isShowing={showingArgs} />
106100
107101 {isToggleable && (
@@ -110,8 +104,8 @@
110104 shouldShowContent ? "max-h-[50vh] opacity-100" : "max-h-0 opacity-0"
111105 }`}
112106 >
113- {shownContextItems.length > 0 ? (
114- shownContextItems.map((contextItem, idx) => (
107+ {ctxItems.length > 0 ? (
108+ ctxItems.map((contextItem, idx) => (
115109 <ContextItemsPeekItem key={idx} contextItem={contextItem} />
116110 ))
117111 ) : (
modified gui/src/pages/gui/ToolCallDiv/ToolCall.tsx +7 −15
@@ -2,14 +2,12 @@
22 import { useMemo, useState } from "react";
33 import { ArgsItems, ArgsToggleIcon } from "./ToolCallArgs";
44 import { ToolCallStatusMessage } from "./ToolCallStatusMessage";
5-import { ToolTruncateHistoryIcon } from "./ToolTruncateHistoryIcon";
65
76 interface ToolCallDisplayProps {
87 children: React.ReactNode;
98 icon: React.ReactNode;
109 tool: Tool | undefined;
1110 toolCallState: ToolCallState;
12- historyIndex: number;
1311 }
1412
1513 export function ToolCallDisplay({
@@ -17,7 +15,6 @@
1715 toolCallState,
1816 children,
1917 icon,
20- historyIndex,
2118 }: ToolCallDisplayProps) {
2219 const [argsExpanded, setArgsExpanded] = useState(false);
2320
@@ -42,18 +39,13 @@
4239 toolCallState={toolCallState}
4340 />
4441 </div>
45- <div className="flex flex-row items-center gap-1.5">
46- {!!toolCallState.output && (
47- <ToolTruncateHistoryIcon historyIndex={historyIndex} />
48- )}
49- {!!args.length ? (
50- <ArgsToggleIcon
51- isShowing={argsExpanded}
52- setIsShowing={setArgsExpanded}
53- toolCallId={toolCallState.toolCallId}
54- />
55- ) : null}
56- </div>
42+ {!!args.length ? (
43+ <ArgsToggleIcon
44+ isShowing={argsExpanded}
45+ setIsShowing={setArgsExpanded}
46+ toolCallId={toolCallState.toolCallId}
47+ />
48+ ) : null}
5749 </div>
5850 {argsExpanded && !!args.length && (
5951 <ArgsItems args={args} isShowing={argsExpanded} />
deleted gui/src/pages/gui/ToolCallDiv/ToolTruncateHistoryIcon.tsx +0 −40
@@ -1,40 +0,0 @@
1-import { BarsArrowUpIcon } from "@heroicons/react/24/outline";
2-import { chatMessageIsEmpty } from "core/llm/messages";
3-import { findLastIndex } from "core/util/findLast";
4-import { useMemo } from "react";
5-import { useMainEditor } from "../../../components/mainInput/TipTapEditor";
6-import { ToolbarButtonWithTooltip } from "../../../components/StyledMarkdownPreview/StepContainerPreToolbar/ToolbarButtonWithTooltip";
7-import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
8-import { truncateHistoryToMessage } from "../../../redux/slices/sessionSlice";
9-
10-export function ToolTruncateHistoryIcon({
11- historyIndex,
12-}: {
13- historyIndex: number;
14-}) {
15- const isStreaming = useAppSelector((state) => state.session.isStreaming);
16- const history = useAppSelector((state) => state.session.history);
17- const lastMessageIndex = useMemo(() => {
18- return findLastIndex(history, (item) => !chatMessageIsEmpty(item.message));
19- }, [history]);
20- const dispatch = useAppDispatch();
21- const { mainEditor } = useMainEditor();
22- if (isStreaming || historyIndex === lastMessageIndex) {
23- return null;
24- }
25- return (
26- <ToolbarButtonWithTooltip
27- tooltipContent="Truncate chat to this message"
28- onClick={() => {
29- dispatch(
30- truncateHistoryToMessage({
31- index: historyIndex,
32- }),
33- );
34- mainEditor?.commands.focus();
35- }}
36- >
37- <BarsArrowUpIcon className="h-2.5 w-2.5 flex-shrink-0" />
38- </ToolbarButtonWithTooltip>
39- );
40-}
modified gui/src/pages/gui/ToolCallDiv/index.tsx +8 −3
@@ -12,7 +12,12 @@
1212 PencilIcon,
1313 XMarkIcon,
1414 } from "@heroicons/react/24/outline";
15-import { ToolCallDelta, ToolCallState, ToolStatus } from "core";
15+import {
16+ ContextItemWithId,
17+ ToolCallDelta,
18+ ToolCallState,
19+ ToolStatus,
20+} from "core";
1621 import { BuiltInToolNames } from "core/tools/builtIn";
1722 import { ComponentType, useMemo } from "react";
1823 import { vscButtonBackground } from "../../../components";
@@ -25,6 +30,7 @@
2530 interface ToolCallDivProps {
2631 toolCall: ToolCallDelta;
2732 toolCallState: ToolCallState;
33+ output?: ContextItemWithId[];
2834 historyIndex: number;
2935 }
3036
@@ -80,7 +86,7 @@
8086 icon={
8187 props.toolCallState.status === "generated" ? ArrowRightIcon : icon
8288 }
83- historyIndex={props.historyIndex}
89+ contextItems={props.output ?? []}
8490 />
8591 );
8692 }
@@ -90,7 +96,6 @@
9096 icon={getStatusIcon(props.toolCallState.status)}
9197 tool={tool}
9298 toolCallState={props.toolCallState}
93- historyIndex={props.historyIndex}
9499 >
95100 <FunctionSpecificToolCallDiv
96101 toolCall={props.toolCall}
modified gui/src/redux/slices/sessionSlice.ts +0 −23
@@ -171,28 +171,6 @@
171171 state.history[index].contextItems = contextItems;
172172 }
173173 },
174- truncateHistoryToMessage: (
175- state,
176- {
177- payload,
178- }: PayloadAction<{
179- index: number;
180- }>,
181- ) => {
182- const { index } = payload;
183-
184- if (state.history.length && index < state.history.length) {
185- state.codeBlockApplyStates.curIndex = 0;
186- state.history = state.history.slice(0, index + 1).concat({
187- message: {
188- id: uuidv4(),
189- role: "assistant",
190- content: "", // IMPORTANT - this is subsequently updated by response streaming
191- },
192- contextItems: [],
193- });
194- }
195- },
196174 submitEditorAndInitAtIndex: (
197175 state,
198176 {
@@ -733,7 +711,6 @@
733711 addPromptCompletionPair,
734712 setActive,
735713 submitEditorAndInitAtIndex,
736- truncateHistoryToMessage,
737714 updateHistoryItemAtIndex,
738715 clearDanglingMessages,
739716 setMainEditorContentTrigger,