fix: use correct styling on truncate btn
This commit is contained in:
parent
8327f4a9e1
commit
9a15213f63
1 changed files with 30 additions and 19 deletions
|
|
@ -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 (
|
||||
<ToolbarButtonWithTooltip
|
||||
tooltipContent={isStreaming ? "" : "Trim chat to this message"}
|
||||
onClick={() => {
|
||||
if (isStreaming) {
|
||||
return;
|
||||
}
|
||||
dispatch(
|
||||
truncateHistoryToMessage({
|
||||
index: historyIndex,
|
||||
}),
|
||||
);
|
||||
mainEditor?.commands.focus();
|
||||
}}
|
||||
>
|
||||
<BarsArrowUpIcon
|
||||
className={`h-3 w-3 flex-shrink-0 ${isStreaming ? "cursor-not-allowed" : "cursor-pointer"}`}
|
||||
/>
|
||||
</ToolbarButtonWithTooltip>
|
||||
<>
|
||||
<div
|
||||
data-tooltip-id={truncateTooltipId}
|
||||
onClick={(e) => {
|
||||
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"}`}
|
||||
>
|
||||
<BarsArrowUpIcon className="h-3 w-3 flex-shrink-0 opacity-60" />
|
||||
</div>
|
||||
<ToolTip id={truncateTooltipId}>
|
||||
{isStreaming ? "" : "Trim chat to this message"}
|
||||
</ToolTip>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue