Skip to content

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

fix(web): update JSON viewer (#17402)

Trang Nguyen86862015ce69
diff --git a/web/src/components/table/ValueCell.tsx b/web/src/components/table/ValueCell.tsx
index cf85a33339..854b7323f1 100644
--- a/web/src/components/table/ValueCell.tsx
+++ b/web/src/components/table/ValueCell.tsx
@@ -39,8 +39,8 @@ export type MetadataFilterActions = {
const MAX_STRING_LENGTH_FOR_LINK_DETECTION = 1500;
const MAX_CELL_DISPLAY_CHARS = 2000;
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 VALUE_TEXT_CLASSES = "font-mono text-xs/5 wrap-break-word";
+const PREVIEW_TEXT_CLASSES = "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";
@@ -92,10 +92,8 @@ function getValueType(value: unknown): JsonTableRow["type"] {
return typeof value as JsonTableRow["type"];
}
-function renderArrayValue(arr: unknown[]): JSX.Element {
- if (arr.length === 0) {
- return <span className={PREVIEW_TEXT_CLASSES}>empty list</span>;
- }
+function arrayPreviewText(arr: unknown[]): string {
+ if (arr.length === 0) return "empty list";
if (arr.length <= SMALL_ARRAY_THRESHOLD) {
// Show inline values for small arrays
@@ -117,7 +115,7 @@ function renderArrayValue(arr: unknown[]): JSX.Element {
return String(item);
})
.join(", ");
- return <span className={PREVIEW_TEXT_CLASSES}>[{displayItems}]</span>;
+ return `[${displayItems}]`;
}
// Show truncated values for large arrays
const preview = arr
@@ -129,11 +127,11 @@ function renderArrayValue(arr: unknown[]): JSX.Element {
return String(item);
})
.join(", ");
- return (
- <span className={PREVIEW_TEXT_CLASSES}>
- [{preview}, ...{arr.length - ARRAY_PREVIEW_ITEMS} more]
- </span>
- );
+ return `[${preview}, ...${arr.length - ARRAY_PREVIEW_ITEMS} more]`;
+}
+
+function renderPreview(text: string): JSX.Element {
+ return <span className={PREVIEW_TEXT_CLASSES}>{text}</span>;
}
function formatPreviewPrimitive(value: unknown): string {
@@ -151,16 +149,10 @@ function formatShortObjectPreview(obj: Record<string, unknown>): string | null {
return `{${fields.join(", ")}}`;
}
-function renderObjectValue(obj: Record<string, unknown>): JSX.Element {
+function objectPreviewText(obj: Record<string, unknown>): string {
const keys = Object.keys(obj);
- if (keys.length === 0) {
- return <span className={PREVIEW_TEXT_CLASSES}>empty object</span>;
- }
- const shortPreview = formatShortObjectPreview(obj);
- if (shortPreview) {
- return <span className={PREVIEW_TEXT_CLASSES}>{shortPreview}</span>;
- }
- return <span className={PREVIEW_TEXT_CLASSES}>{keys.length} items</span>;
+ if (keys.length === 0) return "empty object";
+ return formatShortObjectPreview(obj) ?? `${keys.length} items`;
}
function getValueStringLength(value: unknown): number {
@@ -373,7 +365,8 @@ export const ValueCell = memo(
const handleCopy = async (e: React.MouseEvent) => {
e.stopPropagation();
- const copyValue = getCopyValue(value);
+ const copyValue =
+ typeof value === "string" ? JSON.stringify(value) : getCopyValue(value);
try {
await copyTextToClipboard(copyValue);
@@ -414,7 +407,7 @@ export const ValueCell = memo(
: "whitespace-pre-line"
}`}
>
- &quot;{renderStringWithLinks(displayValue)}&quot;
+ {renderStringWithLinks(displayValue)}
</span>
),
needsTruncation,
@@ -459,11 +452,11 @@ export const ValueCell = memo(
needsTruncation: false,
};
}
- const arrayValue = value as unknown[];
- // Arrays always show previews, never truncate
+ const arrayPreview = arrayPreviewText(value as unknown[]);
return {
- content: renderArrayValue(arrayValue),
+ content: renderPreview(arrayPreview),
needsTruncation: false,
+ previewTitle: arrayPreview,
};
}
case "object": {
@@ -475,11 +468,13 @@ export const ValueCell = memo(
needsTruncation: false,
};
}
- const objectValue = value as Record<string, unknown>;
- // Objects always show previews, never truncate
+ const objectPreview = objectPreviewText(
+ value as Record<string, unknown>,
+ );
return {
- content: renderObjectValue(objectValue),
+ content: renderPreview(objectPreview),
needsTruncation: false,
+ previewTitle: objectPreview,
};
}
default: {
@@ -502,11 +497,23 @@ export const ValueCell = memo(
}
};
- const { content, needsTruncation } = getDisplayValue();
+ const { content, needsTruncation, previewTitle } = getDisplayValue();
+ const singleLine = previewTitle !== undefined;
return (
- <div className={`${MONO_TEXT_CLASSES} group relative max-w-full`}>
- <span className="cursor-text">{content}</span>
+ <div
+ className={cn(
+ VALUE_TEXT_CLASSES,
+ "group relative max-w-full",
+ singleLine && "w-0 min-w-full",
+ )}
+ >
+ <span
+ className={cn("cursor-text", singleLine && "block truncate")}
+ title={previewTitle}
+ >
+ {content}
+ </span>
{needsTruncation && !row.original.hasChildren && (
<div
className="inline cursor-pointer opacity-50"
diff --git a/web/src/components/ui/CodeJsonViewer.tsx b/web/src/components/ui/CodeJsonViewer.tsx
index 7674fd228a..151c341bcd 100644
--- a/web/src/components/ui/CodeJsonViewer.tsx
+++ b/web/src/components/ui/CodeJsonViewer.tsx
@@ -103,8 +103,9 @@ export function JSONView(props: {
props.title === "assistant" || props.title === "Output"
? "bg-accent-light-green dark:border-accent-dark-green/30"
: "",
- props.title === "system" || props.title === "Input" ? "bg-card" : "",
- props.scrollable || props.borderless ? "" : "rounded-sm border",
+ props.scrollable || props.borderless || props.title
+ ? ""
+ : "rounded-sm border",
props.codeClassName,
)}
>
diff --git a/web/src/components/ui/MarkdownViewer.tsx b/web/src/components/ui/MarkdownViewer.tsx
index 08e32f305f..5d1129a5f2 100644
--- a/web/src/components/ui/MarkdownViewer.tsx
+++ b/web/src/components/ui/MarkdownViewer.tsx
@@ -584,9 +584,8 @@ export function MarkdownView({
className={cn(
"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"
+ ? "bg-accent-light-green overflow-hidden rounded-md"
: "",
- title === "system" || title === "Input" ? "bg-card" : "",
className,
)}
>
diff --git a/web/src/components/ui/PrettyJsonView.expansion.clienttest.tsx b/web/src/components/ui/PrettyJsonView.expansion.clienttest.tsx
index 00dc695a9a..2051c22e29 100644
--- a/web/src/components/ui/PrettyJsonView.expansion.clienttest.tsx
+++ b/web/src/components/ui/PrettyJsonView.expansion.clienttest.tsx
@@ -61,10 +61,8 @@ describe("PrettyJsonView short-list expansion", () => {
).not.toBeInTheDocument();
expect(within(expandedTable).getByText("0")).toBeInTheDocument();
expect(within(expandedTable).getByText("1")).toBeInTheDocument();
- expect(within(expandedTable).getByText('"email"')).toBeInTheDocument();
- expect(
- within(expandedTable).getByText('"paid_social"'),
- ).toBeInTheDocument();
+ expect(within(expandedTable).getByText("email")).toBeInTheDocument();
+ expect(within(expandedTable).getByText("paid_social")).toBeInTheDocument();
});
it("keeps the parent preview when every expanded child is hidden", () => {
@@ -148,6 +146,6 @@ describe("PrettyJsonView short-list expansion", () => {
within(expandedTable).queryByText('{"name": "Ada"}'),
).not.toBeInTheDocument();
expect(within(expandedTable).getByText("name")).toBeInTheDocument();
- expect(within(expandedTable).getByText('"Ada"')).toBeInTheDocument();
+ expect(within(expandedTable).getByText("Ada")).toBeInTheDocument();
});
});
diff --git a/web/src/components/ui/PrettyJsonView.tsx b/web/src/components/ui/PrettyJsonView.tsx
index f4a42a9d81..de28dfa6d3 100644
--- a/web/src/components/ui/PrettyJsonView.tsx
+++ b/web/src/components/ui/PrettyJsonView.tsx
@@ -66,12 +66,11 @@ import { ItemBadge, type LangfuseItemType } from "@/src/components/ItemBadge";
import { isLargeRenderString } from "@/src/components/ui/largeStringGate";
import { LargeStringFallback } from "@/src/components/ui/LargeStringFallback";
-// Constants for table layout
const INDENTATION_PER_LEVEL = 16;
-const INDENTATION_BASE = 8;
-const BUTTON_WIDTH = 16;
-const MARGIN_LEFT_1 = 4;
-const CELL_PADDING_X = 8; // px-2
+const INDENTATION_BASE = 12;
+const KEY_CLASSES = "text-muted-foreground font-mono text-xs/5 wrap-break-word";
+const CELL_CLASSES =
+ "border-border/60 py-1 pr-2 pl-1 align-top whitespace-normal";
// Constants for smart expansion logic
// Used for nested objects to control smart expansion depth
@@ -83,10 +82,8 @@ const DEFAULT_MAX_ROWS_IF_ROOT = 100;
const MAX_CELL_DISPLAY_CHARS = 2000;
const ASSISTANT_TITLES = ["assistant", "Output", "model"];
-const SYSTEM_TITLES = ["system", "Input"];
-const MONO_TEXT_CLASSES = "font-mono text-xs wrap-break-word";
-const PREVIEW_TEXT_CLASSES = "italic text-gray-500 dark:text-gray-400";
+const PREVIEW_TEXT_CLASSES = "text-gray-500 dark:text-gray-400";
type PrettyJsonViewTone = "danger" | "warning" | "muted" | "neutral";
@@ -167,14 +164,17 @@ function getContainerClasses(
scrollable: boolean | undefined,
codeClassName: string | undefined,
baseClasses = "whitespace-pre-wrap wrap-break-word p-3 text-xs",
+ borderless = false,
) {
+ const toned = ASSISTANT_TITLES.includes(title || "");
return cn(
baseClasses,
- ASSISTANT_TITLES.includes(title || "")
- ? "bg-accent-light-green dark:border-accent-dark-green/30"
- : "",
- SYSTEM_TITLES.includes(title || "") ? "bg-card" : "",
- scrollable ? "" : "rounded-sm border",
+ toned ? "bg-accent-light-green dark:border-accent-dark-green/30" : "",
+ borderless
+ ? "rounded-md overflow-clip"
+ : scrollable
+ ? ""
+ : "rounded-sm border",
codeClassName,
);
}
@@ -334,7 +334,6 @@ interface JsonTableRowProps {
expandedCells: Set<string>;
toggleCellExpansion: (cellId: string) => void;
stickyTopLevelKey: boolean;
- stickyOffsets: { header: number; row: number };
toneClasses?: (typeof PRETTY_JSON_VIEW_TONE_CLASSES)[PrettyJsonViewTone];
}
@@ -347,7 +346,6 @@ const JsonTableRowComponent = memo(
expandedCells,
toggleCellExpansion,
stickyTopLevelKey,
- stickyOffsets,
toneClasses,
}: JsonTableRowProps) => {
// Hook is now at top level of this component ✅
@@ -380,21 +378,18 @@ const JsonTableRowComponent = memo(
"hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",
isExpandable ? "cursor-pointer" : "",
row.original.level === 0 && stickyTopLevelKey
- ? "bg-background sticky z-10 shadow-xs"
+ ? "bg-background sticky top-0 z-10 shadow-xs"
: "",
toneClasses?.row,
)}
- style={
- row.original.level === 0 && stickyTopLevelKey
- ? { top: `${stickyOffsets.header}px` }
- : undefined
- }
>
{row.getVisibleCells().map((cell) => (
<td
key={cell.id}
className={cn(
- "h-full border-b px-2 py-1 align-top whitespace-normal [&:has([role=checkbox])]:pr-0 [:last-child_>_&]:border-b-0",
+ "h-full border-b [:last-child_>_&]:border-b-0",
+ CELL_CLASSES,
+ cell.column.id === "value" && "[&>div]:wrap-anywhere",
toneClasses?.cell,
)}
style={{ width: `${cell.column.columnDef.size}%` }}
@@ -426,7 +421,6 @@ function JsonPrettyTable({
metadataActions,
rowActions,
toneClasses,
- showHeader = true,
}: {
data: JsonTableRow[];
expandAllRef?: React.RefObject<(() => void) | null>;
@@ -447,140 +441,137 @@ function JsonPrettyTable({
rowActions?: (row: Row<JsonTableRow>) => React.ReactNode;
toneClasses?: (typeof PRETTY_JSON_VIEW_TONE_CLASSES)[PrettyJsonViewTone];
/** Drop the Path / Value header row. */
- showHeader?: boolean;
}) {
- const headerRef = useRef<HTMLTableRowElement>(null);
const topLevelRowRef = useRef<HTMLTableRowElement>(null);
- const [stickyOffsets, setStickyOffsets] = useState({ header: 32, row: 32 });
+ const [topLevelRowHeight, setTopLevelRowHeight] = useState(32);
- // calculate height of top row to calculate offsets for other headings to not go beneath sticky rows
useEffect(() => {
- if (stickyTopLevelKey && headerRef.current) {
- const headerHeight = headerRef.current.offsetHeight;
-
- // get first top-level row height (if it exists)
- let rowHeight = 32; // default fallback
- if (topLevelRowRef.current) {
- rowHeight = topLevelRowRef.current.offsetHeight;
- }
-
- setStickyOffsets({
- header: headerHeight,
- row: rowHeight,
- });
+ if (stickyTopLevelKey && topLevelRowRef.current) {
+ setTopLevelRowHeight(topLevelRowRef.current.offsetHeight);
}
}, [stickyTopLevelKey, data, expanded]);
- const columns: LangfuseColumnDef<JsonTableRow, unknown>[] = [
- {
- accessorKey: "key",
- header: "Path",
- size: 35,
- cell: ({ row }) => {
- // we need to calculate the indentation here for a good line break
- // because of the padding, we don't know when to break the line otherwise
- const indentationWidth =
- row.original.level * INDENTATION_PER_LEVEL + INDENTATION_BASE;
- const buttonWidth = row.original.hasChildren ? BUTTON_WIDTH : 0;
- const availableTextWidth = `calc(100% - ${indentationWidth + buttonWidth + CELL_PADDING_X + MARGIN_LEFT_1}px)`;
-
- const valueLength = getValueStringLength(row.original.value);
- const isLongValue = valueLength > MAX_CELL_DISPLAY_CHARS / 3; // already long if we don't truncate
-
- const itemBadgeType =
- showObservationTypeBadge &&
- row.original.level === 0 &&
- row.original.value &&
- typeof row.original.value === "object" &&
- !Array.isArray(row.original.value) &&
- "type" in row.original.value &&
- typeof (row.original.value as any).type === "string" &&
- (row.original.value as any).type
- ? ((row.original.value as any).type as LangfuseItemType)
- : null;
-
- const content = (
- <div className="flex items-start wrap-break-word">
- <div
- className="flex shrink-0 items-center justify-end"
- style={{ width: `${indentationWidth}px` }}
- >
- {row.original.hasChildren && (
- <Button
- variant="ghost"
- size="sm"
- onClick={(e) => {
- e.stopPropagation();
- handleRowExpansion(
- row,
- onLazyLoadChildren,
- expandedCells,
- toggleCellExpansion,
- );
- }}
- className="h-4 w-4 p-0"
- >
- {row.getIsExpanded() ? (
- <ChevronDown className="h-3 w-3" />
- ) : (
- <ChevronRight className="h-3 w-3" />
- )}
- </Button>
- )}
- </div>
- <span
- className={`ml-1 ${MONO_TEXT_CLASSES} cursor-text`}
- style={{ maxWidth: availableTextWidth }}
+ const indentationWidthFor = (row: Row<JsonTableRow>) =>
+ row.original.level * INDENTATION_PER_LEVEL + INDENTATION_BASE;
+
+ const renderKeyText = (key: string) =>
+ key.includes(".")
+ ? key.split(".").map((segment, index, segments) => (
+ <span key={index}>
+ {segment}
+ {index < segments.length - 1 && (
+ <>
+ .<wbr />
+ </>
+ )}
+ </span>
+ ))
+ : key;
+
+ const renderKey = (row: Row<JsonTableRow>) => {
+ const indentationWidth = indentationWidthFor(row);
+
+ const itemBadgeType =
+ showObservationTypeBadge &&
+ row.original.level === 0 &&
+ row.original.value &&
+ typeof row.original.value === "object" &&
+ !Array.isArray(row.original.value) &&
+ "type" in row.original.value &&
+ typeof (row.original.value as any).type === "string" &&
+ (row.original.value as any).type
+ ? ((row.original.value as any).type as LangfuseItemType)
+ : null;
+
+ return (
+ <div className="flex w-max max-w-[40cqw] min-w-40 items-start text-xs/5 wrap-break-word">
+ <div
+ className="flex h-[1lh] shrink-0 items-center justify-end"
+ style={{ width: `${indentationWidth}px` }}
+ >
+ {row.original.hasChildren ? (
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={(e) => {
+ e.stopPropagation();
+ handleRowExpansion(
+ row,
+ onLazyLoadChildren,
+ expandedCells,
+ toggleCellExpansion,
+ );
+ }}
+ className="text-muted-foreground hover:text-foreground h-4 w-4 p-0 hover:bg-transparent"
>
- {itemBadgeType && (
- <span className="mr-1 inline-block align-middle">
- <ItemBadge type={itemBadgeType} isSmall={true} />
- </span>
+ {row.getIsExpanded() ? (
+ <ChevronDown className="h-3 w-3" />
+ ) : (
+ <ChevronRight className="h-3 w-3" />
)}
- {row.original.key}
+ </Button>
+ ) : null}
+ </div>
+ <span className={cn("min-w-0 cursor-text", KEY_CLASSES)}>
+ {itemBadgeType && (
+ <span className="mr-1 inline-block align-middle">
+ <ItemBadge type={itemBadgeType} isSmall={true} />
</span>
- </div>
- );
+ )}
+ {renderKeyText(row.original.key)}
+ </span>
+ </div>
+ );
+ };
- if (isLongValue) {
- // calculate sticky position based on level and stickyTopLevelKey setting
- let topPosition = "0";
- if (stickyTopLevelKey) {
- // Level 0: position below header
- // Level > 0: position below header + one top-level row
- topPosition =
- row.original.level === 0
- ? `${stickyOffsets.header}px`
- : `${stickyOffsets.header + stickyOffsets.row}px`;
- }
+ const renderValue = (row: Row<JsonTableRow>) => (
+ <ValueCell
+ row={row}
+ expandedCells={expandedCells}
+ toggleCellExpansion={toggleCellExpansion}
+ preserveStringWhitespace={row.original.key === "code_eval_source_code"}
+ metadataActions={metadataActions}
+ rowActions={rowActions}
+ />
+ );
- return (
- <div className="sticky z-5 py-1" style={{ top: topPosition }}>
- {content}
- </div>
- );
+ const keyColumn: LangfuseColumnDef<JsonTableRow, unknown> = {
+ accessorKey: "key",
+ header: "Path",
+ size: 1,
+ cell: ({ row }) => {
+ const content = renderKey(row);
+ const valueLength = getValueStringLength(row.original.value);
+ const isLongValue = valueLength > MAX_CELL_DISPLAY_CHARS / 3; // already long if we don't truncate
+
+ if (isLongValue) {
+ let topPosition = "0";
+ if (stickyTopLevelKey) {
+ topPosition =
+ row.original.level === 0 ? "0" : `${topLevelRowHeight}px`;
}
- return content;
- },
- },
- {
- accessorKey: "value",
- header: "Value",
- size: 65,
- cell: ({ row }) => (
- <ValueCell
- row={row}
- expandedCells={expandedCells}
- toggleCellExpansion={toggleCellExpansion}
- preserveStringWhitespace={
- row.original.key === "code_eval_source_code"
- }
- metadataActions={metadataActions}
- rowActions={rowActions}
- />
- ),
+ return (
+ <div className="sticky z-5 -my-1 py-1" style={{ top: topPosition }}>
+ {content}
+ </div>
+ );
+ }
+
+ return content;
},
+ };
+
+ const valueColumn: LangfuseColumnDef<JsonTableRow, unknown> = {
+ accessorKey: "value",
+ header: "Value",
+ size: 99,
+ cell: ({ row }) => renderValue(row),
+ };
+
+ const columns: LangfuseColumnDef<JsonTableRow, unknown>[] = [
+ keyColumn,
+ valueColumn,
];
const table = useReactTable({
@@ -696,38 +687,12 @@ function JsonPrettyTable({
return (
<div className={cn("w-full", !noBorder && "rounded-sm border")}>
- <table className="w-full table-fixed caption-bottom border-separate border-spacing-0 space-y-4 overflow-auto text-sm">
- <thead className={cn("[&_tr]:border-b", !showHeader && "hidden")}>
- {table.getHeaderGroups().map((headerGroup, index) => (
- <tr
- key={headerGroup.id}
- ref={index === 0 ? headerRef : undefined}
- className={cn(
- "hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",
- stickyTopLevelKey ? "sticky top-0 z-20" : "",
- toneClasses?.row,
- )}
- >
- {headerGroup.headers.map((header) => (
- <th
- key={header.id}
- className={cn(
- "text-muted-foreground relative h-8 border-b px-2 py-1 text-left align-middle font-bold [&:has([role=checkbox])]:pr-0",
- stickyTopLevelKey ? "bg-background" : "bg-transparent",
- toneClasses?.cell,
- )}
- style={{ width: `${header.column.columnDef.size}%` }}
- >
- {header.isPlaceholder
- ? null
- : flexRender(
- header.column.columnDef.header,
- header.getContext(),
- )}
- </th>
- ))}
- </tr>
- ))}
+ <table className="w-full table-auto caption-bottom border-separate border-spacing-0 space-y-4 overflow-auto text-sm">
+ <thead className="sr-only">
+ <tr>
+ <th scope="col">Path</th>
+ <th scope="col">Value</th>
+ </tr>
</thead>
<tbody className="text-xs [&_tr:last-child]:border-0">
{table.getRowModel().rows.map((row, rowIndex) => (
@@ -744,7 +709,6 @@ function JsonPrettyTable({
expandedCells={expandedCells}
toggleCellExpansion={toggleCellExpansion}
stickyTopLevelKey={stickyTopLevelKey}
- stickyOffsets={stickyOffsets}
toneClasses={toneClasses}
/>
))}
@@ -760,7 +724,6 @@ export function PrettyJsonView(props: {
title?: string;
titleIcon?: React.ReactNode;
/** Drop the Path / Value header row. */
- showHeader?: boolean;
className?: string;
isLoading?: boolean;
isParsing?: boolean;
@@ -851,6 +814,8 @@ export function PrettyJsonView(props: {
return decodeUnicodeInJson(result);
}, [props.json, props.parsedJson, props.isParsing, largeStringValue]);
+ const tableBorderless = Boolean(props.title) && !props.tone;
+
// JSONView internally calls deepParseJson (with maxDepth:3) which mutates
// nested string fields in place. Because baseTableData[].rawChildData holds
// references back into parsedJson, sharing parsedJson with JSONView would
@@ -1263,12 +1228,9 @@ export function PrettyJsonView(props: {
!emptyValueDisplay;
const getBackgroundColorClass = () =>
- cn(
- ASSISTANT_TITLES.includes(props.title || "")
- ? "bg-accent-light-green"
- : "",
- SYSTEM_TITLES.includes(props.title || "") ? "bg-card" : "",
- );
+ ASSISTANT_TITLES.includes(props.title || "")
+ ? "bg-accent-light-green rounded-md overflow-clip"
+ : "";
const body = (
<>
@@ -1298,7 +1260,13 @@ export function PrettyJsonView(props: {
<div
className={cn(
"flex items-center",
- getContainerClasses(props.title, props.scrollable, codeClassName),
+ getContainerClasses(
+ props.title,
+ props.scrollable,
+ codeClassName,
+ undefined,
+ tableBorderless,
+ ),
)}
>
<span className={`font-mono ${PREVIEW_TEXT_CLASSES}`}>
@@ -1331,11 +1299,15 @@ export function PrettyJsonView(props: {
style={{ display: shouldUseTableView ? "flex" : "none" }}
>
<div
- className={getContainerClasses(
- props.title,
- props.scrollable,
- codeClassName,
- "flex text-xs wrap-break-word whitespace-pre-wrap",
+ className={cn(
+ getContainerClasses(
+ props.title,
+ props.scrollable,
+ codeClassName,
+ "flex text-xs wrap-break-word whitespace-pre-wrap",
+ tableBorderless,
+ ),
+ "@container w-full",
)}
>
{props.isLoading ? (
@@ -1360,7 +1332,6 @@ export function PrettyJsonView(props: {
metadataActions={props.metadataActions}
rowActions={props.rowActions}
toneClasses={toneClasses}
- showHeader={props.showHeader}
/>
)}
</div>
@@ -1504,7 +1475,11 @@ export function PrettyJsonView(props: {
<div
className={cn(
"flex h-full min-h-0 overflow-hidden",
- isMarkdownMode ? getBackgroundColorClass() : "rounded-sm border",
+ isMarkdownMode
+ ? getBackgroundColorClass()
+ : shouldUseTableView && tableBorderless
+ ? ""
+ : "rounded-sm border",
)}
>
<div className="max-h-full min-h-0 w-full overflow-y-auto">
diff --git a/web/src/components/ui/jsonViewPreference.ts b/web/src/components/ui/jsonViewPreference.ts
new file mode 100644
index 0000000000..dd26b5aef8
--- /dev/null
+++ b/web/src/components/ui/jsonViewPreference.ts
@@ -0,0 +1,35 @@
+export const JSON_VIEW_PREFERENCE_STORAGE_KEY = "jsonViewPreference";
+
+export type JsonViewPreference = "pretty" | "json" | "json-beta";
+
+export const DEFAULT_JSON_VIEW_PREFERENCE: JsonViewPreference = "pretty";
+
+const JSON_VIEW_PREFERENCES: readonly string[] = [
+ "pretty",
+ "json",
+ "json-beta",
+];
+
+export function normalizeJsonViewPreference(
+ value: unknown,
+): JsonViewPreference {
+ return typeof value === "string" && JSON_VIEW_PREFERENCES.includes(value)
+ ? (value as JsonViewPreference)
+ : DEFAULT_JSON_VIEW_PREFERENCE;
+}
+
+export function isPrettyLikeJsonView(view: JsonViewPreference): boolean {
+ return view !== "json" && view !== "json-beta";
+}
+
+export function toPrettyOrJsonView(
+ view: JsonViewPreference,
+): "pretty" | "json" {
+ return view === "json" ? "json" : "pretty";
+}
+
+export function jsonViewToggleTab(
+ view: JsonViewPreference,
+): Exclude<JsonViewPreference, "json-beta"> {
+ return view === "json-beta" ? "json" : view;
+}
diff --git a/web/src/features/sessions/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTimelineContentMessage/SessionTimelineContentMessage.tsx b/web/src/features/sessions/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTimelineContentMessage/SessionTimelineContentMessage.tsx
index a620c1a8c9..3f7f46c36c 100644
--- a/web/src/features/sessions/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTimelineContentMessage/SessionTimelineContentMessage.tsx
+++ b/web/src/features/sessions/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTimelineContentMessage/SessionTimelineContentMessage.tsx
@@ -109,7 +109,11 @@ export function SessionTimelineContentMessage({
className={cn("flex w-full", presentation.wrapper)}
>
<article
- className={cn("min-w-0 overflow-hidden", presentation.container)}
+ className={cn(
+ "min-w-0 overflow-hidden",
+ presentation.container,
+ isJsonOnly && isJsonExpanded && "w-full",
+ )}
>
{showSender && groupIndex === firstContentGroupIndex ? (
<div className="text-foreground mb-1 flex min-w-0 items-center gap-1.5 font-mono text-[11px]">
diff --git a/web/src/features/traces/components/IOPreview/IOPreview.tsx b/web/src/features/traces/components/IOPreview/IOPreview.tsx
index 9d95d30f0c..8a2678d0a7 100644
--- a/web/src/features/traces/components/IOPreview/IOPreview.tsx
+++ b/web/src/features/traces/components/IOPreview/IOPreview.tsx
@@ -9,6 +9,11 @@ import { type MediaReturnType } from "@/src/features/media/validation";
import { type ExpansionState } from "@/src/features/traces/components/AdvancedJsonViewer/types";
import { ViewModeToggle, type ViewMode } from "./components/ViewModeToggle";
+import {
+ DEFAULT_JSON_VIEW_PREFERENCE,
+ JSON_VIEW_PREFERENCE_STORAGE_KEY,
+ normalizeJsonViewPreference,
+} from "@/src/components/ui/jsonViewPreference";
import { IOPreviewJSON, type IOPreviewJSONProps } from "./IOPreviewJSON";
import { IOPreviewJSONSimple } from "./IOPreviewJSONSimple";
import { IOPreviewPretty } from "./IOPreviewPretty";
@@ -164,16 +169,11 @@ export function IOPreview({
// View state management
const [localCurrentView, setLocalCurrentView] = useLocalStorage<ViewMode>(
- "jsonViewPreference",
- "pretty",
+ JSON_VIEW_PREFERENCE_STORAGE_KEY,
+ DEFAULT_JSON_VIEW_PREFERENCE,
);
- // A previously persisted "pretty-beta" preference is no longer a view mode;
- // fall back to the Formatted view.
- const normalizedLocalView: ViewMode =
- (localCurrentView as string) === "pretty-beta"
- ? "pretty"
- : localCurrentView;
- const selectedView = currentView ?? normalizedLocalView;
+ const selectedView =
+ currentView ?? normalizeJsonViewPreference(localCurrentView);
const showViewToggle = currentView === undefined;
const [compensateScrollRef, startPreserveScroll] =
diff --git a/web/src/features/traces/components/IOPreview/components/ViewModeToggle.tsx b/web/src/features/traces/components/IOPreview/components/ViewModeToggle.tsx
index db66ae1d8d..18742ae24c 100644
--- a/web/src/features/traces/components/IOPreview/components/ViewModeToggle.tsx
+++ b/web/src/features/traces/components/IOPreview/components/ViewModeToggle.tsx
@@ -1,8 +1,9 @@
import { Tabs } from "@/src/components/design-system/Tabs/Tabs";
import { Switch } from "@/src/components/design-system/Switch/Switch";
import { useJsonBetaToggle } from "@/src/features/traces/hooks/useJsonBetaToggle";
+import { type JsonViewPreference } from "@/src/components/ui/jsonViewPreference";
-export type ViewMode = "pretty" | "json" | "json-beta";
+export type ViewMode = JsonViewPreference;
export interface ViewModeToggleProps {
selectedView: ViewMode;
diff --git a/web/src/features/traces/components/ObservationDetailView/ConnectedObservationDetailView.tsx b/web/src/features/traces/components/ObservationDetailView/ConnectedObservationDetailView.tsx
index 994f80065a..2f476ad861 100644
--- a/web/src/features/traces/components/ObservationDetailView/ConnectedObservationDetailView.tsx
+++ b/web/src/features/traces/components/ObservationDetailView/ConnectedObservationDetailView.tsx
@@ -55,6 +55,10 @@ import {
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
import { useTraceAnalyticsDimensions } from "@/src/features/traces/hooks/useTraceAnalyticsDimensions";
import { useViewPreferences } from "@/src/features/traces/contexts/ViewPreferencesContext";
+import {
+ jsonViewToggleTab,
+ normalizeJsonViewPreference,
+} from "@/src/components/ui/jsonViewPreference";
// Contexts and hooks
import { useTraceData } from "@/src/features/traces/contexts/TraceDataContext";
@@ -206,7 +210,7 @@ export function ConnectedObservationDetailView({
// Map jsonViewPreference to currentView format expected by child components
const currentView = jsonViewPreference;
- const selectedViewTab = currentView === "pretty" ? "pretty" : "json";
+ const selectedViewTab = jsonViewToggleTab(currentView);
const [isPrettyViewAvailable, setIsPrettyViewAvailable] = useState(true);
const handleViewTabChange = useCallback(
@@ -219,11 +223,11 @@ export function ConnectedObservationDetailView({
...analyticsDimensions,
});
}
- if (tab === "pretty") {
- setJsonViewPreference(tab);
- } else {
+ if (tab === "json") {
// When switching to JSON, use beta preference
setJsonViewPreference(jsonBetaEnabled ? "json-beta" : "json");
+ } else {
+ setJsonViewPreference(normalizeJsonViewPreference(tab));
}
},
[
diff --git a/web/src/features/traces/components/ObservationDetailView/ObservationAttributesTab.tsx b/web/src/features/traces/components/ObservationDetailView/ObservationAttributesTab.tsx
index 49405a9ac7..ebab3e7526 100644
--- a/web/src/features/traces/components/ObservationDetailView/ObservationAttributesTab.tsx
+++ b/web/src/features/traces/components/ObservationDetailView/ObservationAttributesTab.tsx
@@ -54,7 +54,6 @@ export function ObservationAttributesTab({
<div className={SECTION_CLASS}>
<PrettyJsonView
title="Attributes"
- showHeader={false}
json={attributes}
currentView={currentView}
rowActions={(row) => (
@@ -73,7 +72,6 @@ export function ObservationAttributesTab({
<div className={SECTION_CLASS}>
<PrettyJsonView
title="Model parameters"
- showHeader={false}
json={modelParameters}
currentView={currentView}
/>
@@ -92,7 +90,6 @@ export function ObservationAttributesTab({
) : (
<PrettyJsonView
title="Metadata"
- showHeader={false}
json={metadata}
parsedJson={parsedMetadata}
currentView={currentView}
diff --git a/web/src/features/traces/components/TraceDetailView/TraceDetailView.tsx b/web/src/features/traces/components/TraceDetailView/TraceDetailView.tsx
index 8f3d4ecb95..e585cef125 100644
--- a/web/src/features/traces/components/TraceDetailView/TraceDetailView.tsx
+++ b/web/src/features/traces/components/TraceDetailView/TraceDetailView.tsx
@@ -42,6 +42,10 @@ import { useParsedTrace } from "@/src/hooks/useParsedTrace";
// Contexts and hooks
import { useTraceData } from "@/src/features/traces/contexts/TraceDataContext";
import { useViewPreferences } from "@/src/features/traces/contexts/ViewPreferencesContext";
+import {
+ jsonViewToggleTab,
+ normalizeJsonViewPreference,
+} from "@/src/components/ui/jsonViewPreference";
import {
type DetailTab,
useSelection,
@@ -105,8 +109,7 @@ export function TraceDetailView({
// Map jsonViewPreference to currentView format expected by child components
const currentView = jsonViewPreference;
- const selectedViewTab =
- jsonViewPreference === "pretty" ? "pretty" : ("json" as const);
+ const selectedViewTab = jsonViewToggleTab(jsonViewPreference);
const handleViewTabChange = useCallback(
(tab: string) => {
@@ -118,10 +121,10 @@ export function TraceDetailView({
...analyticsDimensions,
});
}
- if (tab === "pretty") {
- setJsonViewPreference(tab);
- } else {
+ if (tab === "json") {
setJsonViewPreference(jsonBetaEnabled ? "json-beta" : "json");
+ } else {
+ setJsonViewPreference(normalizeJsonViewPreference(tab));
}
},
[
diff --git a/web/src/features/traces/components/TraceLogView/LogViewExpandedContent.tsx b/web/src/features/traces/components/TraceLogView/LogViewExpandedContent.tsx
index 21d84627bc..f33acd5bd5 100644
--- a/web/src/features/traces/components/TraceLogView/LogViewExpandedContent.tsx
+++ b/web/src/features/traces/components/TraceLogView/LogViewExpandedContent.tsx
@@ -10,12 +10,16 @@ import { PrettyJsonView } from "@/src/components/ui/PrettyJsonView";
import { type TreeNode } from "@/src/features/traces/types/treeNode";
import { useLogViewObservationIO } from "./useLogViewObservationIO";
import { Spinner } from "@/src/components/design-system/Spinner/Spinner";
+import {
+ type JsonViewPreference,
+ toPrettyOrJsonView,
+} from "@/src/components/ui/jsonViewPreference";
export interface LogViewExpandedContentProps {
node: TreeNode;
traceId: string;
projectId: string;
- currentView?: "pretty" | "json" | "json-beta";
+ currentView?: JsonViewPreference;
/** Optional external expansion state for JSON tree (non-virtualized mode) */
externalExpansionState?: Record<string, boolean> | boolean;
/** Callback when expansion state changes (non-virtualized mode) */
@@ -83,8 +87,7 @@ export const LogViewExpandedContent = memo(function LogViewExpandedContent({
{jsonData && !isLoading && (
<PrettyJsonView
json={jsonData}
- // Map json-beta to "pretty" for PrettyJsonView since it only supports "pretty" | "json"
- currentView={currentView === "json-beta" ? "pretty" : currentView}
+ currentView={toPrettyOrJsonView(currentView)}
isLoading={false}
showNullValues={false}
stickyTopLevelKey={false}
diff --git a/web/src/features/traces/components/TraceLogView/LogViewToolbar.tsx b/web/src/features/traces/components/TraceLogView/LogViewToolbar.tsx
index 6277bdf8e2..d6316d0053 100644
--- a/web/src/features/traces/components/TraceLogView/LogViewToolbar.tsx
+++ b/web/src/features/traces/components/TraceLogView/LogViewToolbar.tsx
@@ -31,6 +31,7 @@ import {
} from "@/src/components/ui/hover-card";
import { cn } from "@/src/utils/tailwind";
import { Spinner } from "@/src/components/design-system/Spinner/Spinner";
+import { type JsonViewPreference } from "@/src/components/ui/jsonViewPreference";
export interface LogViewToolbarProps {
/** Current search query */
@@ -55,8 +56,7 @@ export interface LogViewToolbarProps {
isCopyOrDownloadCacheOnly?: boolean;
/** Callback to copy JSON */
onCopyJson?: () => void;
- /** Current view type (pretty/json/json-beta) */
- currentView?: "pretty" | "json" | "json-beta";
+ currentView?: JsonViewPreference;
/** Whether indent visualization is enabled */
indentEnabled?: boolean;
/** Whether indent toggle is disabled (tree too deep) */
diff --git a/web/src/features/traces/components/TraceLogView/TraceLogView.tsx b/web/src/features/traces/components/TraceLogView/TraceLogView.tsx
index a8789ea663..b82a9eaa5f 100644
--- a/web/src/features/traces/components/TraceLogView/TraceLogView.tsx
+++ b/web/src/features/traces/components/TraceLogView/TraceLogView.tsx
@@ -37,6 +37,7 @@ import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePos
import { useTraceAnalyticsDimensions } from "@/src/features/traces/hooks/useTraceAnalyticsDimensions";
import { useTraceData } from "@/src/features/traces/contexts/TraceDataContext";
import { useViewPreferences } from "@/src/features/traces/contexts/ViewPreferencesContext";
+import { type JsonViewPreference } from "@/src/components/ui/jsonViewPreference";
import { useJsonExpansion } from "@/src/features/traces/contexts/JsonExpansionContext";
import { JSONTableView } from "@/src/features/traces/components/JSONTableView";
import { type FlatLogItem } from "./log-view-types";
@@ -56,7 +57,7 @@ import { flattenTreeOrder } from "@/src/features/traces/components/TraceLogView/
export interface TraceLogViewProps {
traceId: string;
projectId: string;
- currentView?: "pretty" | "json" | "json-beta";
+ currentView?: JsonViewPreference;
/** Which detail panel hosts this log view — analytics segmentation only. */
target?: "trace" | "observation";
}
@@ -378,24 +379,22 @@ export const TraceLogView = ({
)}
{/* Table view mode - render as expandable table */}
- {/* "json-beta" uses table mode since advanced I/O viewer works in expandable rows */}
- {flatItems.length > 0 &&
- (currentView === "pretty" || currentView === "json-beta") && (
- <JSONTableView
- items={flatItems}
- columns={columns}
- getItemKey={(item) => item.node.id}
- expandable
- renderExpanded={renderExpanded}
- expandedKeys={expandedKeys}
- onExpandedKeysChange={handleExpandedKeysChange}
- virtualized={isVirtualized}
- overscan={100}
- collapsedRowHeight={COLLAPSED_ROW_HEIGHT}
- expandedRowHeight={EXPANDED_ROW_HEIGHT}
- renderRowPrefix={renderRowPrefix}
- />
- )}
+ {flatItems.length > 0 && currentView !== "json" && (
+ <JSONTableView
+ items={flatItems}
+ columns={columns}
+ getItemKey={(item) => item.node.id}
+ expandable
+ renderExpanded={renderExpanded}
+ expandedKeys={expandedKeys}
+ onExpandedKeysChange={handleExpandedKeysChange}
+ virtualized={isVirtualized}
+ overscan={100}
+ collapsedRowHeight={COLLAPSED_ROW_HEIGHT}
+ expandedRowHeight={EXPANDED_ROW_HEIGHT}
+ renderRowPrefix={renderRowPrefix}
+ />
+ )}
</div>
);
};
diff --git a/web/src/features/traces/contexts/SelectionContext.tsx b/web/src/features/traces/contexts/SelectionContext.tsx
index 4b04e0b9f4..0d4582c552 100644
--- a/web/src/features/traces/contexts/SelectionContext.tsx
+++ b/web/src/features/traces/contexts/SelectionContext.tsx
@@ -28,10 +28,11 @@ import {
} from "react";
import { StringParam, useQueryParam } from "use-query-params";
import { useDebounce } from "@/src/hooks/useDebounce";
+import { useViewPreferences } from "./ViewPreferencesContext";
import {
- useViewPreferences,
+ isPrettyLikeJsonView,
type JsonViewPreference,
-} from "./ViewPreferencesContext";
+} from "@/src/components/ui/jsonViewPreference";
// Valid tab values for detail view
export type DetailTab = "preview" | "attributes" | "log" | "scores";
@@ -95,11 +96,11 @@ export function SelectionProvider({ children }: SelectionProviderProps) {
: DEFAULT_TAB;
// Map localStorage JsonViewPreference to ViewPref format
- // Both "json" and "json-beta" map to "json" ViewPref
- const localStorageViewPref: ViewPref =
- jsonViewPreference === "json" || jsonViewPreference === "json-beta"
- ? "json"
- : "formatted";
+ const localStorageViewPref: ViewPref = isPrettyLikeJsonView(
+ jsonViewPreference,
+ )
+ ? "formatted"
+ : "json";
// View preference: URL param overrides localStorage default
const viewPref: ViewPref = VALID_PREFS.includes(prefParam as ViewPref)
diff --git a/web/src/features/traces/contexts/ViewPreferencesContext.tsx b/web/src/features/traces/contexts/ViewPreferencesContext.tsx
index 505187d86d..08ddaef2e1 100644
--- a/web/src/features/traces/contexts/ViewPreferencesContext.tsx
+++ b/web/src/features/traces/contexts/ViewPreferencesContext.tsx
@@ -19,6 +19,12 @@ import {
GRAPH_VIEW_MODES,
type GraphViewMode,
} from "@/src/features/trace-graph-view/types";
+import {
+ DEFAULT_JSON_VIEW_PREFERENCE,
+ JSON_VIEW_PREFERENCE_STORAGE_KEY,
+ type JsonViewPreference,
+ normalizeJsonViewPreference,
+} from "@/src/components/ui/jsonViewPreference";
/** Log view ordering mode */
export type LogViewMode = "chronological" | "tree-order";
@@ -26,9 +32,6 @@ export type LogViewMode = "chronological" | "tree-order";
/** Log view tree visualization style (only applies in tree-order mode) */
export type LogViewTreeStyle = "flat" | "indented";
-/** JSON view preference (formatted/pretty vs raw JSON vs advanced JSON beta). */
-export type JsonViewPreference = "pretty" | "json" | "json-beta";
-
/** Context in which trace is rendered - affects feature availability */
type TraceRenderContext = "fullscreen" | "peek" | "annotation";
@@ -132,19 +135,19 @@ export function ViewPreferencesProvider({
const [logViewTreeStyle, setLogViewTreeStyle] =
useLocalStorage<LogViewTreeStyle>("logViewTreeStyle", "flat");
const [storedJsonViewPreference, setJsonViewPreference] =
- useLocalStorage<JsonViewPreference>("jsonViewPreference", "pretty");
- // A previously persisted "pretty-beta" preference is no longer a view mode;
- // degrade it to the Formatted view rather than breaking the toggle.
- const jsonViewPreference: JsonViewPreference =
- (storedJsonViewPreference as string) === "pretty-beta"
- ? "pretty"
- : storedJsonViewPreference;
+ useLocalStorage<JsonViewPreference>(
+ JSON_VIEW_PREFERENCE_STORAGE_KEY,
+ DEFAULT_JSON_VIEW_PREFERENCE,
+ );
+ const jsonViewPreference = normalizeJsonViewPreference(
+ storedJsonViewPreference,
+ );
// Migration: default to true if user had json-beta selected previously
// TODO: Remove migration logic after 2025-01-26 (2 weeks) when user settings are migrated
const [jsonBetaEnabled, setJsonBetaEnabled] = useLocalStorage<boolean>(
"jsonBetaEnabled",
typeof window !== "undefined" &&
- localStorage.getItem("jsonViewPreference") === '"json-beta"',
+ localStorage.getItem(JSON_VIEW_PREFERENCE_STORAGE_KEY) === '"json-beta"',
);
// Shared with the inline expand/collapse toggle on system prompt messages;
// instances sync via useLocalStorage's localStorageChange events.
diff --git a/web/src/features/traces/hooks/useJsonBetaToggle.ts b/web/src/features/traces/hooks/useJsonBetaToggle.ts
index 38c3265991..712086f5e1 100644
--- a/web/src/features/traces/hooks/useJsonBetaToggle.ts
+++ b/web/src/features/traces/hooks/useJsonBetaToggle.ts
@@ -1,6 +1,10 @@
import useLocalStorage from "@/src/components/useLocalStorage";
-
-type ViewMode = "pretty" | "json" | "json-beta";
+import {
+ JSON_VIEW_PREFERENCE_STORAGE_KEY,
+ type JsonViewPreference,
+ jsonViewToggleTab,
+ normalizeJsonViewPreference,
+} from "@/src/components/ui/jsonViewPreference";
/**
* Hook for managing JSON Beta toggle state alongside view preference.
@@ -11,31 +15,26 @@ type ViewMode = "pretty" | "json" | "json-beta";
* use useViewPreferences() instead.
*/
export function useJsonBetaToggle(
- currentView: ViewMode,
- setCurrentView: (view: ViewMode) => void,
+ currentView: JsonViewPreference,
+ setCurrentView: (view: JsonViewPreference) => void,
) {
// Migration: default to true if user had json-beta selected previously
// TODO: Remove migration logic after 2025-01-26 (2 weeks) when user settings are migrated
const [jsonBetaEnabled, setJsonBetaEnabled] = useLocalStorage<boolean>(
"jsonBetaEnabled",
typeof window !== "undefined" &&
- localStorage.getItem("jsonViewPreference") === '"json-beta"',
+ localStorage.getItem(JSON_VIEW_PREFERENCE_STORAGE_KEY) === '"json-beta"',
);
- // Derive UI tab selection (pretty or json). A previously persisted
- // "pretty-beta" preference falls back to the Formatted tab.
- const selectedViewTab =
- currentView === "pretty" || (currentView as string) === "pretty-beta"
- ? ("pretty" as const)
- : ("json" as const);
+ const selectedViewTab = jsonViewToggleTab(currentView);
const handleViewTabChange = (tab: string) => {
- if (tab === "pretty") {
- setCurrentView(tab);
- } else {
+ if (tab === "json") {
// When switching to JSON, use beta preference
setCurrentView(jsonBetaEnabled ? "json-beta" : "json");
+ return;
}
+ setCurrentView(normalizeJsonViewPreference(tab));
};
const handleBetaToggle = (enabled: boolean) => {