add paste-back button to assistant action bar

This commit is contained in:
CREDO23 2026-03-26 20:30:19 +02:00
parent 5bb4f5c084
commit 2adffccd92

View file

@ -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 (
<ActionBarPrimitive.Root
@ -295,7 +298,17 @@ const AssistantActionBar: FC = () => {
<DownloadIcon />
</TooltipIconButton>
</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 && (
<ActionBarPrimitive.Reload asChild>
<TooltipIconButton tooltip="Refresh">