From 9a15213f63d4da546fa5c9be593144c5ae6d0d84 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 8 Jul 2025 09:35:13 -0700 Subject: [PATCH 1/2] fix: use correct styling on truncate btn --- .../ToolCallDiv/ToolTruncateHistoryIcon.tsx | 49 ++++++++++++------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/gui/src/pages/gui/ToolCallDiv/ToolTruncateHistoryIcon.tsx b/gui/src/pages/gui/ToolCallDiv/ToolTruncateHistoryIcon.tsx index 12000042d..804dd2918 100644 --- a/gui/src/pages/gui/ToolCallDiv/ToolTruncateHistoryIcon.tsx +++ b/gui/src/pages/gui/ToolCallDiv/ToolTruncateHistoryIcon.tsx @@ -2,8 +2,8 @@ import { BarsArrowUpIcon } from "@heroicons/react/24/outline"; import { chatMessageIsEmpty } from "core/llm/messages"; import { findLastIndex } from "core/util/findLast"; import { useMemo } from "react"; +import { ToolTip } from "../../../components/gui/Tooltip"; import { useMainEditor } from "../../../components/mainInput/TipTapEditor"; -import { ToolbarButtonWithTooltip } from "../../../components/StyledMarkdownPreview/StepContainerPreToolbar/ToolbarButtonWithTooltip"; import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; import { truncateHistoryToMessage } from "../../../redux/slices/sessionSlice"; @@ -19,27 +19,38 @@ export function ToolTruncateHistoryIcon({ }, [history]); const dispatch = useAppDispatch(); const { mainEditor } = useMainEditor(); + + const truncateTooltipId = useMemo(() => { + return "truncate-hover-" + historyIndex; + }, [historyIndex]); + if (historyIndex === lastMessageIndex) { return null; } + return ( - { - if (isStreaming) { - return; - } - dispatch( - truncateHistoryToMessage({ - index: historyIndex, - }), - ); - mainEditor?.commands.focus(); - }} - > - - + <> +
{ + e.stopPropagation(); + if (isStreaming) { + return; + } + dispatch( + truncateHistoryToMessage({ + index: historyIndex, + }), + ); + mainEditor?.commands.focus(); + }} + className={`hover:description-muted/30 cursor-pointer select-none rounded px-1 py-0.5 hover:opacity-80 ${isStreaming ? "cursor-not-allowed opacity-50" : "bg-transparent"}`} + > + +
+ + {isStreaming ? "" : "Trim chat to this message"} + + ); } From 7205639dec58fb874e534d89a171181c2a674254 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 8 Jul 2025 09:38:57 -0700 Subject: [PATCH 2/2] fix: update toolbar btn stylings --- .../ToolbarButtonWithTooltip.tsx | 19 ++++---- .../pages/gui/ToolCallDiv/ToolCallArgs.tsx | 30 ++++-------- .../ToolCallDiv/ToolTruncateHistoryIcon.tsx | 47 ++++++++----------- 3 files changed, 37 insertions(+), 59 deletions(-) diff --git a/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/ToolbarButtonWithTooltip.tsx b/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/ToolbarButtonWithTooltip.tsx index 58f05ef0c..f8293cd50 100644 --- a/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/ToolbarButtonWithTooltip.tsx +++ b/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/ToolbarButtonWithTooltip.tsx @@ -1,6 +1,5 @@ import { ReactNode, useMemo } from "react"; -import { Tooltip } from "react-tooltip"; -import { getFontSize } from "../../../util"; +import { ToolTip } from "../../gui/Tooltip"; interface ToolbarButtonWithTooltipProps { onClick: () => void; @@ -22,20 +21,20 @@ export function ToolbarButtonWithTooltip({ return ( <> - - + + {tooltipContent} - + ); } diff --git a/gui/src/pages/gui/ToolCallDiv/ToolCallArgs.tsx b/gui/src/pages/gui/ToolCallDiv/ToolCallArgs.tsx index 0c5c188e4..c1b1ec0c7 100644 --- a/gui/src/pages/gui/ToolCallDiv/ToolCallArgs.tsx +++ b/gui/src/pages/gui/ToolCallDiv/ToolCallArgs.tsx @@ -1,6 +1,5 @@ import { CodeBracketIcon } from "@heroicons/react/24/outline"; -import { useMemo } from "react"; -import { ToolTip } from "../../../components/gui/Tooltip"; +import { ToolbarButtonWithTooltip } from "../../../components/StyledMarkdownPreview/StepContainerPreToolbar/ToolbarButtonWithTooltip"; interface ArgsToggleIconProps { isShowing: boolean; @@ -13,26 +12,15 @@ export const ArgsToggleIcon = ({ setIsShowing, toolCallId, }: ArgsToggleIconProps) => { - const argsTooltipId = useMemo(() => { - return "args-hover-" + toolCallId; - }, [toolCallId]); - return ( - <> -
{ - e.stopPropagation(); - setIsShowing(!isShowing); - }} - className={`hover:description-muted/30 cursor-pointer select-none rounded px-1 py-0.5 hover:opacity-80 ${isShowing ? "bg-description-muted/30" : "bg-transparent"}`} - > - -
- - {isShowing ? "Hide args" : "Show args"} - - + { + setIsShowing(!isShowing); + }} + > + + ); }; diff --git a/gui/src/pages/gui/ToolCallDiv/ToolTruncateHistoryIcon.tsx b/gui/src/pages/gui/ToolCallDiv/ToolTruncateHistoryIcon.tsx index 804dd2918..d28cd9328 100644 --- a/gui/src/pages/gui/ToolCallDiv/ToolTruncateHistoryIcon.tsx +++ b/gui/src/pages/gui/ToolCallDiv/ToolTruncateHistoryIcon.tsx @@ -2,8 +2,8 @@ import { BarsArrowUpIcon } from "@heroicons/react/24/outline"; import { chatMessageIsEmpty } from "core/llm/messages"; import { findLastIndex } from "core/util/findLast"; import { useMemo } from "react"; -import { ToolTip } from "../../../components/gui/Tooltip"; import { useMainEditor } from "../../../components/mainInput/TipTapEditor"; +import { ToolbarButtonWithTooltip } from "../../../components/StyledMarkdownPreview/StepContainerPreToolbar/ToolbarButtonWithTooltip"; import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; import { truncateHistoryToMessage } from "../../../redux/slices/sessionSlice"; @@ -20,37 +20,28 @@ export function ToolTruncateHistoryIcon({ const dispatch = useAppDispatch(); const { mainEditor } = useMainEditor(); - const truncateTooltipId = useMemo(() => { - return "truncate-hover-" + historyIndex; - }, [historyIndex]); - if (historyIndex === lastMessageIndex) { return null; } return ( - <> -
{ - e.stopPropagation(); - if (isStreaming) { - return; - } - dispatch( - truncateHistoryToMessage({ - index: historyIndex, - }), - ); - mainEditor?.commands.focus(); - }} - className={`hover:description-muted/30 cursor-pointer select-none rounded px-1 py-0.5 hover:opacity-80 ${isStreaming ? "cursor-not-allowed opacity-50" : "bg-transparent"}`} - > - -
- - {isStreaming ? "" : "Trim chat to this message"} - - + { + if (isStreaming) { + return; + } + dispatch( + truncateHistoryToMessage({ + index: historyIndex, + }), + ); + mainEditor?.commands.focus(); + }} + > + + ); }