Changesets · Branches · Tags · Compare
| Changeset | 80716f70899b1c06186fcad420e48ddd9f88408405d78460f92e4c028a34cf11 |
|---|---|
| Author | Patrick Erichsen <patrick.a.erichsen@gmail.com> · 2025-07-08 09:35 -07:00 |
| Committer | Patrick Erichsen <patrick.a.erichsen@gmail.com> · 2025-07-08 09:35 -07:00 |
| Parents | 68309fbd40d3 |
1 file changed
modified gui/src/pages/gui/ToolCallDiv/ToolTruncateHistoryIcon.tsx +30 −19
| @@ -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"; | |
| 5 | 6 | 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 | |
| @@ -19,27 +19,38 @@ | ||
| 19 | 19 | }, [history]); |
| 20 | 20 | const dispatch = useAppDispatch(); |
| 21 | 21 | const { mainEditor } = useMainEditor(); |
| 22 | + | |
| 23 | + const truncateTooltipId = useMemo(() => { | |
| 24 | + return "truncate-hover-" + historyIndex; | |
| 25 | + }, [historyIndex]); | |
| 26 | + | |
| 22 | 27 | if (historyIndex === lastMessageIndex) { |
| 23 | 28 | return null; |
| 24 | 29 | } |
| 30 | + | |
| 25 | 31 | return ( |
| 26 | - <ToolbarButtonWithTooltip | |
| 27 | - tooltipContent={isStreaming ? "" : "Trim chat to this message"} | |
| 28 | - onClick={() => { | |
| 29 | - if (isStreaming) { | |
| 30 | - return; | |
| 31 | - } | |
| 32 | - dispatch( | |
| 33 | - truncateHistoryToMessage({ | |
| 34 | - index: historyIndex, | |
| 35 | - }), | |
| 36 | - ); | |
| 37 | - mainEditor?.commands.focus(); | |
| 38 | - }} | |
| 39 | - > | |
| 40 | - <BarsArrowUpIcon | |
| 41 | - className={`h-3 w-3 flex-shrink-0 ${isStreaming ? "cursor-not-allowed" : "cursor-pointer"}`} | |
| 42 | - /> | |
| 43 | - </ToolbarButtonWithTooltip> | |
| 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 | + </> | |
| 44 | 55 | ); |
| 45 | 56 | } |