Skip to content

Commit e3a10a0

Browse files
committed
feat(dashboard): add copy run id button to reflexion runs table
1 parent 82a6f66 commit e3a10a0

1 file changed

Lines changed: 37 additions & 1 deletion

File tree

src/components/dashboard/ReflexionRunsTable.tsx

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
'use client';
22

3+
import { useState } from 'react';
4+
import { Copy, Check } from 'lucide-react';
5+
import { Button } from '@/components/ui/button';
36
import {
47
Table,
58
TableBody,
@@ -11,6 +14,36 @@ import {
1114
import { Badge } from '@/components/ui/badge';
1215
import { ReflexionRun } from '@prisma/client';
1316

17+
function CopyRunIdButton({ runId }: { runId: string }) {
18+
const [copied, setCopied] = useState(false);
19+
20+
const handleCopy = async () => {
21+
try {
22+
await navigator.clipboard.writeText(runId);
23+
setCopied(true);
24+
setTimeout(() => setCopied(false), 2000);
25+
} catch (err) {
26+
console.error('Failed to copy text: ', err);
27+
}
28+
};
29+
30+
return (
31+
<Button
32+
variant="ghost"
33+
size="icon-xs"
34+
onClick={handleCopy}
35+
title="Copy Run ID"
36+
className="text-muted-foreground hover:text-foreground h-5 w-5 p-0"
37+
>
38+
{copied ? (
39+
<Check className="size-3 text-emerald-500" />
40+
) : (
41+
<Copy className="size-3" />
42+
)}
43+
</Button>
44+
);
45+
}
46+
1447
interface ReflexionRunsTableProps {
1548
runs: ReflexionRun[];
1649
}
@@ -57,7 +90,10 @@ export function ReflexionRunsTable({ runs }: ReflexionRunsTableProps) {
5790
return (
5891
<TableRow key={run.id}>
5992
<TableCell className="font-mono text-xs text-muted-foreground">
60-
{shortId}
93+
<div className="flex items-center gap-1.5">
94+
<span>{shortId}</span>
95+
<CopyRunIdButton runId={run.id} />
96+
</div>
6197
</TableCell>
6298
<TableCell className="font-medium" title={run.brief}>
6399
{truncatedBrief}

0 commit comments

Comments
 (0)