Skip to content

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

fix(web): padded markdown box in the JSON view, aligned system prompt link (#18637)

Trang Nguyen8c26de8773d8
diff --git a/web/src/components/design-system/Button/Button.stories.tsx b/web/src/components/design-system/Button/Button.stories.tsx
index 6b0c71cd70..cec10edfa5 100644
--- a/web/src/components/design-system/Button/Button.stories.tsx
+++ b/web/src/components/design-system/Button/Button.stories.tsx
@@ -21,7 +21,7 @@ export const VariantMatrix = meta.story({
parameters: { controls: { disable: true } },
render: () => (
<div className="grid grid-cols-2 items-center gap-3">
- {(["primary", "secondary", "destructive", "ghost"] as const).map(
+ {(["primary", "secondary", "destructive", "ghost", "text"] as const).map(
(variant) =>
(["default", "sm"] as const).map((size) => (
<Button
diff --git a/web/src/components/design-system/Button/Button.tsx b/web/src/components/design-system/Button/Button.tsx
index 1450e1e401..30382d2911 100644
--- a/web/src/components/design-system/Button/Button.tsx
+++ b/web/src/components/design-system/Button/Button.tsx
@@ -17,12 +17,15 @@ const buttonVariants = cva(
destructive:
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
ghost: "hover:bg-accent hover:text-accent-foreground",
+ /** Inline text action: muted, underlined, no box. */
+ text: "text-muted-foreground hover:text-foreground underline",
},
size: {
default: "h-8 px-3 py-1 text-sm",
sm: "h-7 px-2 text-xs",
},
},
+ compoundVariants: [{ variant: "text", class: "h-auto px-0 py-0" }],
defaultVariants: {
variant: "primary",
size: "default",
@@ -37,6 +40,7 @@ const buttonIconVariants = cva("icon-base shrink-0", {
secondary: "",
destructive: "",
ghost: "text-icon-foreground",
+ text: "",
},
},
defaultVariants: {
@@ -46,7 +50,7 @@ const buttonIconVariants = cva("icon-base shrink-0", {
type ButtonProps = {
text: string;
- variant?: "primary" | "secondary" | "destructive" | "ghost";
+ variant?: "primary" | "secondary" | "destructive" | "ghost" | "text";
size?: "default" | "sm";
} & (
| {
@@ -72,10 +76,13 @@ type ButtonProps = {
);
export function Button(props: ButtonProps) {
- const className = buttonVariants({
- variant: props.variant,
- size: props.size,
- });
+ // twMerge so the text variant's px-0/h-auto win over the size defaults.
+ const className = cn(
+ buttonVariants({
+ variant: props.variant,
+ size: props.size,
+ }),
+ );
const iconClassName = buttonIconVariants({ variant: props.variant });
if (props.href !== undefined) {
diff --git a/web/src/components/ui/MarkdownViewer.tsx b/web/src/components/ui/MarkdownViewer.tsx
index 673b50bd26..a797dc61e2 100644
--- a/web/src/components/ui/MarkdownViewer.tsx
+++ b/web/src/components/ui/MarkdownViewer.tsx
@@ -42,7 +42,7 @@ import { MarkdownJsonViewHeader } from "@/src/components/ui/MarkdownJsonView";
import { copyTextToClipboard } from "@/src/utils/clipboard";
import { MENTION_USER_PREFIX } from "@/src/features/comments/lib/mentionParser";
import { useCollapsibleSystemPrompt } from "@/src/hooks/useCollapsibleSystemPrompt";
-import { Button } from "@/src/components/ui/button";
+import { Button } from "@/src/components/design-system/Button/Button";
import { getSafeImageUrl, getSafeLinkUrl } from "@/src/components/ui/safe-url";
import { env } from "@/src/env.mjs";
import {
@@ -580,14 +580,13 @@ export function MarkdownView({
);
const collapseToggle = shouldBeCollapsible ? (
- <Button
- variant="ghost"
- size="xs"
- onClick={() => toggleCollapsed("inline")}
- className="w-fit text-xs underline"
- >
- {isCollapsed ? "Expand system prompt" : "Collapse system prompt"}
- </Button>
+ <div className="flex">
+ <Button
+ variant="text"
+ onClick={() => toggleCollapsed("inline")}
+ text={isCollapsed ? "Expand system prompt" : "Collapse system prompt"}
+ />
+ </div>
) : null;
return (
diff --git a/web/src/components/ui/PrettyJsonView.tsx b/web/src/components/ui/PrettyJsonView.tsx
index 4df92c2f6e..1cd457c07a 100644
--- a/web/src/components/ui/PrettyJsonView.tsx
+++ b/web/src/components/ui/PrettyJsonView.tsx
@@ -1206,7 +1206,7 @@ export function PrettyJsonView(props: {
const getBackgroundColorClass = () =>
ASSISTANT_TITLES.includes(props.title || "")
- ? "bg-surface-output rounded-md overflow-clip"
+ ? "bg-surface-output rounded-md overflow-clip px-3 pt-1"
: "";
const body = (
diff --git a/web/src/features/traces/components/ChatMessageList.tsx b/web/src/features/traces/components/ChatMessageList.tsx
index 545d8a7554..e72ceac940 100644
--- a/web/src/features/traces/components/ChatMessageList.tsx
+++ b/web/src/features/traces/components/ChatMessageList.tsx
@@ -1,5 +1,5 @@
import { useMemo, useState } from "react";
-import { Button } from "@/src/components/ui/button";
+import { Button } from "@/src/components/design-system/Button/Button";
import { PrettyJsonView } from "@/src/components/ui/PrettyJsonView";
import {
filterAlreadyRenderedMedia,
@@ -132,16 +132,17 @@ export function ChatMessageList({
{/* Show collapse/expand button after first message */}
{isCollapsed !== null &&
originalIndex === messagesToRender[0]?.originalIndex && (
- <Button
- variant="ghost"
- size="xs"
- onClick={() => setCollapsed((v) => !v)}
- className="text-muted-foreground hover:text-foreground mt-1 mb-2 w-fit px-0 underline hover:bg-transparent"
- >
- {isCollapsed
- ? `Show ${messagesToRender.length - COLLAPSE_THRESHOLD} more`
- : "Hide history"}
- </Button>
+ <div className="mt-1 mb-2 flex">
+ <Button
+ variant="text"
+ onClick={() => setCollapsed((v) => !v)}
+ text={
+ isCollapsed
+ ? `Show ${messagesToRender.length - COLLAPSE_THRESHOLD} more`
+ : "Hide history"
+ }
+ />
+ </div>
)}
</div>
))}