Skip to content

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

fix(observation-ui): enhance badge rendering with text truncation and improved value display (#7321)

marliessophie17364919afa7
diff --git a/web/src/components/trace/ObservationPreview.tsx b/web/src/components/trace/ObservationPreview.tsx
index 3592ee999d..63ade92cc9 100644
--- a/web/src/components/trace/ObservationPreview.tsx
+++ b/web/src/components/trace/ObservationPreview.tsx
@@ -326,15 +326,28 @@ export const ObservationPreview = ({
typeof preloadedObservation.modelParameters === "object"
? Object.entries(preloadedObservation.modelParameters)
.filter(Boolean)
- .map(([key, value]) => (
- <Badge variant="tertiary" key={key}>
- {key}:{" "}
- {Object.prototype.toString.call(value) ===
+ .map(([key, value]) => {
+ const valueString =
+ Object.prototype.toString.call(value) ===
"[object Object]"
? JSON.stringify(value)
- : value?.toString()}
- </Badge>
- ))
+ : value?.toString();
+ return (
+ <Badge
+ variant="tertiary"
+ key={key}
+ className="h-6 max-w-md"
+ >
+ {/* CHILD: This span handles the text truncation */}
+ <span
+ className="overflow-hidden text-ellipsis whitespace-nowrap"
+ title={valueString}
+ >
+ {key}: {valueString}
+ </span>
+ </Badge>
+ );
+ })
: null}
</Fragment>
</Fragment>