mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-12 01:02:39 +02:00
add paste-back button to assistant action bar
This commit is contained in:
parent
5bb4f5c084
commit
2adffccd92
1 changed files with 15 additions and 2 deletions
|
|
@ -3,10 +3,11 @@ import {
|
||||||
AuiIf,
|
AuiIf,
|
||||||
ErrorPrimitive,
|
ErrorPrimitive,
|
||||||
MessagePrimitive,
|
MessagePrimitive,
|
||||||
|
useAui,
|
||||||
useAuiState,
|
useAuiState,
|
||||||
} from "@assistant-ui/react";
|
} from "@assistant-ui/react";
|
||||||
import { useAtomValue } from "jotai";
|
import { useAtomValue } from "jotai";
|
||||||
import { CheckIcon, CopyIcon, DownloadIcon, MessageSquare, RefreshCwIcon } from "lucide-react";
|
import { CheckIcon, ClipboardPaste, CopyIcon, DownloadIcon, MessageSquare, RefreshCwIcon } from "lucide-react";
|
||||||
import type { FC } from "react";
|
import type { FC } from "react";
|
||||||
import { useEffect, useMemo, useRef, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { commentsEnabledAtom, targetCommentIdAtom } from "@/atoms/chat/current-thread.atom";
|
import { commentsEnabledAtom, targetCommentIdAtom } from "@/atoms/chat/current-thread.atom";
|
||||||
|
|
@ -272,6 +273,8 @@ export const AssistantMessage: FC = () => {
|
||||||
|
|
||||||
const AssistantActionBar: FC = () => {
|
const AssistantActionBar: FC = () => {
|
||||||
const isLast = useAuiState((s) => s.message.isLast);
|
const isLast = useAuiState((s) => s.message.isLast);
|
||||||
|
const aui = useAui();
|
||||||
|
const canReplace = isLast && typeof window !== "undefined" && !!window.electronAPI?.replaceText;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ActionBarPrimitive.Root
|
<ActionBarPrimitive.Root
|
||||||
|
|
@ -295,7 +298,17 @@ const AssistantActionBar: FC = () => {
|
||||||
<DownloadIcon />
|
<DownloadIcon />
|
||||||
</TooltipIconButton>
|
</TooltipIconButton>
|
||||||
</ActionBarPrimitive.ExportMarkdown>
|
</ActionBarPrimitive.ExportMarkdown>
|
||||||
{/* Only allow regenerating the last assistant message */}
|
{canReplace && (
|
||||||
|
<TooltipIconButton
|
||||||
|
tooltip="Paste back"
|
||||||
|
onClick={() => {
|
||||||
|
const text = aui.message().getCopyText();
|
||||||
|
window.electronAPI?.replaceText(text);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ClipboardPaste />
|
||||||
|
</TooltipIconButton>
|
||||||
|
)}
|
||||||
{isLast && (
|
{isLast && (
|
||||||
<ActionBarPrimitive.Reload asChild>
|
<ActionBarPrimitive.Reload asChild>
|
||||||
<TooltipIconButton tooltip="Refresh">
|
<TooltipIconButton tooltip="Refresh">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue