Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(web): alignment tweaks for observation details (#17560)

Trang Nguyen1a9567fb51d8
diff --git a/web/src/components/table/ValueCell.tsx b/web/src/components/table/ValueCell.tsx
index 6997226573..132fedeb76 100644
--- a/web/src/components/table/ValueCell.tsx
+++ b/web/src/components/table/ValueCell.tsx
@@ -41,6 +41,11 @@ const ARRAY_PREVIEW_ITEMS = 3;
const MONO_TEXT_CLASSES = "font-mono text-xs wrap-break-word";
const PREVIEW_TEXT_CLASSES = "italic text-gray-500 dark:text-gray-400";
+const ROW_ACTION_BUTTON_CLASSES =
+ "text-muted-foreground absolute top-0 h-5 w-5 rounded-sm p-0 opacity-0 transition-opacity duration-200 group-hover:opacity-100 hover:bg-transparent hover:text-foreground";
+const ROW_COPY_OFFSET = "-right-0.5";
+const ROW_MENU_OFFSET = "-right-1.5";
+
function renderStringWithLinks(text: string): React.ReactNode {
if (text.length >= MAX_STRING_LENGTH_FOR_LINK_DETECTION) {
return text;
@@ -540,7 +545,8 @@ export const ValueCell = memo(
aria-label="Value actions"
title="Actions"
className={cn(
- "bg-background/80 hover:bg-background absolute top-1/2 right-1 h-4 w-4 -translate-y-1/2 border p-0 opacity-0 shadow-xs transition-opacity duration-200 group-hover:opacity-100",
+ ROW_ACTION_BUTTON_CLASSES,
+ ROW_MENU_OFFSET,
isOpen && "opacity-100",
)}
onClick={(event) => event.stopPropagation()}
@@ -554,15 +560,15 @@ export const ValueCell = memo(
<Button
variant="ghost"
size="icon"
- className="bg-background/80 hover:bg-background absolute top-0 right-0 h-5 w-5 border p-0.5 opacity-0 shadow-xs transition-opacity duration-200 group-hover:opacity-100"
+ className={cn(ROW_ACTION_BUTTON_CLASSES, ROW_COPY_OFFSET)}
onClick={handleCopy}
title="Copy value"
aria-label="Copy cell value"
>
{showCopySuccess ? (
- <Check className="h-2.5 w-2.5 text-green-600" />
+ <Check className="h-3 w-3" />
) : (
- <Copy className="h-2.5 w-2.5" />
+ <Copy className="h-3 w-3" />
)}
</Button>
)}
diff --git a/web/src/components/ui/MarkdownJsonView.tsx b/web/src/components/ui/MarkdownJsonView.tsx
index ff2cf553cc..7a65474a68 100644
--- a/web/src/components/ui/MarkdownJsonView.tsx
+++ b/web/src/components/ui/MarkdownJsonView.tsx
@@ -78,7 +78,7 @@ export function MarkdownJsonViewHeader({
return (
<div
className={cn(
- "io-message-header group-hover:bg-muted/80 flex flex-row items-center justify-between py-1 text-sm font-bold capitalize transition-colors",
+ "io-message-header flex flex-row items-center justify-between py-1 text-sm font-bold capitalize",
inset ? "px-2" : "px-1",
)}
>
@@ -132,7 +132,7 @@ export function MarkdownJsonViewHeader({
handleOnCopy(event);
setTimeout(() => setIsCopied(false), 1000);
}}
- className="hover:bg-border -mr-2"
+ className="text-muted-foreground hover:text-foreground hover:bg-transparent"
>
{isCopied ? (
<Check className="h-3 w-3" />
@@ -220,7 +220,6 @@ export function MarkdownJsonView({
title={title}
titleIcon={titleIcon}
className={className}
- hoverControls
media={media}
currentView="pretty"
controlButtons={controlButtons}
diff --git a/web/src/components/ui/MarkdownViewer.tsx b/web/src/components/ui/MarkdownViewer.tsx
index 5a27110128..56fb59e209 100644
--- a/web/src/components/ui/MarkdownViewer.tsx
+++ b/web/src/components/ui/MarkdownViewer.tsx
@@ -576,13 +576,12 @@ export function MarkdownView({
: undefined
}
/>
- <div className="border-t" />
</>
) : null}
{afterHeader}
<div
className={cn(
- "io-message-content ph-no-capture grid grid-flow-row gap-2 px-1 py-2",
+ "io-message-content ph-no-capture text-foreground-secondary grid grid-flow-row gap-2 px-1 pt-1 pb-2",
title === "assistant" || title === "Output" || title === "Model"
? "bg-accent-light-green"
: "",
diff --git a/web/src/components/ui/PrettyJsonView.tsx b/web/src/components/ui/PrettyJsonView.tsx
index 849519784e..bd0ec39b41 100644
--- a/web/src/components/ui/PrettyJsonView.tsx
+++ b/web/src/components/ui/PrettyJsonView.tsx
@@ -780,9 +780,6 @@ export function PrettyJsonView(props: {
inset?: boolean;
/** Content to render between header and main content (e.g., thinking blocks) */
afterHeader?: React.ReactNode;
- /** Titled sections (Input/Output/Metadata): header controls (copy,
- expand-all) reveal on section hover instead of rendering always. */
- hoverControls?: boolean;
/** When set, rows show an actions menu with copy + add-to-filter shortcuts
(metadata views only). */
metadataActions?: MetadataFilterActions;
@@ -1236,6 +1233,12 @@ export function PrettyJsonView(props: {
}
};
+ const hasExpandableRows = useMemo(() => {
+ if (typeof parsedJson !== "object" || parsedJson === null) return false;
+ return Object.values(parsedJson as Record<string, unknown>).some((value) =>
+ hasChildren(value, getValueType(value)),
+ );
+ }, [parsedJson]);
const emptyValueDisplay = getEmptyValueDisplay(parsedJson);
const isPrettyView = actualCurrentView === "pretty";
const isMarkdownMode = isMarkdown && isPrettyView;
@@ -1427,12 +1430,12 @@ export function PrettyJsonView(props: {
const expandCollapseButton = (
<>
- {shouldUseTableView && (
+ {shouldUseTableView && hasExpandableRows && (
<Button
variant="ghost"
size="icon-xs"
onClick={() => expandAllRef.current?.()}
- className="hover:bg-border -mr-2"
+ className="text-muted-foreground hover:text-foreground hover:bg-transparent"
title={allRowsExpanded ? "Collapse all rows" : "Expand all rows"}
>
{allRowsExpanded ? (
@@ -1447,7 +1450,7 @@ export function PrettyJsonView(props: {
variant="ghost"
size="icon-xs"
onClick={handleJsonToggleCollapse}
- className="hover:bg-border -mr-2"
+ className="text-muted-foreground hover:text-foreground hover:bg-transparent"
title={jsonIsCollapsed ? "Expand all" : "Collapse all"}
>
{jsonIsCollapsed ? (
@@ -1464,7 +1467,7 @@ export function PrettyJsonView(props: {
<div
className={cn(
"flex max-h-full min-h-0 flex-col",
- props.hoverControls && "group/iosection",
+ "group/iosection",
props.inset && "[&_.io-message-content]:px-2",
props.className,
props.scrollable ? "overflow-hidden" : "",
@@ -1486,7 +1489,7 @@ export function PrettyJsonView(props: {
: undefined
}
inset={props.inset}
- hoverRevealControls={props.hoverControls}
+ hoverRevealControls
controlButtons={
<>
{expandCollapseButton}
diff --git a/web/src/features/traces/components/ChatMessageList.tsx b/web/src/features/traces/components/ChatMessageList.tsx
index 750483e4cc..73dab00c38 100644
--- a/web/src/features/traces/components/ChatMessageList.tsx
+++ b/web/src/features/traces/components/ChatMessageList.tsx
@@ -1,4 +1,4 @@
-import { Fragment, useMemo, useState } from "react";
+import { useMemo, useState } from "react";
import { Button } from "@/src/components/ui/button";
import { PrettyJsonView } from "@/src/components/ui/PrettyJsonView";
import {
@@ -120,7 +120,7 @@ export function ChatMessageList({
<div className="flex max-h-full min-h-0 flex-col gap-2">
<div className="flex flex-col gap-2">
{visibleMessages.map(({ message, originalIndex }) => (
- <Fragment key={originalIndex}>
+ <div className="flex flex-col gap-1" key={originalIndex}>
<ChatMessage
message={message}
shouldRenderMarkdown={shouldRenderMarkdown}
@@ -136,14 +136,14 @@ export function ChatMessageList({
variant="ghost"
size="xs"
onClick={() => setCollapsed((v) => !v)}
- className="underline"
+ className="text-muted-foreground hover:text-foreground w-fit pl-2 underline hover:bg-transparent"
>
{isCollapsed
- ? `Show ${messagesToRender.length - COLLAPSE_THRESHOLD} more ...`
+ ? `Show ${messagesToRender.length - COLLAPSE_THRESHOLD} more`
: "Hide history"}
</Button>
)}
- </Fragment>
+ </div>
))}
</div>
diff --git a/web/src/features/traces/components/IOPreview/IOPreviewPretty.tsx b/web/src/features/traces/components/IOPreview/IOPreviewPretty.tsx
index 94e2d6f51b..fddf03f12b 100644
--- a/web/src/features/traces/components/IOPreview/IOPreviewPretty.tsx
+++ b/web/src/features/traces/components/IOPreview/IOPreviewPretty.tsx
@@ -58,7 +58,7 @@ function JsonInputOutputView({
const showOutput = !hideOutput && !(hideIfNull && !parsedOutput);
return (
- <div className="[&_.io-message-content]:px-2 [&_.io-message-header]:px-2">
+ <div className="space-y-2 [&_.io-message-content]:px-2 [&_.io-message-header]:px-2">
{showInput && (
<PrettyJsonView
title="Input"
@@ -313,7 +313,7 @@ export function IOPreviewPretty({
const shouldRenderMessages = hasRenderableChatMessages(parserResult);
return (
- <div>
+ <div className="space-y-2 pt-1">
{showData && status ? (
<StatusMessageSection status={status} currentView="pretty" />
) : null}
@@ -352,7 +352,7 @@ export function IOPreviewPretty({
)}
</div>
) : showData ? (
- <>
+ <div>
<JsonInputOutputView {...jsonViewProps} />
<div className="[&_.io-message-content]:px-2 [&_.io-message-header]:px-2">
{showCorrections && (
@@ -366,7 +366,7 @@ export function IOPreviewPretty({
/>
)}
</div>
- </>
+ </div>
) : null}
{/* Metadata Section */}
diff --git a/web/src/features/traces/components/IOPreview/components/ChatMessage.tsx b/web/src/features/traces/components/IOPreview/components/ChatMessage.tsx
index 23dab5a1b9..d74401a0d0 100644
--- a/web/src/features/traces/components/IOPreview/components/ChatMessage.tsx
+++ b/web/src/features/traces/components/IOPreview/components/ChatMessage.tsx
@@ -89,7 +89,7 @@ export function ChatMessage({
// Placeholder message
if (isPlaceholderMessage(message)) {
return (
- <div className="hover:bg-muted transition-colors">
+ <div className="transition-colors">
<div style={{ display: shouldRenderMarkdown ? "block" : "none" }}>
<MarkdownJsonView
title="Placeholder"
@@ -101,7 +101,6 @@ export function ChatMessage({
title="Placeholder"
json={message.name || "Unnamed placeholder"}
currentView={currentView}
- hoverControls
/>
</div>
</div>
@@ -111,12 +110,11 @@ export function ChatMessage({
// JSON-only message (non-ChatML object)
if (isOnlyJsonMessage(message)) {
return (
- <div className="hover:bg-muted transition-colors">
+ <div className="transition-colors">
<PrettyJsonView
title={title || (isOutputMessage ? "Output" : "Input")}
json={message.json}
currentView={currentView}
- hoverControls
/>
</div>
);
@@ -125,13 +123,12 @@ export function ChatMessage({
// User toggled to show passthrough JSON
if (showTableView) {
return (
- <div className="hover:bg-muted transition-colors">
+ <div className="transition-colors">
<PrettyJsonView
title={title}
json={message.json}
currentView="pretty"
controlButtons={passthroughToggleButton}
- hoverControls
/>
</div>
);
@@ -145,7 +142,7 @@ export function ChatMessage({
toolCalls.length > 0
) {
return (
- <div className="hover:bg-muted transition-colors">
+ <div className="transition-colors">
<MarkdownJsonViewHeader
title={title}
handleOnCopy={() => {
@@ -190,7 +187,7 @@ export function ChatMessage({
);
return (
- <div className="hover:bg-muted transition-colors">
+ <div className="transition-colors">
{/* Markdown view */}
<div style={{ display: shouldRenderMarkdown ? "block" : "none" }}>
<MarkdownJsonView
@@ -220,7 +217,6 @@ export function ChatMessage({
controlButtons={passthroughToggleButton}
afterHeader={thinkingBlocks}
isSystemPrompt={isSystemPrompt}
- hoverControls
/>
{showData && toolCalls.length > 0 && (
<div className="mt-2">
@@ -238,12 +234,11 @@ export function ChatMessage({
// Fallback: message with additional data but no content
if (hasAdditionalData(message)) {
return (
- <div className="hover:bg-muted transition-colors">
+ <div className="transition-colors">
<PrettyJsonView
title={title || (isOutputMessage ? "Output" : "Input")}
json={withoutUnsetFields(message)}
currentView={currentView}
- hoverControls
/>
</div>
);
diff --git a/web/src/features/traces/components/ObservationDetailView/ObservationAttributesTab.tsx b/web/src/features/traces/components/ObservationDetailView/ObservationAttributesTab.tsx
index 4d763189bf..49405a9ac7 100644
--- a/web/src/features/traces/components/ObservationDetailView/ObservationAttributesTab.tsx
+++ b/web/src/features/traces/components/ObservationDetailView/ObservationAttributesTab.tsx
@@ -49,7 +49,7 @@ export function ObservationAttributesTab({
return (
<div className="flex min-h-0 w-full flex-1 flex-col overflow-auto pb-4">
- <div className="space-y-4 pt-2">
+ <div className="space-y-2 pt-1">
{hasAttributes ? (
<div className={SECTION_CLASS}>
<PrettyJsonView
@@ -66,7 +66,6 @@ export function ObservationAttributesTab({
analyticsTable="attributes"
/>
)}
- hoverControls
/>
</div>
) : null}
@@ -77,7 +76,6 @@ export function ObservationAttributesTab({
showHeader={false}
json={modelParameters}
currentView={currentView}
- hoverControls
/>
</div>
) : null}
@@ -99,7 +97,6 @@ export function ObservationAttributesTab({
parsedJson={parsedMetadata}
currentView={currentView}
metadataActions={metadataActions}
- hoverControls
/>
)}
</div>
diff --git a/web/src/features/traces/components/TraceDetailView/TraceDetailView.tsx b/web/src/features/traces/components/TraceDetailView/TraceDetailView.tsx
index e0fad0d5dd..d194d34cab 100644
--- a/web/src/features/traces/components/TraceDetailView/TraceDetailView.tsx
+++ b/web/src/features/traces/components/TraceDetailView/TraceDetailView.tsx
@@ -404,12 +404,12 @@ export function TraceDetailView({
{trace.tags.length > 0 && (
<>
<div
- className={`px-2 pt-2 text-sm font-bold ${!isPrettyLikeView ? "shrink-0" : ""}`}
+ className={`px-2 pt-1 text-sm font-bold ${!isPrettyLikeView ? "shrink-0" : ""}`}
>
Tags
</div>
<div
- className={`flex flex-wrap gap-x-1 gap-y-1 px-2 pb-2 ${!isPrettyLikeView ? "shrink-0" : ""}`}
+ className={`flex flex-wrap gap-x-1 gap-y-1 px-2 pb-3 ${!isPrettyLikeView ? "shrink-0" : ""}`}
>
<TagList selectedTags={trace.tags} isLoading={false} />
</div>