🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(scores-table-cell): add copy to clipboard functionality and fix scroll-behaviour (#11616)
marliessophie9cbebbf4a05d
diff --git a/web/src/components/scores-table-cell.tsx b/web/src/components/scores-table-cell.tsxindex becde9d4d0..a9044de76d 100644--- a/web/src/components/scores-table-cell.tsx+++ b/web/src/components/scores-table-cell.tsx@@ -10,12 +10,14 @@ import {import { numberFormatter } from "@/src/utils/numbers";import { cn } from "@/src/utils/tailwind";-import { BracesIcon, MessageCircleMore } from "lucide-react";+import { BracesIcon, MessageCircleMore, Copy, Check } from "lucide-react";import { JSONView } from "@/src/components/ui/CodeJsonViewer";import { api } from "@/src/utils/api";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";import { Skeleton } from "@/src/components/ui/skeleton";import React from "react";+import { copyTextToClipboard } from "@/src/utils/clipboard";+import { Button } from "@/src/components/ui/button";const COLOR_MAP = new Map([["True", "bg-light-green p-0.5 text-dark-green"],@@ -53,6 +55,16 @@ export const ScoresTableCell = ({hasMetadata?: boolean;}) => {const projectId = useProjectIdFromURL();+ const [copied, setCopied] = React.useState(false);++ const handleCopy = async (e: React.MouseEvent<HTMLButtonElement>) => {+ e.stopPropagation();+ if (aggregate.comment) {+ await copyTextToClipboard(aggregate.comment);+ setCopied(true);+ setTimeout(() => setCopied(false), 2000);+ }+ };if (displayFormat === "smart" && aggregate.values.length === 1 && projectId) {const value =@@ -70,8 +82,25 @@ export const ScoresTableCell = ({<HoverCardTrigger className="inline-block cursor-pointer"><MessageCircleMore size={12} /></HoverCardTrigger>- <HoverCardContent className="overflow-hidden whitespace-normal break-normal text-xs">- <p className="whitespace-pre-wrap">{aggregate.comment}</p>+ <HoverCardContent className="flex flex-col whitespace-normal break-normal p-0 text-xs">+ <div className="sticky top-0 z-10 flex h-8 items-center justify-end bg-popover px-1">+ <Button+ onClick={handleCopy}+ variant="ghost"+ size="icon-xs"+ className="rounded p-1 hover:bg-accent"+ aria-label={copied ? "Copied" : "Copy to clipboard"}+ >+ {copied ? (+ <Check className="h-3 w-3" />+ ) : (+ <Copy className="h-3 w-3" />+ )}+ </Button>+ </div>+ <div className="max-h-[40vh] overflow-y-auto p-3 pt-0">+ <p className="whitespace-pre-wrap">{aggregate.comment}</p>+ </div></HoverCardContent></HoverCard>)}