Skip to content

Commit b13308d

Browse files
authored
Merge pull request #4294 from berkay-digital/feat/copy-ai-log-analysis
feat: add copy button to AI log analysis result
2 parents 16746a1 + ad490dc commit b13308d

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

‎apps/dokploy/components/dashboard/docker/logs/analyze-logs.tsx‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use client";
2-
import { Bot, Loader2, RotateCcw, Settings, X } from "lucide-react";
2+
import copy from "copy-to-clipboard";
3+
import { Bot, Check, Copy, Loader2, RotateCcw, Settings, X } from "lucide-react";
34
import Link from "next/link";
45
import { useState } from "react";
56
import ReactMarkdown from "react-markdown";
@@ -30,6 +31,7 @@ const MAX_LOG_LINES = 200;
3031
export function AnalyzeLogs({ logs, context }: Props) {
3132
const [open, setOpen] = useState(false);
3233
const [aiId, setAiId] = useState<string>("");
34+
const [copied, setCopied] = useState(false);
3335
const { data: providers } = api.ai.getEnabledProviders.useQuery(undefined, {
3436
enabled: open,
3537
});
@@ -52,6 +54,15 @@ export function AnalyzeLogs({ logs, context }: Props) {
5254
mutate({ aiId, logs: logsText, context });
5355
};
5456

57+
const handleCopy = () => {
58+
if (!data?.analysis) return;
59+
const success = copy(data.analysis);
60+
if (success) {
61+
setCopied(true);
62+
setTimeout(() => setCopied(false), 2000);
63+
}
64+
};
65+
5566
return (
5667
<Popover
5768
open={open}
@@ -168,6 +179,18 @@ export function AnalyzeLogs({ logs, context }: Props) {
168179
)}
169180
Re-analyze
170181
</Button>
182+
<Button
183+
size="sm"
184+
variant="outline"
185+
onClick={handleCopy}
186+
title="Copy analysis to clipboard"
187+
>
188+
{copied ? (
189+
<Check className="h-3.5 w-3.5" />
190+
) : (
191+
<Copy className="h-3.5 w-3.5" />
192+
)}
193+
</Button>
171194
<Button
172195
size="sm"
173196
variant="ghost"

0 commit comments

Comments
 (0)