Skip to content

Commit e05f652

Browse files
Merge pull request #3318 from Agenta-AI/improve/add-copy-button-on-evaluation-cells
[fix]: added copy button on evaluation cell
2 parents be52f90 + ec118e7 commit e05f652

File tree

4 files changed

+38
-12
lines changed

4 files changed

+38
-12
lines changed

web/oss/src/components/EvalRunDetails/components/TableCells/CellContentPopover.tsx

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,50 @@ import {memo, type ReactNode} from "react"
22

33
import {Popover} from "antd"
44

5+
import CopyButton from "@/oss/components/CopyButton/CopyButton"
6+
57
interface CellContentPopoverProps {
68
children: ReactNode
79
content: ReactNode
810
disabled?: boolean
11+
copyContent?: string
912
}
1013

1114
/**
1215
* Wraps table cell content with a hover popover that shows the full content.
1316
* Used to preview truncated cell content without opening the focus drawer.
1417
*/
15-
const CellContentPopover = ({children, content, disabled}: CellContentPopoverProps) => {
18+
const CellContentPopover = ({
19+
children,
20+
content,
21+
disabled,
22+
copyContent,
23+
}: CellContentPopoverProps) => {
1624
if (disabled) {
1725
return <>{children}</>
1826
}
1927

28+
const popoverContent = (
29+
<div className="relative">
30+
<div className="max-w-[400px] max-h-[300px] overflow-auto text-xs pr-6">{content}</div>
31+
{copyContent && (
32+
<div className="absolute -top-1 -right-1">
33+
<CopyButton
34+
text={copyContent}
35+
icon={true}
36+
buttonText={null}
37+
size="small"
38+
stopPropagation={true}
39+
type="text"
40+
/>
41+
</div>
42+
)}
43+
</div>
44+
)
45+
2046
return (
2147
<Popover
22-
content={
23-
<div className="max-w-[400px] max-h-[300px] overflow-auto text-xs">{content}</div>
24-
}
48+
content={popoverContent}
2549
trigger="hover"
2650
mouseEnterDelay={0.5}
2751
mouseLeaveDelay={0.1}

web/oss/src/components/EvalRunDetails/components/TableCells/InputCell.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ const PreviewEvaluationInputCell = ({
168168

169169
if (chatNodes && chatNodes.length) {
170170
return (
171-
<CellContentPopover content={popoverContent}>
171+
<CellContentPopover content={popoverContent} copyContent={safeJsonStringify(value)}>
172172
<div ref={ref} className={CONTAINER_CLASS} style={widthStyle}>
173173
<div className="flex w-full flex-col gap-2">{chatNodes}</div>
174174
</div>
@@ -179,7 +179,7 @@ const PreviewEvaluationInputCell = ({
179179
// Render JSON objects/arrays using the JSON editor
180180
if (isJson) {
181181
return (
182-
<CellContentPopover content={popoverContent}>
182+
<CellContentPopover content={popoverContent} copyContent={safeJsonStringify(jsonValue)}>
183183
<div ref={ref} className={CONTAINER_CLASS} style={widthStyle}>
184184
<JsonContent value={jsonValue} />
185185
</div>
@@ -188,7 +188,7 @@ const PreviewEvaluationInputCell = ({
188188
}
189189

190190
return (
191-
<CellContentPopover content={popoverContent}>
191+
<CellContentPopover content={popoverContent} copyContent={displayValue}>
192192
<div ref={ref} className={CONTAINER_CLASS} style={widthStyle}>
193193
<span className="scenario-table-text whitespace-pre-wrap">{displayValue}</span>
194194
</div>

web/oss/src/components/EvalRunDetails/components/TableCells/InvocationCell.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,9 @@ const PreviewEvaluationInvocationCell = ({
215215
</div>
216216
)
217217

218+
const errorCopyContent = `${stepError?.message}${stepError?.stacktrace ? `\n${stepError?.stacktrace}` : ""}`
218219
return (
219-
<CellContentPopover content={errorPopoverContent}>
220+
<CellContentPopover content={errorPopoverContent} copyContent={errorCopyContent}>
220221
<div
221222
ref={ref}
222223
className={clsx(CONTAINER_CLASS, "!justify-between")}
@@ -264,7 +265,7 @@ const PreviewEvaluationInvocationCell = ({
264265

265266
if (chatNodes && chatNodes.length) {
266267
return (
267-
<CellContentPopover content={popoverContent}>
268+
<CellContentPopover content={popoverContent} copyContent={safeJsonStringify(value)}>
268269
<div ref={ref} className={CONTAINER_CLASS} style={widthStyle}>
269270
<div className="scenario-invocation-content flex-1 min-h-0 overflow-hidden">
270271
<div className="flex w-full flex-col gap-2">{chatNodes}</div>
@@ -284,7 +285,7 @@ const PreviewEvaluationInvocationCell = ({
284285
// Render JSON objects/arrays using the JSON editor
285286
if (isJson) {
286287
return (
287-
<CellContentPopover content={popoverContent}>
288+
<CellContentPopover content={popoverContent} copyContent={safeJsonStringify(jsonValue)}>
288289
<div
289290
ref={ref}
290291
className={clsx(CONTAINER_CLASS, "!justify-between")}
@@ -306,7 +307,7 @@ const PreviewEvaluationInvocationCell = ({
306307
}
307308

308309
return (
309-
<CellContentPopover content={popoverContent}>
310+
<CellContentPopover content={popoverContent} copyContent={displayValue}>
310311
<div ref={ref} className={clsx(CONTAINER_CLASS, "!justify-between")} style={widthStyle}>
311312
<div className="scenario-invocation-content flex-1 min-h-0 overflow-hidden">
312313
<span className="scenario-table-text whitespace-pre-wrap">{displayValue}</span>

web/oss/src/components/EvalRunDetails/components/TableCells/MetricCell.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,9 @@ const PreviewEvaluationMetricCell = ({
277277
</div>
278278
)
279279

280+
const errorCopyContent = `${stepError.message}${stepError.stacktrace ? `\n${stepError.stacktrace}` : ""}`
280281
return (
281-
<CellContentPopover content={errorPopoverContent}>
282+
<CellContentPopover content={errorPopoverContent} copyContent={errorCopyContent}>
282283
<div
283284
ref={ref}
284285
className={CONTAINER_CLASS}

0 commit comments

Comments
 (0)