Changesets · Branches · Tags · Compare
| Changeset | f4d972701df9451a75e2137d0c2a981eebb5823f83f7906b274e18e1fc3e56a1 |
|---|---|
| Author | Dallin Romney <dallinromney@gmail.com> · 2025-07-01 12:40 -07:00 |
| Committer | Dallin Romney <dallinromney@gmail.com> · 2025-07-01 12:40 -07:00 |
| Parents | ae97b3eabfe1 |
7 files changed
modified gui/src/components/mainInput/icons.ts +0 −2
| @@ -18,7 +18,6 @@ | ||
| 18 | 18 | PlusIcon, |
| 19 | 19 | SparklesIcon, |
| 20 | 20 | TrashIcon, |
| 21 | - WrenchScrewdriverIcon, | |
| 22 | 21 | } from "@heroicons/react/24/outline"; |
| 23 | 22 | import { DiscordIcon } from "../svg/DiscordIcon"; |
| 24 | 23 | import { GithubIcon } from "../svg/GithubIcon"; |
| @@ -56,5 +55,4 @@ | ||
| 56 | 55 | "gitlab-mr": GitlabIcon, |
| 57 | 56 | http: GlobeAltIcon, |
| 58 | 57 | trash: TrashIcon, |
| 59 | - toolCall: WrenchScrewdriverIcon, | |
| 60 | 58 | }; |
modified gui/src/pages/gui/Chat.tsx +2 −1
| @@ -319,7 +319,7 @@ | ||
| 319 | 319 | inputId={item.message.id} |
| 320 | 320 | /> |
| 321 | 321 | </> |
| 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 === | |
| 323 | 323 | "assistant" && |
| 324 | 324 | item.message.toolCalls && |
| 325 | 325 | item.toolCallState ? ( |
| @@ -330,6 +330,7 @@ | ||
| 330 | 330 | key={i} |
| 331 | 331 | toolCallState={item.toolCallState!} |
| 332 | 332 | toolCall={toolCall} |
| 333 | + output={history[index + 1]?.contextItems} | |
| 333 | 334 | historyIndex={index} |
| 334 | 335 | /> |
| 335 | 336 | ); |
modified gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx +21 −27
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | import { ChevronRightIcon } from "@heroicons/react/24/outline"; |
| 2 | -import { Tool, ToolCallState } from "core"; | |
| 2 | +import { ContextItemWithId, Tool, ToolCallState } from "core"; | |
| 3 | 3 | import { ComponentType, useContext, useMemo, useState } from "react"; |
| 4 | 4 | import { |
| 5 | 5 | ContextItemsPeekItem, |
| @@ -7,28 +7,26 @@ | ||
| 7 | 7 | } from "../../../components/mainInput/belowMainInput/ContextItemsPeek"; |
| 8 | 8 | import { IdeMessengerContext } from "../../../context/IdeMessenger"; |
| 9 | 9 | import { ArgsItems, ArgsToggleIcon } from "./ToolCallArgs"; |
| 10 | -import { toolCallStateToContextItems } from "./toolCallStateToContextItem"; | |
| 11 | 10 | import { ToolCallStatusMessage } from "./ToolCallStatusMessage"; |
| 12 | -import { ToolTruncateHistoryIcon } from "./ToolTruncateHistoryIcon"; | |
| 13 | 11 | |
| 14 | 12 | interface SimpleToolCallUIProps { |
| 15 | 13 | toolCallState: ToolCallState; |
| 16 | 14 | tool: Tool | undefined; |
| 15 | + contextItems: ContextItemWithId[]; | |
| 17 | 16 | icon?: ComponentType<React.SVGProps<SVGSVGElement>>; |
| 18 | - historyIndex: number; | |
| 19 | 17 | } |
| 20 | 18 | |
| 21 | 19 | export function SimpleToolCallUI({ |
| 20 | + contextItems, | |
| 22 | 21 | icon: Icon, |
| 23 | 22 | toolCallState, |
| 24 | 23 | tool, |
| 25 | - historyIndex, | |
| 26 | 24 | }: SimpleToolCallUIProps) { |
| 27 | 25 | 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]); | |
| 32 | 30 | |
| 33 | 31 | const [open, setOpen] = useState(false); |
| 34 | 32 | const [isHovered, setIsHovered] = useState(false); |
| @@ -38,8 +36,8 @@ | ||
| 38 | 36 | return Object.entries(toolCallState.parsedArgs); |
| 39 | 37 | }, [toolCallState.parsedArgs]); |
| 40 | 38 | |
| 41 | - const isToggleable = shownContextItems.length > 1; | |
| 42 | - const isSingleItem = shownContextItems.length === 1; | |
| 39 | + const isToggleable = ctxItems.length > 1; | |
| 40 | + const isSingleItem = ctxItems.length === 1; | |
| 43 | 41 | const shouldShowContent = isToggleable ? open : false; |
| 44 | 42 | const isClickable = isToggleable || isSingleItem; |
| 45 | 43 | |
| @@ -47,7 +45,7 @@ | ||
| 47 | 45 | if (isToggleable) { |
| 48 | 46 | setOpen((prev) => !prev); |
| 49 | 47 | } else if (isSingleItem) { |
| 50 | - openContextItem(shownContextItems[0], ideMessenger); | |
| 48 | + openContextItem(ctxItems[0], ideMessenger); | |
| 51 | 49 | } |
| 52 | 50 | } |
| 53 | 51 | |
| @@ -73,7 +71,7 @@ | ||
| 73 | 71 | } |
| 74 | 72 | |
| 75 | 73 | 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"> | |
| 77 | 75 | <div className="flex min-w-0 flex-row items-center justify-between gap-2"> |
| 78 | 76 | <div |
| 79 | 77 | 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 @@ | ||
| 89 | 87 | </div> |
| 90 | 88 | <ToolCallStatusMessage tool={tool} toolCallState={toolCallState} /> |
| 91 | 89 | </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 | + )} | |
| 104 | 97 | </div> |
| 98 | + | |
| 105 | 99 | <ArgsItems args={args} isShowing={showingArgs} /> |
| 106 | 100 | |
| 107 | 101 | {isToggleable && ( |
| @@ -110,8 +104,8 @@ | ||
| 110 | 104 | shouldShowContent ? "max-h-[50vh] opacity-100" : "max-h-0 opacity-0" |
| 111 | 105 | }`} |
| 112 | 106 | > |
| 113 | - {shownContextItems.length > 0 ? ( | |
| 114 | - shownContextItems.map((contextItem, idx) => ( | |
| 107 | + {ctxItems.length > 0 ? ( | |
| 108 | + ctxItems.map((contextItem, idx) => ( | |
| 115 | 109 | <ContextItemsPeekItem key={idx} contextItem={contextItem} /> |
| 116 | 110 | )) |
| 117 | 111 | ) : ( |
modified gui/src/pages/gui/ToolCallDiv/ToolCall.tsx +7 −15
| @@ -2,14 +2,12 @@ | ||
| 2 | 2 | import { useMemo, useState } from "react"; |
| 3 | 3 | import { ArgsItems, ArgsToggleIcon } from "./ToolCallArgs"; |
| 4 | 4 | import { ToolCallStatusMessage } from "./ToolCallStatusMessage"; |
| 5 | -import { ToolTruncateHistoryIcon } from "./ToolTruncateHistoryIcon"; | |
| 6 | 5 | |
| 7 | 6 | interface ToolCallDisplayProps { |
| 8 | 7 | children: React.ReactNode; |
| 9 | 8 | icon: React.ReactNode; |
| 10 | 9 | tool: Tool | undefined; |
| 11 | 10 | toolCallState: ToolCallState; |
| 12 | - historyIndex: number; | |
| 13 | 11 | } |
| 14 | 12 | |
| 15 | 13 | export function ToolCallDisplay({ |
| @@ -17,7 +15,6 @@ | ||
| 17 | 15 | toolCallState, |
| 18 | 16 | children, |
| 19 | 17 | icon, |
| 20 | - historyIndex, | |
| 21 | 18 | }: ToolCallDisplayProps) { |
| 22 | 19 | const [argsExpanded, setArgsExpanded] = useState(false); |
| 23 | 20 | |
| @@ -42,18 +39,13 @@ | ||
| 42 | 39 | toolCallState={toolCallState} |
| 43 | 40 | /> |
| 44 | 41 | </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} | |
| 57 | 49 | </div> |
| 58 | 50 | {argsExpanded && !!args.length && ( |
| 59 | 51 | <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 @@ | ||
| 12 | 12 | PencilIcon, |
| 13 | 13 | XMarkIcon, |
| 14 | 14 | } 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"; | |
| 16 | 21 | import { BuiltInToolNames } from "core/tools/builtIn"; |
| 17 | 22 | import { ComponentType, useMemo } from "react"; |
| 18 | 23 | import { vscButtonBackground } from "../../../components"; |
| @@ -25,6 +30,7 @@ | ||
| 25 | 30 | interface ToolCallDivProps { |
| 26 | 31 | toolCall: ToolCallDelta; |
| 27 | 32 | toolCallState: ToolCallState; |
| 33 | + output?: ContextItemWithId[]; | |
| 28 | 34 | historyIndex: number; |
| 29 | 35 | } |
| 30 | 36 | |
| @@ -80,7 +86,7 @@ | ||
| 80 | 86 | icon={ |
| 81 | 87 | props.toolCallState.status === "generated" ? ArrowRightIcon : icon |
| 82 | 88 | } |
| 83 | - historyIndex={props.historyIndex} | |
| 89 | + contextItems={props.output ?? []} | |
| 84 | 90 | /> |
| 85 | 91 | ); |
| 86 | 92 | } |
| @@ -90,7 +96,6 @@ | ||
| 90 | 96 | icon={getStatusIcon(props.toolCallState.status)} |
| 91 | 97 | tool={tool} |
| 92 | 98 | toolCallState={props.toolCallState} |
| 93 | - historyIndex={props.historyIndex} | |
| 94 | 99 | > |
| 95 | 100 | <FunctionSpecificToolCallDiv |
| 96 | 101 | toolCall={props.toolCall} |
modified gui/src/redux/slices/sessionSlice.ts +0 −23
| @@ -171,28 +171,6 @@ | ||
| 171 | 171 | state.history[index].contextItems = contextItems; |
| 172 | 172 | } |
| 173 | 173 | }, |
| 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 | - }, | |
| 196 | 174 | submitEditorAndInitAtIndex: ( |
| 197 | 175 | state, |
| 198 | 176 | { |
| @@ -733,7 +711,6 @@ | ||
| 733 | 711 | addPromptCompletionPair, |
| 734 | 712 | setActive, |
| 735 | 713 | submitEditorAndInitAtIndex, |
| 736 | - truncateHistoryToMessage, | |
| 737 | 714 | updateHistoryItemAtIndex, |
| 738 | 715 | clearDanglingMessages, |
| 739 | 716 | setMainEditorContentTrigger, |