Skip to content

Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.

fix: Use telemetry trace detail sheet for Otter trace links (#1205)

Aman Agarwalc4c1f00807c4
diff --git a/src/client/src/components/(playground)/chat/chat-layout.tsx b/src/client/src/components/(playground)/chat/chat-layout.tsx
index 853cadc1..8d3a2657 100644
--- a/src/client/src/components/(playground)/chat/chat-layout.tsx
+++ b/src/client/src/components/(playground)/chat/chat-layout.tsx
@@ -8,7 +8,7 @@ import ConversationList from "./conversation-list";
import ChatPanel from "./chat-panel";
import OtterUsageView from "./otter-usage-view";
import ChatSettingsForm from "./chat-settings-form";
-import RequestDetails from "@/components/(playground)/request/request-details";
+import TraceDetailRequestSheet from "@/components/(playground)/observability/trace-detail-request-sheet";
import { useRootStore } from "@/store";
import {
getChatConversations,
@@ -226,7 +226,7 @@ export default function ChatLayout({ initialConversationId, initialView = "chat"
/>
)}
</div>
- <RequestDetails />
+ <TraceDetailRequestSheet />
</Card>
);
}
diff --git a/src/client/src/components/(playground)/chat/message-bubble.tsx b/src/client/src/components/(playground)/chat/message-bubble.tsx
index 355a15a9..109e1372 100644
--- a/src/client/src/components/(playground)/chat/message-bubble.tsx
+++ b/src/client/src/components/(playground)/chat/message-bubble.tsx
@@ -208,6 +208,10 @@ function TraceReferencePills({ refs }: { refs: TraceReference[] }) {
updateRequest({ spanId: ref.id });
return;
}
+ if (ref.spanId) {
+ updateRequest({ id: ref.id, spanId: ref.spanId });
+ return;
+ }
try {
const res = await fetch(`/api/metrics/request/trace/${ref.id}`);
const result = await res.json();
diff --git a/src/client/src/components/(playground)/observability/trace-detail-request-sheet.tsx b/src/client/src/components/(playground)/observability/trace-detail-request-sheet.tsx
new file mode 100644
index 00000000..8fc73e57
--- /dev/null
+++ b/src/client/src/components/(playground)/observability/trace-detail-request-sheet.tsx
@@ -0,0 +1,140 @@
+"use client";
+
+import { useEffect, useState } from "react";
+import type { ReactNode } from "react";
+import { useRouter } from "next/navigation";
+import { Maximize2, X } from "lucide-react";
+import { Button } from "@/components/ui/button";
+import { ResizeablePanel } from "@/components/ui/resizeable-panel";
+import { Sheet, SheetContent } from "@/components/ui/sheet";
+import {
+ useRequest,
+ useRequestNavigation,
+} from "@/components/(playground)/request/request-context";
+import getMessage from "@/constants/messages";
+import { TraceDetailView } from "./trace-detail-page";
+
+const DETAIL_SHEET_CONTENT_CLASS =
+ "right-2 top-2 bottom-2 flex h-auto w-auto max-w-none flex-col gap-0 border-0 bg-transparent p-0 shadow-none focus-visible:outline-none sm:max-w-none";
+
+function ResizableTraceDetailSheet({ children }: { children: ReactNode }) {
+ const [maxWidth, setMaxWidth] = useState(1200);
+ const [defaultWidth, setDefaultWidth] = useState(880);
+
+ useEffect(() => {
+ const updateBounds = () => {
+ const viewportWidth = window.innerWidth;
+ const nextMaxWidth = Math.max(420, viewportWidth - 32);
+ setMaxWidth(nextMaxWidth);
+ setDefaultWidth(Math.min(Math.max(viewportWidth * 0.72, 900), nextMaxWidth));
+ };
+ updateBounds();
+ window.addEventListener("resize", updateBounds);
+ return () => window.removeEventListener("resize", updateBounds);
+ }, []);
+
+ return (
+ <ResizeablePanel
+ defaultWidth={defaultWidth}
+ minWidth={420}
+ maxWidth={maxWidth}
+ handlePosition="left"
+ className="h-full max-w-[calc(100vw-1rem)] rounded-md bg-white shadow-2xl dark:bg-stone-950"
+ handleClassName="opacity-100 border-stone-300 bg-white dark:border-stone-700 dark:bg-stone-900"
+ >
+ <div className="flex h-full min-h-0 flex-col overflow-hidden">
+ {children}
+ </div>
+ </ResizeablePanel>
+ );
+}
+
+export default function TraceDetailRequestSheet() {
+ const m = getMessage();
+ const router = useRouter();
+ const [request, updateRequest] = useRequest();
+ const { items, total, offset } = useRequestNavigation();
+ const spanId = request?.spanId ? String(request.spanId) : "";
+ const [activeSpanId, setActiveSpanId] = useState(spanId);
+
+ useEffect(() => {
+ setActiveSpanId(spanId);
+ }, [spanId]);
+
+ const closeSheet = () => {
+ updateRequest(null);
+ };
+
+ const updateSpanSelection = (nextSpanId: string) => {
+ setActiveSpanId(nextSpanId);
+ updateRequest({
+ ...(request || {}),
+ spanId: nextSpanId,
+ });
+ };
+
+ const updateActiveSpanSelection = (nextSpanId: string) => {
+ setActiveSpanId(nextSpanId);
+ if (typeof window === "undefined") return;
+ const url = new URL(window.location.href);
+ url.searchParams.set("spanId", nextSpanId);
+ window.history.replaceState({}, "", url.toString());
+ };
+
+ const fullScreenHref = activeSpanId ? `/telemetry/traces/${activeSpanId}` : "";
+
+ return (
+ <Sheet
+ modal={false}
+ open={!!spanId}
+ onOpenChange={(open) => !open && closeSheet()}
+ >
+ <SheetContent
+ side="right"
+ className={DETAIL_SHEET_CONTENT_CLASS}
+ displayOverlay={false}
+ displayClose={false}
+ >
+ <ResizableTraceDetailSheet>
+ <div className="min-h-0 flex-1 overflow-hidden">
+ {spanId ? (
+ <TraceDetailView
+ spanId={spanId}
+ type="traces"
+ variant="sheet"
+ onSpanChange={updateSpanSelection}
+ onActiveSpanChange={updateActiveSpanSelection}
+ navigationRows={items}
+ navigationOffset={offset}
+ navigationTotal={total}
+ extraActions={
+ <>
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-7 gap-1.5"
+ onClick={() => router.push(fullScreenHref)}
+ disabled={!fullScreenHref}
+ >
+ <Maximize2 className="h-3.5 w-3.5" />
+ {m.OBSERVABILITY_FULL_SCREEN}
+ </Button>
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-7 w-7 border-stone-200 bg-white p-0 text-stone-600 hover:bg-stone-100 hover:text-stone-950 dark:border-stone-800 dark:bg-stone-950 dark:text-stone-300 dark:hover:bg-stone-800 dark:hover:text-stone-50"
+ onClick={closeSheet}
+ title={m.OBSERVABILITY_CLOSE}
+ >
+ <X className="h-4 w-4" />
+ </Button>
+ </>
+ }
+ />
+ ) : null}
+ </div>
+ </ResizableTraceDetailSheet>
+ </SheetContent>
+ </Sheet>
+ );
+}
diff --git a/src/client/src/components/(playground)/request/components/attributes-tab.tsx b/src/client/src/components/(playground)/request/components/attributes-tab.tsx
deleted file mode 100644
index 8c01aa4e..00000000
--- a/src/client/src/components/(playground)/request/components/attributes-tab.tsx
+++ /dev/null
@@ -1,187 +0,0 @@
-"use client";
-
-import { TraceMapping } from "@/constants/traces";
-import {
- CODE_ITEM_DISPLAY_KEYS,
- KNOWN_SPAN_ATTR_KEYS,
- getTraceMappingKeyFullPath,
-} from "@/helpers/client/trace";
-import { TraceMappingKeyType, TransformedTraceRow } from "@/types/trace";
-import { isNil } from "lodash";
-
-type AttrGroup = { label: string; keys: TraceMappingKeyType[] };
-
-const ATTR_GROUPS: AttrGroup[] = [
- {
- label: "Model & Request",
- keys: [
- "model", "provider", "type", "endpoint", "responseModel", "outputType",
- "temperature", "requestTopP", "requestTopK",
- "requestFrequencyPenalty", "requestPresencePenalty",
- "maxTokens", "randomSeed", "requestChoiceCount",
- "requestIsStream", "requestUser", "requestToolChoice", "reasoningEffort",
- ],
- },
- {
- label: "Response",
- keys: ["responseId", "finishReason"],
- },
- {
- label: "Usage",
- keys: [
- "promptTokens", "completionTokens", "totalTokens", "cost",
- "cacheReadTokens", "cacheCreationTokens", "reasoningTokens",
- ],
- },
- {
- label: "Latency",
- keys: ["ttft", "tbt"],
- },
- {
- label: "Tools",
- keys: ["toolName", "toolCallId"],
- },
- {
- label: "OpenAI",
- keys: [
- "openaiApiType", "openaiRequestServiceTier",
- "openaiResponseServiceTier", "openaiSystemFingerprint",
- ],
- },
- {
- label: "Media",
- keys: ["audioVoice", "audioFormat", "audioSpeed", "imageSize", "imageQuality", "imageStyle"],
- },
- {
- label: "Embeddings",
- keys: ["embeddingFormat", "embeddingDimension"],
- },
- {
- label: "Fine-tuning",
- keys: [
- "trainingFile", "validationFile", "fineTuneBatchSize",
- "learningRateMultiplier", "fineTuneNEpochs", "fineTuneModelSuffix", "finetuneJobStatus",
- ],
- },
- {
- label: "Database",
- keys: [
- "operation", "system", "dbSystemName", "dbOperationName",
- "collectionName", "nResults", "documentsCount", "idsCount", "vectorCount",
- ],
- },
- {
- label: "Framework",
- keys: ["owner", "repo"],
- },
-];
-
-const CODE_ITEM_KEY_SET = new Set<string>(CODE_ITEM_DISPLAY_KEYS);
-
-export function GroupHeader({ label }: { label: string }) {
- return (
- <div className="sticky top-0 px-4 py-1.5 bg-stone-100 dark:bg-stone-800/80 border-y border-stone-200 dark:border-stone-700 first:border-t-0">
- <span className="text-[10px] font-semibold uppercase tracking-wider text-stone-400 dark:text-stone-500">
- {label}
- </span>
- </div>
- );
-}
-
-/** Safely convert any value to a displayable string */
-function safeStringify(val: unknown): string {
- if (val === null || val === undefined) return "";
- if (typeof val === "string") return val;
- if (typeof val === "number" || typeof val === "boolean") return String(val);
- try {
- return JSON.stringify(val, null, 2);
- } catch {
- return "[Complex Object]";
- }
-}
-
-export function AttrRow({ label, value, mono = false, className = "" }: { label: string; value: unknown; mono?: boolean; className?: string }) {
- const displayValue = safeStringify(value);
- return (
- <div className={`flex items-start gap-3 px-4 py-2 border-b border-stone-100 dark:border-stone-800/60 last:border-0 hover:bg-stone-50 dark:hover:bg-stone-800/30 transition-colors ${className}`}>
- <span className="w-44 shrink-0 text-xs text-stone-500 dark:text-stone-400 pt-px leading-relaxed break-all">
- {label}
- </span>
- <span
- className={`text-xs text-stone-800 dark:text-stone-200 break-all leading-relaxed min-w-0 ${
- mono ? "font-mono" : ""
- }`}
- >
- {displayValue}
- </span>
- </div>
- );
-}
-
-export default function AttributesTab({
- normalizedItem,
- spanAttributes,
-}: {
- normalizedItem: TransformedTraceRow;
- spanAttributes: Record<string, string | number>;
-}) {
- const groups = ATTR_GROUPS.map((group) => ({
- label: group.label,
- entries: group.keys
- .filter((key) => {
- if (CODE_ITEM_KEY_SET.has(key)) return false;
- const value = normalizedItem[key];
- if (isNil(value) || value === "" || value === TraceMapping[key]?.defaultValue)
- return false;
- return true;
- })
- .map((key) => {
- const mapping = TraceMapping[key];
- const prefix = mapping?.valuePrefix ?? "";
- const suffix = mapping?.valueSuffix ?? "";
- return {
- key,
- label: mapping?.isRoot ? key : (() => { const fp = getTraceMappingKeyFullPath(key); return Array.isArray(fp) ? fp.join(".") : (fp as string); })(),
- value: `${prefix}${normalizedItem[key]}${suffix}`,
- };
- }),
- })).filter((g) => g.entries.length > 0);
-
- const customEntries = Object.entries(spanAttributes).filter(
- ([key, value]) =>
- !KNOWN_SPAN_ATTR_KEYS.has(key) &&
- !isNil(value) &&
- String(value).length > 0
- );
-
- const hasContent = groups.length > 0 || customEntries.length > 0;
-
- if (!hasContent) {
- return (
- <div className="flex items-center justify-center h-24 text-sm text-stone-400 dark:text-stone-500">
- No span attributes
- </div>
- );
- }
-
- return (
- <div className="flex flex-col">
- {groups.map((group) => (
- <div key={group.label}>
- <GroupHeader label={group.label} />
- {group.entries.map(({ key, label, value }) => (
- <AttrRow key={key} label={label} value={value} />
- ))}
- </div>
- ))}
- {customEntries.length > 0 && (
- <div>
- <GroupHeader label="Custom" />
- {customEntries.map(([key, value]) => (
- <AttrRow key={key} label={key} value={value} mono />
- ))}
- </div>
- )}
- </div>
- );
-}
diff --git a/src/client/src/components/(playground)/request/components/code-item.tsx b/src/client/src/components/(playground)/request/components/code-item.tsx
deleted file mode 100644
index abb82a2b..00000000
--- a/src/client/src/components/(playground)/request/components/code-item.tsx
+++ /dev/null
@@ -1,22 +0,0 @@
-import JSONViewer from "@/components/common/json-viewer";
-
-export default function CodeItem({
- label,
- text,
-}: {
- label?: string;
- text: unknown;
-}) {
- return (
- <div className="flex flex-col space-y-3 group py-4 w-full">
- {label && (
- <span className="text-sm text-stone-500 font-medium dark:text-stone-300">
- {label} :
- </span>
- )}
- <code className="text-sm inline-flex text-left items-center bg-stone-300 text-stone-700 rounded-md p-4 group-hover:text-stone-900 cursor-pointer dark:bg-stone-800 dark:text-stone-200 dark:group-hover:text-stone-100">
- <JSONViewer value={text} />
- </code>
- </div>
- );
-}
diff --git a/src/client/src/components/(playground)/request/components/content-data.tsx b/src/client/src/components/(playground)/request/components/content-data.tsx
deleted file mode 100644
index b928ad29..00000000
--- a/src/client/src/components/(playground)/request/components/content-data.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-import { isNil } from "lodash";
-import JsonViewer from "@/components/common/json-viewer";
-
-export default function ContentDataItem({
- dataKey,
- dataValue,
-}: {
- dataKey: string;
- dataValue?: string;
-}) {
- return (
- <div className="flex items-start gap-3 px-4 py-2 border-b border-stone-100 dark:border-stone-800/60 last:border-0 hover:bg-stone-50 dark:hover:bg-stone-800/30 transition-colors">
- <span className="w-44 shrink-0 text-xs text-stone-500 dark:text-stone-400 pt-px leading-relaxed">
- {dataKey}
- </span>
- {!(isNil(dataValue) || dataValue === "") ? (
- <span className="text-xs text-stone-800 dark:text-stone-200 break-all leading-relaxed flex-1 min-w-0">
- <JsonViewer value={dataValue} />
- </span>
- ) : null}
- </div>
- );
-}
diff --git a/src/client/src/components/(playground)/request/components/extra-tabs/index.tsx b/src/client/src/components/(playground)/request/components/extra-tabs/index.tsx
deleted file mode 100644
index fcb42784..00000000
--- a/src/client/src/components/(playground)/request/components/extra-tabs/index.tsx
+++ /dev/null
@@ -1,16 +0,0 @@
-import { TransformedTraceRow } from "@/types/trace";
-import Evaluations from "../evaluations";
-
-export default function ExtraTabs({
- tabKey,
- trace,
-}: {
- tabKey: string;
- trace: TransformedTraceRow;
-}) {
- if (tabKey === "Evaluation") {
- return <Evaluations trace={trace} />;
- }
-
- return null;
-}
diff --git a/src/client/src/components/(playground)/request/components/info-pill.tsx b/src/client/src/components/(playground)/request/components/info-pill.tsx
deleted file mode 100644
index 1bfd59fa..00000000
--- a/src/client/src/components/(playground)/request/components/info-pill.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-import { Badge } from "@/components/ui/badge";
-import { Button } from "@/components/ui/button";
-import { Separator } from "@/components/ui/separator";
-
-export default function InfoPill({
- title,
- value,
-}: {
- title: string;
- value: any;
-}) {
- return (
- <Button
- variant="outline"
- size="default"
- className="text-stone-500 bg-stone-300 dark:text-stone-300 dark:bg-stone-800 cursor-default px-2 py-1 h-auto overflow-hidden"
- >
- <span className="text-xs bg-transparent">{title}</span>
- <Separator
- orientation="vertical"
- className="mx-1 h-4 bg-stone-300 dark:bg-stone-600"
- />
- <Badge
- variant="secondary"
- className="rounded-sm px-1 font-normal bg-transparent py-0 block ellipsis overflow-hidden whitespace-normal"
- >
- {value}
- </Badge>
- </Button>
- );
-}
diff --git a/src/client/src/components/(playground)/request/components/resource-attributes-tab.tsx b/src/client/src/components/(playground)/request/components/resource-attributes-tab.tsx
deleted file mode 100644
index 34953475..00000000
--- a/src/client/src/components/(playground)/request/components/resource-attributes-tab.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-"use client";
-
-import { isNil } from "lodash";
-import { AttrRow } from "./attributes-tab";
-
-export default function ResourceAttributesTab({
- resourceAttributes,
-}: {
- resourceAttributes: Record<string, string>;
-}) {
- const entries = Object.entries(resourceAttributes || {}).filter(
- ([, value]) => !isNil(value) && String(value).length > 0
- );
-
- if (entries.length === 0) {
- return (
- <div className="flex items-center justify-center h-16 text-sm text-stone-400 dark:text-stone-500">
- No resource attributes
- </div>
- );
- }
-
- return (
- <div className="flex flex-col">
- {entries.map(([key, value]) => (
- <AttrRow key={key} label={key} value={value} />
- ))}
- </div>
- );
-}
diff --git a/src/client/src/components/(playground)/request/components/span-attributes-tab.tsx b/src/client/src/components/(playground)/request/components/span-attributes-tab.tsx
deleted file mode 100644
index fa9045b7..00000000
--- a/src/client/src/components/(playground)/request/components/span-attributes-tab.tsx
+++ /dev/null
@@ -1,148 +0,0 @@
-"use client";
-
-import { TraceMapping } from "@/constants/traces";
-import {
- CODE_ITEM_DISPLAY_KEYS,
- KNOWN_SPAN_ATTR_KEYS,
- getTraceMappingKeyFullPath,
-} from "@/helpers/client/trace";
-import { TraceMappingKeyType, TransformedTraceRow } from "@/types/trace";
-import { isNil } from "lodash";
-import { AttrRow, GroupHeader } from "./attributes-tab";
-
-type AttrGroup = { label: string; keys: TraceMappingKeyType[] };
-
-const ATTR_GROUPS: AttrGroup[] = [
- {
- label: "Model & Request",
- keys: [
- "model", "provider", "type", "endpoint", "responseModel", "outputType",
- "temperature", "requestTopP", "requestTopK",
- "requestFrequencyPenalty", "requestPresencePenalty",
- "maxTokens", "randomSeed", "requestChoiceCount",
- "requestIsStream", "requestUser", "requestToolChoice", "reasoningEffort",
- ],
- },
- {
- label: "Response",
- keys: ["responseId", "finishReason"],
- },
- {
- label: "Usage",
- keys: [
- "promptTokens", "completionTokens", "totalTokens", "cost",
- "cacheReadTokens", "cacheCreationTokens", "reasoningTokens",
- ],
- },
- {
- label: "Latency",
- keys: ["ttft", "tbt"],
- },
- {
- label: "Tools",
- keys: ["toolName", "toolCallId"],
- },
- {
- label: "OpenAI",
- keys: [
- "openaiApiType", "openaiRequestServiceTier",
- "openaiResponseServiceTier", "openaiSystemFingerprint",
- ],
- },
- {
- label: "Media",
- keys: ["audioVoice", "audioFormat", "audioSpeed", "imageSize", "imageQuality", "imageStyle"],
- },
- {
- label: "Embeddings",
- keys: ["embeddingFormat", "embeddingDimension"],
- },
- {
- label: "Fine-tuning",
- keys: [
- "trainingFile", "validationFile", "fineTuneBatchSize",
- "learningRateMultiplier", "fineTuneNEpochs", "fineTuneModelSuffix", "finetuneJobStatus",
- ],
- },
- {
- label: "Database",
- keys: [
- "operation", "system", "dbSystemName", "dbOperationName",
- "collectionName", "nResults", "documentsCount", "idsCount", "vectorCount",
- ],
- },
- {
- label: "Framework",
- keys: ["owner", "repo"],
- },
-];
-
-const CODE_ITEM_KEY_SET = new Set<string>(CODE_ITEM_DISPLAY_KEYS);
-
-export default function SpanAttributesTab({
- normalizedItem,
- spanAttributes,
-}: {
- normalizedItem: TransformedTraceRow;
- spanAttributes: Record<string, string | number>;
-}) {
- const groups = ATTR_GROUPS.map((group) => ({
- label: group.label,
- entries: group.keys
- .filter((key) => {
- if (CODE_ITEM_KEY_SET.has(key)) return false;
- const value = normalizedItem[key];
- if (isNil(value) || value === "" || value === TraceMapping[key]?.defaultValue)
- return false;
- return true;
- })
- .map((key) => {
- const mapping = TraceMapping[key];
- const prefix = mapping?.valuePrefix ?? "";
- const suffix = mapping?.valueSuffix ?? "";
- return {
- key,
- label: mapping?.isRoot ? key : (() => { const fp = getTraceMappingKeyFullPath(key); return Array.isArray(fp) ? fp.join(".") : (fp as string); })(),
- value: `${prefix}${normalizedItem[key]}${suffix}`,
- };
- }),
- })).filter((g) => g.entries.length > 0);
-
- const customEntries = Object.entries(spanAttributes || {}).filter(
- ([key, value]) =>
- !KNOWN_SPAN_ATTR_KEYS.has(key) &&
- !isNil(value) &&
- String(value).length > 0
- );
-
- const hasContent = groups.length > 0 || customEntries.length > 0;
-
- if (!hasContent) {
- return (
- <div className="flex items-center justify-center h-16 text-sm text-stone-400 dark:text-stone-500">
- No span attributes
- </div>
- );
- }
-
- return (
- <div className="flex flex-col">
- {groups.map((group) => (
- <div key={group.label}>
- <GroupHeader label={group.label} />
- {group.entries.map(({ key, label, value }) => (
- <AttrRow key={key} label={label} value={value} />
- ))}
- </div>
- ))}
- {customEntries.length > 0 && (
- <div>
- <GroupHeader label="Custom" />
- {customEntries.map(([key, value]) => (
- <AttrRow key={key} label={key} value={value} mono />
- ))}
- </div>
- )}
- </div>
- );
-}
diff --git a/src/client/src/components/(playground)/request/components/tabs-content.tsx b/src/client/src/components/(playground)/request/components/tabs-content.tsx
deleted file mode 100644
index c99105ab..00000000
--- a/src/client/src/components/(playground)/request/components/tabs-content.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-import { objectEntries } from "@/utils/object";
-import { isArray, isPlainObject } from "lodash";
-import { AttrRow } from "./attributes-tab";
-
-export default function TabsContent({
- dataKey,
- dataValue,
-}: {
- dataKey: string;
- dataValue: Record<string, any> | string[] | Record<string, any>[];
-}) {
- const content = isArray(dataValue)
- ? dataValue.map((datumValue, index) => (
- <section key={`${dataKey}-${index}`} className="flex flex-col">
- {index !== 0 ? (
- <div className="h-px bg-stone-200 dark:bg-stone-700" />
- ) : null}
- {isPlainObject(datumValue) ? (
- objectEntries(datumValue).map(([key, value]) => (
- <AttrRow
- key={key.toString()}
- label={key as string}
- value={value}
- />
- ))
- ) : (
- <AttrRow
- key={`${dataKey}-${index}-val`}
- label={typeof datumValue === "string" ? datumValue : `[${index}]`}
- value={typeof datumValue === "string" ? "" : datumValue}
- />
- )}
- </section>
- ))
- : objectEntries(dataValue).map(([key, value]) => (
- <AttrRow
- key={key.toString()}
- label={key as string}
- value={value}
- />
- ));
-
- return <div className="flex flex-col">{content}</div>;
-}
diff --git a/src/client/src/components/(playground)/request/heirarchy-display.tsx b/src/client/src/components/(playground)/request/heirarchy-display.tsx
deleted file mode 100644
index 1594e2f4..00000000
--- a/src/client/src/components/(playground)/request/heirarchy-display.tsx
+++ /dev/null
@@ -1,181 +0,0 @@
-import { useRequest } from "./request-context";
-
-import React, { useEffect, useMemo, useRef, useState } from "react";
-import { FolderTree, DollarSign } from "lucide-react";
-import { findSpanInHierarchyLodash } from "@/helpers/client/trace";
-import { TraceHeirarchySpan } from "@/types/trace";
-import useFetchWrapper from "@/utils/hooks/useFetchWrapper";
-import { toast } from "sonner";
-import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion";
-import { ResizeablePanel } from "@/components/ui/resizeable-panel";
-import TimelineView from "./components/timeline-view";
-import NodeGraph from "./components/node-graph";
-import TreeNode from "./components/tree-node";
-import ChatView from "./components/chat-view";
-import TraceAiAnalysisPanel from "./components/trace-ai-analysis-panel";
-
-type ViewMode = "tree" | "timeline" | "graph" | "chat" | "analysis";
-
-function sumCostRecursive(span: TraceHeirarchySpan): number {
- const cost = span.Cost != null && span.Cost > 0 ? span.Cost : 0;
- const childrenCost = (span.children || []).reduce((acc, c) => acc + sumCostRecursive(c), 0);
- return cost + childrenCost;
-}
-
-const DEFAULT_WIDTH = 46;
-
-const VIEW_TABS: { mode: ViewMode; label: string }[] = [
- { mode: "tree", label: "Tree" },
- { mode: "chat", label: "Chat" },
- { mode: "analysis", label: "AI Analysis" },
- { mode: "timeline", label: "Timeline" },
- { mode: "graph", label: "Graph" },
-];
-
-export default function HeirarchyDisplay() {
- const [request] = useRequest();
- const { data, fireRequest, isLoading } = useFetchWrapper();
- const [accordionValue, setAccordionValue] = useState("");
- const [viewMode, setViewMode] = useState<ViewMode>("tree");
- const lastFetchedSpanId = useRef<string | null>(null);
-
- useEffect(() => {
- if (!isLoading) {
- setAccordionValue("debug");
- }
- }, [isLoading]);
-
- useEffect(() => {
- if ((request as any)?.defaultHierarchyView === "analysis") {
- setViewMode("analysis");
- }
- }, [request?.spanId, (request as any)?.defaultHierarchyView]);
-
- const typedData =
- (data as { record: TraceHeirarchySpan; err?: string }) || {};
-
- const spanId = request?.spanId;
-
- useEffect(() => {
- if (!spanId || isLoading) return;
-
- if (lastFetchedSpanId.current === spanId) return;
-
- if (
- typedData.record?.SpanId &&
- findSpanInHierarchyLodash(typedData.record, spanId)
- ) {
- return;
- }
-
- lastFetchedSpanId.current = spanId;
- fireRequest({
- requestType: "GET",
- url: `/api/metrics/request/span/${spanId}/heirarchy`,
- failureCb: (err?: string) => {
- toast.error(err || `Cannot connect to server!`, {
- id: "heirarchy-fetch",
- });
- },
- });
- }, [spanId, isLoading]); // eslint-disable-line react-hooks/exhaustive-deps
-
- const { record } = typedData;
- const aggregateCost = useMemo(() => (record ? sumCostRecursive(record) : 0), [record]);
-
- if (isLoading || typedData.err || !record || !record.SpanId) {
- return null;
- }
-
- return (
- <ResizeablePanel
- defaultWidth={accordionValue ? 450 : DEFAULT_WIDTH}
- minWidth={DEFAULT_WIDTH}
- maxWidth={700}
- handlePosition="left"
- className="absolute left-0 top-0 -translate-x-full h-full bg-stone-100 dark:bg-stone-900 border border-stone-200 dark:border-stone-800 border-t-0 shadow-lg"
- >
- <Accordion type="single" collapsible className="flex flex-1 h-full" value={accordionValue}>
- <AccordionItem value="debug" className="border-0 flex flex-1 w-full">
- {/* ── Left rail: accordion toggle only ── */}
- <AccordionTrigger
- className="flex flex-col items-center gap-3 px-3 py-4 hover:no-underline hover:bg-stone-100 dark:hover:bg-stone-900 [&[data-state=open]]:bg-stone-100 dark:[&[data-state=open]]:bg-stone-900/50 [&[data-state=open]>svg]:rotate-90 [&[data-state=closed]>svg]:rotate-[-90deg] border-r border-stone-200 dark:border-stone-800 transition-colors shrink-0"
- onClick={() => setAccordionValue(accordionValue === "debug" ? "" : "debug")}
- >
- <div className="flex flex-col items-center gap-2">
- <FolderTree className="h-4.5 w-4.5 text-stone-600 dark:text-stone-400" />
- <span className="text-xs font-semibold [writing-mode:vertical-lr] rotate-180 transform text-stone-700 dark:text-stone-300">
- Span Hierarchy
- </span>
- {isLoading && (
- <div className="w-5 h-5 border-2 border-stone-300 border-t-stone-600 rounded-full animate-spin" />
- )}
- </div>
- </AccordionTrigger>
-
- {/* ── Main content area ── */}
- <AccordionContent className="data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down transition-all h-full pb-0" parentClassName="h-full w-full">
- <div className="flex flex-col h-full">
- {/* View mode tabs — horizontal at the top */}
- <div className="flex items-center gap-1 px-3 py-1.5 border-b border-stone-200 dark:border-stone-800 bg-stone-50 dark:bg-stone-900 shrink-0 z-10">
- {VIEW_TABS.map(({ mode, label }) => (
- <button
- key={mode}
- onClick={() => setViewMode(mode)}
- className={`px-2.5 py-1 rounded text-xs font-medium transition-colors ${
- viewMode === mode
- ? "bg-primary/10 text-primary"
- : "text-stone-500 dark:text-stone-400 hover:text-stone-700 dark:hover:text-stone-300 hover:bg-stone-200 dark:hover:bg-stone-800"
- }`}
- >
- {label}
- </button>
- ))}
- </div>
-
- {/* Content */}
- <div className={`flex-1 min-h-0 ${viewMode === "graph" ? "flex flex-col" : "overflow-auto"}`}>
- {viewMode === "tree" && (
- <div className="p-3 min-w-fit overflow-auto h-full">
- <TreeNode span={record} level={0} />
- </div>
- )}
- {viewMode === "chat" && (
- <div className="overflow-auto h-full">
- <ChatView record={record} />
- </div>
- )}
- {viewMode === "analysis" && spanId && (
- <div className="overflow-auto h-full">
- <TraceAiAnalysisPanel spanId={spanId} />
- </div>
- )}
- {viewMode === "timeline" && (
- <div className="p-3 min-w-fit overflow-auto h-full">
- <TimelineView record={record} />
- </div>
- )}
- {viewMode === "graph" && (
- <NodeGraph key={record.SpanId} record={record} />
- )}
- </div>
-
- {/* Aggregate cost footer */}
- {aggregateCost > 0 && (
- <div className="shrink-0 flex items-center gap-2 px-3 py-2 border-t border-stone-200 dark:border-stone-800 bg-stone-50 dark:bg-stone-900/50">
- <DollarSign className="h-3.5 w-3.5 text-stone-500 dark:text-stone-400" />
- <span className="text-xs font-medium text-stone-600 dark:text-stone-400">
- Total cost:
- </span>
- <span className="text-xs font-semibold text-stone-800 dark:text-stone-200">
- ${aggregateCost.toFixed(10)}
- </span>
- </div>
- )}
- </div>
- </AccordionContent>
- </AccordionItem>
- </Accordion>
- </ResizeablePanel>
- );
-}
diff --git a/src/client/src/components/(playground)/request/loader.tsx b/src/client/src/components/(playground)/request/loader.tsx
deleted file mode 100644
index 361b5e52..00000000
--- a/src/client/src/components/(playground)/request/loader.tsx
+++ /dev/null
@@ -1,48 +0,0 @@
-const RowItemLoader = ({
- icon = false,
- text = true,
- width = "",
-}: {
- icon?: boolean;
- text?: boolean;
- width?: string;
-}) => (
- <div
- className={`flex ${width} flex-1 shrink-0 relative h-full justify-center items-center py-4 px-2`}
- >
- {icon && (
- <div className="h-3 w-3 mr-3 rounded-full bg-secondary/[0.9] rounded self-start shrink-0" />
- )}
- {text && (
- <div className="flex flex-col w-full justify-center space-y-3">
- <div className="h-1 w-24 bg-secondary/[0.9] rounded" />
- <div className="h-1 w-16 bg-secondary/[0.9] rounded" />
- </div>
- )}
- </div>
-);
-
-export default function RenderLoader() {
- return (
- <div className="flex flex-col mb-4 animate-pulse">
- <div className="flex items-center rounded-t py-1.5 px-3 z-0 self-start bg-secondary text-primary font-medium">
- <div className="flex items-center pr-3">
- <div className="h-3 w-3 mr-2 rounded-full bg-secondary/[0.9] rounded" />
- <div className="h-1 w-40 bg-secondary/[0.9] rounded" />
- </div>
- <div className="flex items-center pl-3 border-l border-stone-200">
- <div className="h-3 w-3 mr-2 rounded-full bg-secondary/[0.9] rounded" />
- <div className="h-1 w-14 bg-secondary/[0.9] rounded" />
- </div>
- </div>
- <div className="flex items-stretch h-16 border border-secondary relative items-center px-3 rounded-b">
- <RowItemLoader width="w-3/12" />
- <RowItemLoader icon width="w-3/12" />
- <RowItemLoader icon width="w-1.5/12" />
- <RowItemLoader icon width="w-1.5/12" />
- <RowItemLoader icon width="w-1.5/12" />
- <RowItemLoader icon width="w-1.5/12" />
- </div>
- </div>
- );
-}
diff --git a/src/client/src/components/(playground)/request/request-details.tsx b/src/client/src/components/(playground)/request/request-details.tsx
deleted file mode 100644
index 0d546a03..00000000
--- a/src/client/src/components/(playground)/request/request-details.tsx
+++ /dev/null
@@ -1,595 +0,0 @@
-import { useRequest, useRequestNavigation } from "@/components/(playground)/request/request-context";
-import Image from "next/image";
-import { isArray, isNil, isPlainObject } from "lodash";
-import {
- CODE_ITEM_DISPLAY_KEYS,
- ensureTraceRowShape,
- getExtraTabsContentTypes,
- getNormalizedTraceAttribute,
- normalizeTrace,
-} from "@/helpers/client/trace";
-import { ReverseTraceMapping, TraceMapping } from "@/constants/traces";
-import { ExternalLink, X, DollarSign, Zap, Clock, Cpu, ChevronLeft, ChevronRight, BarChart3, RefreshCw } from "lucide-react";
-import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
-import {
- Sheet,
- SheetContent,
- SheetHeader,
- SheetTitle,
-} from "@/components/ui/sheet";
-import { objectEntries, objectKeys } from "@/utils/object";
-import { ValueOf } from "@/types/util";
-import { ReactNode, useCallback, useEffect, useState } from "react";
-import useFetchWrapper from "@/utils/hooks/useFetchWrapper";
-import { toast } from "sonner";
-import getMessage from "@/constants/messages";
-import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
-import HeirarchyDisplay from "./heirarchy-display";
-import { TraceRow, TransformedTraceRow } from "@/types/trace";
-import InfoPill from "./components/info-pill";
-import TabsContentData from "./components/tabs-content";
-import ExtraTabs from "./components/extra-tabs";
-import ResourceAttributesTab from "./components/resource-attributes-tab";
-import SpanAttributesTab from "./components/span-attributes-tab";
-import { AttrRow } from "./components/attributes-tab";
-import TraceAiAnalysisPanel from "./components/trace-ai-analysis-panel";
-
-// Root-level TraceRow scalar fields that are already shown elsewhere in the UI and
-// should NOT be duplicated as info pills.
-const REDUNDANT_ROOT_FIELDS = new Set([
- "TraceId", // shown in header as short trace ID chip
- "SpanName", // shown in header as the panel title
- "StatusCode", // shown in header as status badge
- "Duration", // shown in metric card
- "TraceState", // almost always empty
-]);
-
-function StatusBadge({ statusCode }: { statusCode?: string }) {
- const isError =
- statusCode === "STATUS_CODE_ERROR" || statusCode === "Error";
- return (
- <span
- className={`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-semibold ${
- isError
- ? "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"
- : "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400"
- }`}
- >
- <span
- className={`w-1.5 h-1.5 rounded-full ${
- isError ? "bg-red-500" : "bg-green-500"
- }`}
- />
- {isError ? "Error" : "OK"}
- </span>
- );
-}
-
-function MetricCard({
- icon,
- label,
- value,
-}: {
- icon: ReactNode;
- label: string;
- value: string | number | undefined;
-}) {
- return (
- <div className="flex flex-col gap-1 px-3 py-2 bg-stone-100 dark:bg-stone-800 rounded-lg min-w-[100px] shrink-0">
- <div className="flex items-center gap-1.5 text-stone-500 dark:text-stone-400">
- {icon}
- <span className="text-xs font-medium">{label}</span>
- </div>
- <span className="text-sm font-semibold text-stone-800 dark:text-stone-200 truncate">
- {value ?? "—"}
- </span>
- </div>
- );
-}
-
-function CostMetricCard({
- costValue,
- spanId,
- hasModel,
- onRecalculated,
-}: {
- costValue: string | undefined;
- spanId: string | undefined;
- hasModel: boolean;
- onRecalculated: () => void;
-}) {
- const m = getMessage();
- const hasCost = !!costValue;
- const canRecalculate = hasModel && !!spanId;
-
- const { fireRequest, isLoading } = useFetchWrapper<{
- success: boolean;
- err?: string;
- data?: { spanId: string; cost: number };
- }>();
-
- const handleRecalculate = (e: React.MouseEvent) => {
- e.stopPropagation();
- if (!spanId || isLoading) return;
- fireRequest({
- requestType: "POST",
- url: `/api/pricing/${spanId}`,
- successCb: (res) => {
- if (res?.success) {
- toast.success(
- `${m.RECALCULATE_COST_SUCCESS}: $${(res.data?.cost ?? 0).toFixed(10)}`,
- { id: "pricing-update" }
- );
- onRecalculated();
- } else {
- toast.error(res?.err || m.RECALCULATE_COST_FAILURE, {
- id: "pricing-update",
- });
- }
- },
- failureCb: (err?: string) => {
- toast.error(err || m.RECALCULATE_COST_REQUEST_FAILED, {
- id: "pricing-update",
- });
- },
- });
- };
-
- return (
- <div className="relative flex flex-col gap-1 px-3 py-2 bg-stone-100 dark:bg-stone-800 rounded-lg min-w-[100px] shrink-0">
- <div className="flex items-center gap-1.5 text-stone-500 dark:text-stone-400">
- <DollarSign className="h-3.5 w-3.5" />
- <span className="text-xs font-medium">Cost</span>
- {canRecalculate && (
- <TooltipProvider delayDuration={200}>
- <Tooltip>
- <TooltipTrigger asChild>
- <button
- onClick={handleRecalculate}
- disabled={isLoading}
- className="relative ml-auto p-0.5 rounded hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors disabled:opacity-50"
- >
- <RefreshCw
- className={`h-3 w-3 ${isLoading ? "animate-spin" : ""}`}
- />
- {!hasCost && !isLoading && (
- <span className="w-2 h-2 bg-primary absolute -top-0.5 -right-0.5 rounded-full animate-ping" />
- )}
- </button>
- </TooltipTrigger>
- <TooltipContent side="bottom" className="max-w-[220px] text-xs">
- {m.RECALCULATE_COST_TITLE}
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- )}
- </div>
- <span className="text-sm font-semibold text-stone-800 dark:text-stone-200 truncate">
- {costValue ?? "—"}
- </span>
- </div>
- );
-}
-
-function LoadingSkeleton() {
- return (
- <div className="flex flex-col gap-4 p-4 animate-pulse">
- {/* Header skeleton */}
- <div className="flex gap-2 items-center">
- <div className="h-5 w-5 rounded-full bg-stone-300 dark:bg-stone-700" />
- <div className="h-4 w-32 rounded bg-stone-300 dark:bg-stone-700" />
- <div className="h-4 w-48 rounded bg-stone-300 dark:bg-stone-700" />
- </div>
- {/* Metrics strip skeleton */}
- <div className="flex gap-2">
- {[1, 2, 3, 4].map((i) => (
- <div
- key={i}
- className="h-14 w-28 rounded-lg bg-stone-300 dark:bg-stone-700"
- />
- ))}
- </div>
- {/* Pills skeleton */}
- <div className="flex flex-wrap gap-2">
- {[1, 2, 3, 4, 5, 6].map((i) => (
- <div
- key={i}
- className="h-7 w-24 rounded bg-stone-300 dark:bg-stone-700"
- />
- ))}
- </div>
- </div>
- );
-}
-
-export default function RequestDetails() {
- const m = getMessage();
- const [isOpen, setIsOpen] = useState(false);
- const [request, updateRequest] = useRequest();
- const { currentIndex, items, total, offset, navigatePrev, navigateNext } = useRequestNavigation();
- const { data, fireRequest, isLoading } = useFetchWrapper();
-
- // Cache the last successfully loaded record so navigation never flickers to a skeleton.
- // While a new fetch is in-flight we keep showing the stale data at reduced opacity.
- const [displayData, setDisplayData] = useState<{
- item: TransformedTraceRow;
- rawRecord: TraceRow;
- evaluationSummary?: { runCount: number; totalCost: number; latestModel?: string };
- } | null>(null);
-
- const onClose = () => {
- updateRequest(null);
- setIsOpen(false);
- setDisplayData(null);
- };
-
- const fetchData = useCallback(async () => {
- setIsOpen(true);
- fireRequest({
- requestType: "GET",
- url: `/api/metrics/request/span/${request?.spanId}`,
- failureCb: (err?: string) => {
- toast.error(err || `Cannot connect to server!`, {
- id: "request-page",
- });
- },
- });
- }, [request]);
-
- useEffect(() => {
- if (request?.spanId) {
- fetchData();
- }
- }, [request?.spanId, fetchData]);
-
- // Commit successful fetches into the display cache
- useEffect(() => {
- const raw = (data as { record?: TraceRow })?.record;
- const evaluationSummary = (data as { evaluationSummary?: { runCount: number; totalCost: number; latestModel?: string } })?.evaluationSummary;
- const record = raw ? ensureTraceRowShape(raw) : null;
- const hasId = record && ((record as any).TraceId ?? (record as any).trace_id);
- if (record && hasId && !isLoading) {
- setDisplayData({
- item: normalizeTrace(record),
- rawRecord: record,
- evaluationSummary,
- });
- }
- }, [data, isLoading]);
-
- useEffect(() => {
- if (isOpen) {
- // Pushing the change to the end of the call stack
- const timer = setTimeout(() => {
- document.body.style.pointerEvents = "";
- }, 0);
-
- return () => clearTimeout(timer);
- } else {
- document.body.style.pointerEvents = "auto";
- }
- }, [isOpen]);
-
- // Show the skeleton only on the very first open (nothing cached yet).
- // On subsequent navigations keep the old content visible while the new fetch runs.
- const isFirstLoad = isLoading && !displayData;
- const isTransitioning = isLoading && !!displayData;
-
- const normalizedItem: TransformedTraceRow | null = displayData?.item ?? null;
- const rawRecord: TraceRow | null = displayData?.rawRecord ?? null;
- const evaluationSummary = displayData?.evaluationSummary;
-
- const extraTabs = normalizedItem
- ? getExtraTabsContentTypes(normalizedItem)
- : [];
- const tabKeys: string[] = [...extraTabs];
- const hasAIAnalysis = !!normalizedItem?.spanId;
- const reducedData = rawRecord
- ? objectEntries(rawRecord || {}).reduce(
- (
- acc: {
- arrays: [keyof TraceRow, ValueOf<TraceRow>][];
- objects: [keyof TraceRow, ValueOf<TraceRow>][];
- values: [keyof TraceRow, ValueOf<TraceRow>][];
- },
- [key, value]
- ) => {
- if (isPlainObject(value)) {
- if (objectKeys(value as object).length > 0) {
- acc.objects.push([key, value]);
- tabKeys.push(key);
- }
- } else if (isArray(value)) {
- if (value.length > 0) {
- acc.arrays.push([key, value]);
- tabKeys.push(key);
- }
- } else {
- acc.values.push([key, value]);
- }
-
- return acc;
- },
- { arrays: [], objects: [], values: [] }
- )
- : { arrays: [], objects: [], values: [] };
-
- // Derived display values for metrics strip
- const parsedCost = parseFloat(normalizedItem?.cost as string);
- const costValue =
- isFinite(parsedCost) && parsedCost > 0
- ? `$${parsedCost.toFixed(10)}`
- : undefined;
- const parsedTokens = Number(normalizedItem?.totalTokens);
- const tokensValue =
- isFinite(parsedTokens) && parsedTokens > 0
- ? String(parsedTokens)
- : undefined;
- const parsedDuration = parseFloat(normalizedItem?.requestDuration as string);
- const durationValue = isFinite(parsedDuration)
- ? `${parsedDuration.toFixed(2)}s`
- : undefined;
- const modelValue =
- normalizedItem?.model && normalizedItem.model !== "-"
- ? String(normalizedItem.model)
- : undefined;
-
- // Trace ID (short display)
- const traceId = rawRecord?.TraceId ?? (rawRecord as any)?.trace_id;
- const shortTraceId = traceId ? `${String(traceId).slice(0, 8)}…` : undefined;
-
- return (
- <Sheet open={isOpen}>
- <SheetContent
- className="max-w-none sm:max-w-none w-[55%] p-0 gap-0 flex flex-col border-l border-stone-200 dark:border-stone-800 top-2 bottom-2 h-auto focus-visible:outline-none"
- displayOverlay={false}
- displayClose={false}
- >
- <SheetHeader className="flex-row bg-stone-100 dark:bg-stone-900 px-3 py-1.5 items-center space-y-0 gap-2">
- {/* capitalize : classname is removed because it was rendering the name incorrectly */}
- <SheetTitle className="text-stone-900 dark:text-stone-200 text-md font-bold leading-7 grow pr-1 truncate">
- {!normalizedItem
- ? "Loading…"
- : normalizedItem.spanName}
- </SheetTitle>
- {normalizedItem && (
- <>
- <StatusBadge statusCode={normalizedItem.statusCode as string} />
- {shortTraceId && (
- <span className="text-xs text-stone-600 dark:text-stone-400 font-mono bg-stone-200 dark:bg-stone-800 px-1.5 py-0.5 rounded">
- {shortTraceId}
- </span>
- )}
- </>
- )}
- {currentIndex >= 0 && (
- <div className="flex items-center gap-0.5 shrink-0">
- <button
- onClick={navigatePrev}
- disabled={currentIndex <= 0 && offset <= 0}
- className="p-1 rounded text-stone-500 dark:text-stone-400 hover:text-stone-900 dark:hover:text-stone-200 disabled:opacity-30 disabled:cursor-not-allowed transition-colors"
- title="Previous item"
- >
- <ChevronLeft className="h-4 w-4" />
- </button>
- <span className="text-xs text-stone-600 dark:text-stone-500 tabular-nums min-w-[3rem] text-center">
- {offset + currentIndex + 1} / {total || items.length}
- </span>
- <button
- onClick={navigateNext}
- disabled={currentIndex >= items.length - 1 && offset + items.length >= total}
- className="p-1 rounded text-stone-500 dark:text-stone-400 hover:text-stone-900 dark:hover:text-stone-200 disabled:opacity-30 disabled:cursor-not-allowed transition-colors"
- title="Next item"
- >
- <ChevronRight className="h-4 w-4" />
- </button>
- </div>
- )}
- <X
- className="text-stone-800 dark:text-stone-200 shrink-0 mt-0 space-y-0 cursor-pointer"
- onClick={onClose}
- />
- </SheetHeader>
-
- {isFirstLoad ? (
- <LoadingSkeleton />
- ) : !normalizedItem ? null : (
- <div
- className={`flex flex-col gap-0 overflow-y-scroll bg-stone-100 dark:bg-stone-900 grow pb-4 transition-opacity duration-200 scrollbar-hidden ${
- isTransitioning ? "opacity-40" : "opacity-100"
- }`}
- >
- {/* Key metrics strip */}
- <div className="shrink-0 flex items-center gap-2 px-4 py-3 overflow-x-auto bg-white dark:bg-stone-950 border-b border-stone-200 dark:border-stone-800">
- <CostMetricCard
- costValue={costValue}
- spanId={normalizedItem?.spanId ? String(normalizedItem.spanId) : undefined}
- hasModel={!!modelValue}
- onRecalculated={fetchData}
- />
- <MetricCard
- icon={<Zap className="h-3.5 w-3.5" />}
- label="Total Tokens"
- value={tokensValue}
- />
- <MetricCard
- icon={<Clock className="h-3.5 w-3.5" />}
- label="Duration"
- value={durationValue}
- />
- <MetricCard
- icon={<Cpu className="h-3.5 w-3.5" />}
- label="Model"
- value={modelValue}
- />
- {evaluationSummary && evaluationSummary.runCount > 0 && (
- <>
- <MetricCard
- icon={<BarChart3 className="h-3.5 w-3.5" />}
- label="Eval Runs"
- value={String(evaluationSummary.runCount)}
- />
- <MetricCard
- icon={<DollarSign className="h-3.5 w-3.5" />}
- label="Eval Cost"
- value={
- evaluationSummary.totalCost > 0
- ? `$${evaluationSummary.totalCost.toFixed(10)}`
- : undefined
- }
- />
- </>
- )}
- </div>
-
- {/* Info pills — root-level span metadata (context, correlation IDs, scope) */}
- <div className="shrink-0 flex items-start flex-wrap gap-1 p-4 bg-stone-200 dark:bg-stone-100/[0.15]">
- {reducedData.values
- .filter(([key]) => !REDUNDANT_ROOT_FIELDS.has(key as string))
- .map(([key, value]) => {
- const reverseKey = ReverseTraceMapping[key];
- const normalizedValue = `${
- reverseKey ? TraceMapping[reverseKey].valuePrefix || "" : ""
- }${
- reverseKey
- ? getNormalizedTraceAttribute(reverseKey, value)
- : value
- }${
- reverseKey ? TraceMapping[reverseKey].valueSuffix || "" : ""
- }`;
- return (
- !isNil(value) &&
- value.toString().length > 0 && (
- <InfoPill
- key={key}
- title={key}
- value={normalizedValue}
- />
- )
- );
- })}
- {CODE_ITEM_DISPLAY_KEYS.map((key) => {
- const value = normalizedItem[key];
- const mapping = TraceMapping[key];
- const hasValue =
- !isNil(value) &&
- value !== "" &&
- value !== mapping?.defaultValue;
- if (!hasValue) return null;
- const label = mapping?.label ?? key;
- return (
- <AttrRow
- key={key}
- label={label}
- value={value}
- className="bg-stone-50 dark:bg-stone-800/30 flex-col w-full mt-3"
- />
- );
- })}
- {/* Image */}
- {normalizedItem.image && normalizedItem.imageSize && (
- <a
- href={normalizedItem.image}
- target="_blank"
- rel="noopener noreferrer"
- className="flex items-center justify-center aspect-h-1 aspect-w-1 w-full overflow-hidden rounded-md bg-stone-100 lg:aspect-none lg:h-80 mt-4 group relative p-4 text-center text-stone-500 shrink-0"
- >
- <Image
- src={normalizedItem.image}
- alt={normalizedItem.applicationName}
- className="h-full w-full object-cover object-center lg:h-full lg:w-full"
- width={parseInt(normalizedItem.imageSize.split("x")[0], 10)}
- height={parseInt(
- normalizedItem.imageSize.split("x")[1],
- 10
- )}
- />
- <span className="flex items-center justify-center opacity-0 group-hover:opacity-100 absolute top-0 left-0 w-full h-full text-primary bg-stone-100/[0.1]">
- <ExternalLink className="w-6 h-6 ml-2 shrink-0" />
- </span>
- </a>
- )}
- </div>
-
- <Tabs className="flex min-h-[420px] flex-1 flex-col" defaultValue={"SpanAttributes"}>
- <TabsList className="h-auto flex overflow-auto justify-start w-full rounded-none pt-2 bg-transparent dark:bg-transparent px-0 shrink-0">
- {hasAIAnalysis && (
- <TabsTrigger
- value="AI Analysis"
- className="data-[state=active]:bg-transparent dark:data-[state=active]:bg-transparent data-[state=active]:text-primary dark:data-[state=active]:text-primary data-[state=active]:border-primary dark:data-[state=active]:border-primary border-b border-transparent data-[state=active]:shadow-none rounded-none px-4"
- >
- {m.TRACE_AI_TAB_TITLE}
- </TabsTrigger>
- )}
- {tabKeys.map((key) => {
- return (
- <TabsTrigger
- value={key.toString()}
- key={key.toString()}
- className="data-[state=active]:bg-transparent dark:data-[state=active]:bg-transparent data-[state=active]:text-primary dark:data-[state=active]:text-primary data-[state=active]:border-primary dark:data-[state=active]:border-primary border-b border-transparent data-[state=active]:shadow-none rounded-none px-4"
- >
- {key}
- </TabsTrigger>
- );
- })}
- </TabsList>
- {hasAIAnalysis && normalizedItem?.spanId && (
- <TabsContent value="AI Analysis" className="mt-0 min-h-0 flex-1 p-0 data-[state=active]:flex">
- <TraceAiAnalysisPanel
- spanId={normalizedItem.spanId}
- scope="span"
- description={m.TRACE_AI_IMPROVEMENT_SPAN_DESCRIPTION}
- />
- </TabsContent>
- )}
- {extraTabs.map((tab) => {
- return (
- <TabsContent value={tab.toString()} key={tab.toString()}>
- <ExtraTabs tabKey={tab} trace={normalizedItem} />
- </TabsContent>
- );
- })}
- {reducedData.objects.map(([key, value]) => {
- return (
- <TabsContent
- value={key.toString()}
- key={key.toString()}
- className="mt-0"
- >
- {
- key === "ResourceAttributes" ? (
- <ResourceAttributesTab resourceAttributes={value as Record<string, any>} />
- ) : key === "SpanAttributes" ? (
- <SpanAttributesTab normalizedItem={normalizedItem} spanAttributes={value as Record<string, string | number>} />
- ) : (
- <TabsContentData
- dataKey={key}
- dataValue={value as string[] | Record<string, any>[]}
- />
- )
- }
- </TabsContent>
- );
- })}
- {reducedData.arrays.map(([key, value]) => {
- return (
- <TabsContent
- value={key.toString()}
- key={key.toString()}
- className="mt-0"
- >
- <TabsContentData
- dataKey={key}
- dataValue={value as string[] | Record<string, any>[]}
- />
- </TabsContent>
- );
- })}
- </Tabs>
- </div>
- )}
- <HeirarchyDisplay />
- </SheetContent>
- </Sheet>
- );
-}
diff --git a/src/client/src/lib/platform/chat/schema-context.ts b/src/client/src/lib/platform/chat/schema-context.ts
index fdae606e..7613185d 100644
--- a/src/client/src/lib/platform/chat/schema-context.ts
+++ b/src/client/src/lib/platform/chat/schema-context.ts
@@ -44,7 +44,7 @@ Format:
Rules:
- Include only verified trace/span IDs returned by SQL or trace-analysis tools.
-- For trace references, include \`spanId\` when available so the request detail sheet can open directly.
+- For trace references, include \`spanId\` when available so the telemetry detail sheet can open directly.
- Do not put UUIDs, rule IDs, model IDs, conversation IDs, session IDs, or any other entity IDs in \`\`\`trace-refs.
## Entity Links