From 2adffccd9283124e53af162e3b89143ce6ac644f Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Thu, 26 Mar 2026 20:30:19 +0200 Subject: [PATCH] add paste-back button to assistant action bar --- .../assistant-ui/assistant-message.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/surfsense_web/components/assistant-ui/assistant-message.tsx b/surfsense_web/components/assistant-ui/assistant-message.tsx index 9fefecb1c..910e1fc89 100644 --- a/surfsense_web/components/assistant-ui/assistant-message.tsx +++ b/surfsense_web/components/assistant-ui/assistant-message.tsx @@ -3,10 +3,11 @@ import { AuiIf, ErrorPrimitive, MessagePrimitive, + useAui, useAuiState, } from "@assistant-ui/react"; 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 { useEffect, useMemo, useRef, useState } from "react"; import { commentsEnabledAtom, targetCommentIdAtom } from "@/atoms/chat/current-thread.atom"; @@ -272,6 +273,8 @@ export const AssistantMessage: FC = () => { const AssistantActionBar: FC = () => { const isLast = useAuiState((s) => s.message.isLast); + const aui = useAui(); + const canReplace = isLast && typeof window !== "undefined" && !!window.electronAPI?.replaceText; return ( { - {/* Only allow regenerating the last assistant message */} + {canReplace && ( + { + const text = aui.message().getCopyText(); + window.electronAPI?.replaceText(text); + }} + > + + + )} {isLast && (