From c28f70a9f0f9603a2e52925ef4f2317e20f899da Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 27 Jun 2025 20:23:03 -0700 Subject: [PATCH] context peek formatting and fix last index logic for tool truncation logic --- core/util/findLast.ts | 6 +- .../belowMainInput/ContextItemsPeek.tsx | 58 +++++++++---------- .../gui/ToolCallDiv/SimpleToolCallUI.tsx | 6 +- gui/src/pages/gui/ToolCallDiv/ToolCall.tsx | 6 +- ...ryIcon.tsx => ToolTruncateHistoryIcon.tsx} | 18 ++++-- 5 files changed, 52 insertions(+), 42 deletions(-) rename gui/src/pages/gui/ToolCallDiv/{TruncateHistoryIcon.tsx => ToolTruncateHistoryIcon.tsx} (54%) diff --git a/core/util/findLast.ts b/core/util/findLast.ts index 9e99fd473..256d6e09d 100644 --- a/core/util/findLast.ts +++ b/core/util/findLast.ts @@ -1,6 +1,6 @@ -export function findLastIndex( - arr: any[], - criterion: (item: any) => boolean, +export function findLastIndex( + arr: T[], + criterion: (item: T) => boolean, ): number { let lastIndex = -1; diff --git a/gui/src/components/mainInput/belowMainInput/ContextItemsPeek.tsx b/gui/src/components/mainInput/belowMainInput/ContextItemsPeek.tsx index 3c7ce9390..cb3009675 100644 --- a/gui/src/components/mainInput/belowMainInput/ContextItemsPeek.tsx +++ b/gui/src/components/mainInput/belowMainInput/ContextItemsPeek.tsx @@ -117,40 +117,36 @@ export function ContextItemsPeekItem({ return (
-
- {getContextItemIcon()} -
-
- {contextItem.name} -
-
{ - if (contextItem.uri?.value) { - e.stopPropagation(); - ideMessenger.post("openUrl", contextItem.uri.value); - } else { - console.error("Couldn't open url", contextItem.uri); - } - } - : undefined - } - > - {contextItem.uri?.type === "file" - ? getUriPathBasename(contextItem.description) - : contextItem.description} -
-
- + {getContextItemIcon()} + + {contextItem.name} + +
{ + if (contextItem.uri?.value) { + e.stopPropagation(); + ideMessenger.post("openUrl", contextItem.uri.value); + } else { + console.error("Couldn't open url", contextItem.uri); + } + } + : undefined + } + > + + {contextItem.uri?.type === "file" + ? getUriPathBasename(contextItem.description) + : contextItem.description} + adsfasdfasdjk; asdfl;kjasdl;fkjasdlk;fja asdfklj;asdl;fkjasdf + {isUrl && ( - + )}
diff --git a/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx b/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx index 1f19ea438..9ba9ae60d 100644 --- a/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx +++ b/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx @@ -6,7 +6,7 @@ import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; import { ArgsItems, ArgsToggleIcon } from "./ToolCallArgs"; import { toolCallStateToContextItems } from "./toolCallStateToContextItem"; import { ToolCallStatusMessage } from "./ToolCallStatusMessage"; -import { TruncateHistoryIcon } from "./TruncateHistoryIcon"; +import { ToolTruncateHistoryIcon } from "./ToolTruncateHistoryIcon"; interface SimpleToolCallUIProps { toolCallState: ToolCallState; @@ -61,7 +61,9 @@ export function SimpleToolCallUI({
- + {!!toolCallState.output?.length && ( + + )} {args.length > 0 ? (
- + {!!toolCallState.output && ( + + )} {!!args.length ? ( state.session.isStreaming); const history = useAppSelector((state) => state.session.history); + const lastMessageIndex = useMemo(() => { + return findLastIndex(history, (item) => !chatMessageIsEmpty(item.message)); + }, [history]); const dispatch = useAppDispatch(); - if (isStreaming || historyIndex === history.length - 1) { + const { mainEditor } = useMainEditor(); + if (isStreaming || lastMessageIndex) { return null; } return ( @@ -23,9 +31,11 @@ export function TruncateHistoryIcon({ index: historyIndex, }), ); + mainEditor?.commands.focus(); }} > - + {historyIndex}/{history.length - 1} + ); }