Skip to content

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

fix(web): show full metadata JSONPath values in the modern session header (#18117)

Nimaref620e9bd486
diff --git a/web/src/features/sessions/ModernSessionHeader.stories.tsx b/web/src/features/sessions/ModernSessionHeader.stories.tsx
index 08bcd4b2f4..ef641949bd 100644
--- a/web/src/features/sessions/ModernSessionHeader.stories.tsx
+++ b/web/src/features/sessions/ModernSessionHeader.stories.tsx
@@ -108,7 +108,7 @@ export const ConfiguredMetadata = meta.story({
source: {
state: "ready",
metadata: {
- langfuse_user_email: "[email protected]",
+ langfuse_user_email: "[email protected]",
cloud_region: "EU",
},
metadataTruncated: false,
diff --git a/web/src/features/sessions/ModernSessionHeader.tsx b/web/src/features/sessions/ModernSessionHeader.tsx
index 9a95bb59a1..d41988b01e 100644
--- a/web/src/features/sessions/ModernSessionHeader.tsx
+++ b/web/src/features/sessions/ModernSessionHeader.tsx
@@ -136,32 +136,42 @@ const MetadataJsonPathPill = ({
display: ReturnType<typeof getConfiguredMetadataDisplay>;
onRemove: (path: string) => void;
}) => (
- <span className="group flex items-center">
+ <span className="group flex max-w-full min-w-0 items-center">
<BadgeShell data-session-header-pill="true">
<span
- className="text-muted-foreground max-w-40 truncate"
+ className="text-muted-foreground max-w-64 shrink-0 truncate"
title={display.path}
>
{display.label}
</span>
- <span className="max-w-56 truncate" title={display.displayValue}>
+ <span className="truncate" title={display.displayValue}>
{display.displayValue}
</span>
- <span className="-ml-1.5 inline-flex w-0 overflow-hidden transition-[width,margin] group-focus-within:ml-0 group-focus-within:w-4 group-hover:ml-0 group-hover:w-4">
- <button
- type="button"
- aria-label={`Remove metadata JSONPath ${display.path}`}
- title="Remove metadata JSONPath"
- className="hover:bg-muted focus-visible:ring-ring inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-sm opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100 focus-visible:ring-1 focus-visible:outline-none"
- onClick={() => onRemove(display.path)}
- >
- <X className="h-3 w-3" />
- </button>
- </span>
+ <MetadataJsonPathRemoveButton path={display.path} onRemove={onRemove} />
</BadgeShell>
</span>
);
+const MetadataJsonPathRemoveButton = ({
+ path,
+ onRemove,
+}: {
+ path: string;
+ onRemove: (path: string) => void;
+}) => (
+ <span className="-ml-1.5 inline-flex w-0 overflow-hidden transition-[width,margin] group-focus-within:ml-0 group-focus-within:w-4 group-hover:ml-0 group-hover:w-4">
+ <button
+ type="button"
+ aria-label={`Remove metadata JSONPath ${path}`}
+ title="Remove metadata JSONPath"
+ className="hover:bg-muted focus-visible:ring-ring inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-sm opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100 focus-visible:ring-1 focus-visible:outline-none"
+ onClick={() => onRemove(path)}
+ >
+ <X className="h-3 w-3" />
+ </button>
+ </span>
+);
+
const MetadataJsonPathEditorContent = ({
metadataJsonPaths,
onClose,
@@ -528,7 +538,10 @@ export function ModernSessionHeader({
{hasResults ? (
<>
{filteredPills.map((pill) => (
- <span key={pill.key} className="flex items-center">
+ <span
+ key={pill.key}
+ className="flex max-w-full items-center"
+ >
{pill.content}
</span>
))}
diff --git a/web/src/features/sessions/SessionMetadataJsonPathControl.tsx b/web/src/features/sessions/SessionMetadataJsonPathControl.tsx
index f155d5d93d..fd9c378321 100644
--- a/web/src/features/sessions/SessionMetadataJsonPathControl.tsx
+++ b/web/src/features/sessions/SessionMetadataJsonPathControl.tsx
@@ -145,6 +145,29 @@ export function SessionMetadataJsonPathControl({
queryHashes: observationQueryHashes,
traceIds: loadedTraces.map((trace) => trace.id),
});
+ // The timeline body loads observations through a different query, so traces
+ // are fetched here one at a time, in order, until one has a visible
+ // observation. The legacy body shares these cache entries.
+ const nextObservationInput = firstObservation
+ ? undefined
+ : observationInputs.find((_, index) => {
+ const status = queryCache.get(observationQueryHashes[index] ?? "")
+ ?.state.status;
+ return status !== "success" && status !== "error";
+ });
+ api.sessions.observationsForTraceFromEvents.useQuery(
+ nextObservationInput ?? {
+ projectId,
+ sessionId,
+ traceId: "",
+ filter: filterState,
+ },
+ {
+ enabled: nextObservationInput !== undefined,
+ trpc: { context: { skipBatch: true } },
+ staleTime: 60 * 1000,
+ },
+ );
const source = (() => {
if (!shouldObserveMetadata) {
return { state: "idle" } as const;
@@ -159,7 +182,7 @@ export function SessionMetadataJsonPathControl({
metadataTruncated: firstObservation.metadataTruncated,
} as const;
}
- if (isFetching) {
+ if (isFetching || nextObservationInput) {
return { state: "loading" } as const;
}
if (isError && !hasResolvedQuery) {