Skip to content

Commit 896c79c

Browse files
committed
Fix for wrapping text on run inspector
1 parent cf0fdde commit 896c79c

File tree

2 files changed

+57
-12
lines changed
  • apps/webapp/app
    • components/primitives
    • routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.spans.$spanParam

2 files changed

+57
-12
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { ClipboardCheckIcon, ClipboardIcon } from "lucide-react";
2+
import { useCopy } from "~/hooks/useCopy";
3+
import { cn } from "~/utils/cn";
4+
5+
type CopyTextLinkProps = {
6+
value: string;
7+
className?: string;
8+
};
9+
10+
export function CopyTextLink({ value, className }: CopyTextLinkProps) {
11+
const { copy, copied } = useCopy(value);
12+
13+
return (
14+
<button
15+
type="button"
16+
onClick={copy}
17+
className={cn(
18+
"inline-flex cursor-pointer items-center gap-1 text-xs transition-colors",
19+
copied
20+
? "text-success"
21+
: "text-text-dimmed hover:text-text-bright",
22+
className
23+
)}
24+
>
25+
{copied ? "Copied" : "Copy"}
26+
{copied ? (
27+
<ClipboardCheckIcon className="size-3" />
28+
) : (
29+
<ClipboardIcon className="size-3" />
30+
)}
31+
</button>
32+
);
33+
}

apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.spans.$spanParam/route.tsx

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { MachineTooltipInfo } from "~/components/MachineTooltipInfo";
3232
import { Button, LinkButton } from "~/components/primitives/Buttons";
3333
import { Callout } from "~/components/primitives/Callout";
3434
import { CopyableText } from "~/components/primitives/CopyableText";
35+
import { CopyTextLink } from "~/components/primitives/CopyTextLink";
3536
import { DateTime, DateTimeAccurate } from "~/components/primitives/DateTime";
3637
import { Header2, Header3 } from "~/components/primitives/Headers";
3738
import { Paragraph } from "~/components/primitives/Paragraph";
@@ -263,19 +264,21 @@ function SpanBody({
263264
span.entity?.type === "prompt";
264265

265266
return (
266-
<div className={cn(
267-
"grid h-full max-h-full overflow-hidden bg-background-bright",
268-
isAiInspector ? "grid-rows-[auto_1fr]" : "grid-rows-[2.5rem_1fr]"
269-
)}>
267+
<div
268+
className={cn(
269+
"grid h-full max-h-full overflow-hidden bg-background-bright",
270+
isAiInspector ? "grid-rows-[auto_1fr]" : "grid-rows-[2.5rem_1fr]"
271+
)}
272+
>
270273
<div className="border-b border-grid-bright px-3 pr-2">
271-
<div className="flex h-10 items-center justify-between gap-2 overflow-x-hidden">
272-
<div className="flex items-center gap-1 overflow-x-hidden">
274+
<div className="grid h-10 grid-cols-[minmax(0,1fr)_auto] items-center gap-2">
275+
<div className="flex min-w-0 items-center gap-1">
273276
<RunIcon
274277
name={span.style?.icon}
275278
spanName={span.message}
276279
className="size-5 min-h-5 min-w-5"
277280
/>
278-
<Header2 className={cn("overflow-x-hidden")}>
281+
<Header2 className="min-w-0">
279282
<SpanTitle {...span} size="large" hideAccessory overrideDimmed />
280283
</Header2>
281284
</div>
@@ -311,7 +314,6 @@ function formatSpanDuration(nanoseconds: number): string {
311314
return `${mins}m ${secs}s`;
312315
}
313316

314-
315317
function applySpanOverrides(span: Span, spanOverrides?: SpanOverride): Span {
316318
if (!spanOverrides) {
317319
return span;
@@ -1259,8 +1261,13 @@ function SpanEntity({ span }: { span: Span }) {
12591261
)}
12601262
<Property.Table>
12611263
<Property.Item>
1262-
<Property.Label>Message</Property.Label>
1263-
<Property.Value className="whitespace-pre-wrap">{span.message}</Property.Value>
1264+
<Property.Label className="flex items-center justify-between">
1265+
<span>Message</span>
1266+
<CopyTextLink value={span.message} />
1267+
</Property.Label>
1268+
<Property.Value className="whitespace-pre-wrap [overflow-wrap:break-word]">
1269+
{span.message}
1270+
</Property.Value>
12641271
</Property.Item>
12651272
</Property.Table>
12661273
{span.events.length > 0 && <SpanEvents spanEvents={span.events} />}
@@ -1416,7 +1423,13 @@ function SpanEntity({ span }: { span: Span }) {
14161423
<AISpanDetails
14171424
aiData={span.entity.object}
14181425
promptVersionData={span.entity.promptVersionData}
1419-
rawProperties={typeof span.properties === "string" ? span.properties : span.properties != null ? JSON.stringify(span.properties, null, 2) : undefined}
1426+
rawProperties={
1427+
typeof span.properties === "string"
1428+
? span.properties
1429+
: span.properties != null
1430+
? JSON.stringify(span.properties, null, 2)
1431+
: undefined
1432+
}
14201433
startTime={span.startTime}
14211434
duration={span.duration}
14221435
/>
@@ -1456,4 +1469,3 @@ function SpanEntity({ span }: { span: Span }) {
14561469
}
14571470
}
14581471
}
1459-

0 commit comments

Comments
 (0)