Changesets · Branches · Tags · Compare
| Changeset | cd600673bdf6c95992edb7d4e2d218bf004f0a376283574896014bab9ff891cb |
|---|---|
| Author | Patrick Erichsen <patrick.a.erichsen@gmail.com> · 2025-07-08 09:38 -07:00 |
| Committer | Patrick Erichsen <patrick.a.erichsen@gmail.com> · 2025-07-08 09:38 -07:00 |
| Parents | 80716f70899b |
3 files changed
modified gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/ToolbarButtonWithTooltip.tsx +9 −10
| @@ -1,6 +1,5 @@ | ||
| 1 | 1 | import { ReactNode, useMemo } from "react"; |
| 2 | -import { Tooltip } from "react-tooltip"; | |
| 3 | -import { getFontSize } from "../../../util"; | |
| 2 | +import { ToolTip } from "../../gui/Tooltip"; | |
| 4 | 3 | |
| 5 | 4 | interface ToolbarButtonWithTooltipProps { |
| 6 | 5 | onClick: () => void; |
| @@ -22,20 +21,20 @@ | ||
| 22 | 21 | |
| 23 | 22 | return ( |
| 24 | 23 | <> |
| 25 | - <button | |
| 26 | - onClick={onClick} | |
| 27 | - style={{ | |
| 28 | - fontSize: `${getFontSize() - 2}px`, | |
| 24 | + <div | |
| 25 | + onClick={(e) => { | |
| 26 | + e.stopPropagation(); | |
| 27 | + onClick(); | |
| 29 | 28 | }} |
| 30 | 29 | data-tooltip-id={tooltipId} |
| 31 | 30 | data-testid={testId} |
| 32 | - className="text-foreground flex items-center border-none bg-transparent px-0.5 outline-none hover:cursor-pointer hover:brightness-125" | |
| 31 | + className="hover:description-muted/30 cursor-pointer select-none rounded bg-transparent px-1 py-0.5 hover:opacity-80" | |
| 33 | 32 | > |
| 34 | 33 | {children} |
| 35 | - </button> | |
| 36 | - <Tooltip id={tooltipId} place="top"> | |
| 34 | + </div> | |
| 35 | + <ToolTip id={tooltipId} place="top"> | |
| 37 | 36 | {tooltipContent} |
| 38 | - </Tooltip> | |
| 37 | + </ToolTip> | |
| 39 | 38 | </> |
| 40 | 39 | ); |
| 41 | 40 | } |
modified gui/src/pages/gui/ToolCallDiv/ToolCallArgs.tsx +9 −21
| @@ -1,6 +1,5 @@ | ||
| 1 | 1 | import { CodeBracketIcon } from "@heroicons/react/24/outline"; |
| 2 | -import { useMemo } from "react"; | |
| 3 | -import { ToolTip } from "../../../components/gui/Tooltip"; | |
| 2 | +import { ToolbarButtonWithTooltip } from "../../../components/StyledMarkdownPreview/StepContainerPreToolbar/ToolbarButtonWithTooltip"; | |
| 4 | 3 | |
| 5 | 4 | interface ArgsToggleIconProps { |
| 6 | 5 | isShowing: boolean; |
| @@ -13,26 +12,15 @@ | ||
| 13 | 12 | setIsShowing, |
| 14 | 13 | toolCallId, |
| 15 | 14 | }: ArgsToggleIconProps) => { |
| 16 | - const argsTooltipId = useMemo(() => { | |
| 17 | - return "args-hover-" + toolCallId; | |
| 18 | - }, [toolCallId]); | |
| 19 | - | |
| 20 | 15 | return ( |
| 21 | - <> | |
| 22 | - <div | |
| 23 | - data-tooltip-id={argsTooltipId} | |
| 24 | - onClick={(e) => { | |
| 25 | - e.stopPropagation(); | |
| 26 | - setIsShowing(!isShowing); | |
| 27 | - }} | |
| 28 | - 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"}`} | |
| 29 | - > | |
| 30 | - <CodeBracketIcon className="h-3 w-3 flex-shrink-0 opacity-60" /> | |
| 31 | - </div> | |
| 32 | - <ToolTip id={argsTooltipId}> | |
| 33 | - {isShowing ? "Hide args" : "Show args"} | |
| 34 | - </ToolTip> | |
| 35 | - </> | |
| 16 | + <ToolbarButtonWithTooltip | |
| 17 | + tooltipContent={isShowing ? "Hide args" : "Show args"} | |
| 18 | + onClick={() => { | |
| 19 | + setIsShowing(!isShowing); | |
| 20 | + }} | |
| 21 | + > | |
| 22 | + <CodeBracketIcon className="h-3 w-3 flex-shrink-0 opacity-60" /> | |
| 23 | + </ToolbarButtonWithTooltip> | |
| 36 | 24 | ); |
| 37 | 25 | }; |
| 38 | 26 |
modified gui/src/pages/gui/ToolCallDiv/ToolTruncateHistoryIcon.tsx +19 −28
| @@ -2,8 +2,8 @@ | ||
| 2 | 2 | import { chatMessageIsEmpty } from "core/llm/messages"; |
| 3 | 3 | import { findLastIndex } from "core/util/findLast"; |
| 4 | 4 | import { useMemo } from "react"; |
| 5 | -import { ToolTip } from "../../../components/gui/Tooltip"; | |
| 6 | 5 | import { useMainEditor } from "../../../components/mainInput/TipTapEditor"; |
| 6 | +import { ToolbarButtonWithTooltip } from "../../../components/StyledMarkdownPreview/StepContainerPreToolbar/ToolbarButtonWithTooltip"; | |
| 7 | 7 | import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; |
| 8 | 8 | import { truncateHistoryToMessage } from "../../../redux/slices/sessionSlice"; |
| 9 | 9 | |
| @@ -20,37 +20,28 @@ | ||
| 20 | 20 | const dispatch = useAppDispatch(); |
| 21 | 21 | const { mainEditor } = useMainEditor(); |
| 22 | 22 | |
| 23 | - const truncateTooltipId = useMemo(() => { | |
| 24 | - return "truncate-hover-" + historyIndex; | |
| 25 | - }, [historyIndex]); | |
| 26 | - | |
| 27 | 23 | if (historyIndex === lastMessageIndex) { |
| 28 | 24 | return null; |
| 29 | 25 | } |
| 30 | 26 | |
| 31 | 27 | return ( |
| 32 | - <> | |
| 33 | - <div | |
| 34 | - data-tooltip-id={truncateTooltipId} | |
| 35 | - onClick={(e) => { | |
| 36 | - e.stopPropagation(); | |
| 37 | - if (isStreaming) { | |
| 38 | - return; | |
| 39 | - } | |
| 40 | - dispatch( | |
| 41 | - truncateHistoryToMessage({ | |
| 42 | - index: historyIndex, | |
| 43 | - }), | |
| 44 | - ); | |
| 45 | - mainEditor?.commands.focus(); | |
| 46 | - }} | |
| 47 | - 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"}`} | |
| 48 | - > | |
| 49 | - <BarsArrowUpIcon className="h-3 w-3 flex-shrink-0 opacity-60" /> | |
| 50 | - </div> | |
| 51 | - <ToolTip id={truncateTooltipId}> | |
| 52 | - {isStreaming ? "" : "Trim chat to this message"} | |
| 53 | - </ToolTip> | |
| 54 | - </> | |
| 28 | + <ToolbarButtonWithTooltip | |
| 29 | + tooltipContent={isStreaming ? "" : "Trim chat to this message"} | |
| 30 | + onClick={() => { | |
| 31 | + if (isStreaming) { | |
| 32 | + return; | |
| 33 | + } | |
| 34 | + dispatch( | |
| 35 | + truncateHistoryToMessage({ | |
| 36 | + index: historyIndex, | |
| 37 | + }), | |
| 38 | + ); | |
| 39 | + mainEditor?.commands.focus(); | |
| 40 | + }} | |
| 41 | + > | |
| 42 | + <BarsArrowUpIcon | |
| 43 | + className={`h-3 w-3 flex-shrink-0 opacity-60 ${isStreaming ? "cursor-not-allowed" : ""}`} | |
| 44 | + /> | |
| 45 | + </ToolbarButtonWithTooltip> | |
| 55 | 46 | ); |
| 56 | 47 | } |