Skip to content

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

fix(trace-detail): collapse all button ignoring root node (#8581)

Leo Weigand251741aacbcd
diff --git a/web/src/components/table/peek/peek-dataset-compare-detail.tsx b/web/src/components/table/peek/peek-dataset-compare-detail.tsx
index c474598b1f..b139c4f4be 100644
--- a/web/src/components/table/peek/peek-dataset-compare-detail.tsx
+++ b/web/src/components/table/peek/peek-dataset-compare-detail.tsx
@@ -74,8 +74,8 @@ export const PeekDatasetCompareDetail = ({
}, []);
const handleSetCurrentObservationId = (id?: string) => {
- if (id && traceId && !id.startsWith("trace-")) {
- // Only open observations in new tabs, not the trace root (which has trace- prefix)
+ if (id && traceId) {
+ // Only open observations in new tabs; root selection passes undefined
const pathname = `/project/${projectId}/traces/${encodeURIComponent(traceId)}?observation=${encodeURIComponent(id)}`;
const pathnameWithBasePath = `${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}${pathname}`;
window.open(pathnameWithBasePath, "_blank", "noopener noreferrer");
diff --git a/web/src/components/trace/index.tsx b/web/src/components/trace/index.tsx
index 8fb449ea95..37c1433c8a 100644
--- a/web/src/components/trace/index.tsx
+++ b/web/src/components/trace/index.tsx
@@ -289,10 +289,11 @@ export function Trace(props: {
</Button>
) : (
(() => {
- // Check if anything is expanded by seeing if the trace is collapsed
- const isEverythingCollapsed = collapsedNodes.includes(
- props.trace.id,
- );
+ // Use the same root id format as the tree (see buildTraceTree)
+ const traceRootId = `trace-${props.trace.id}`;
+ // Check if everything is collapsed by seeing if the trace root is collapsed
+ const isEverythingCollapsed =
+ collapsedNodes.includes(traceRootId);
return (
<Button
@@ -300,12 +301,12 @@ export function Trace(props: {
if (isEverythingCollapsed) {
expandAll();
} else {
- // Collapse all observations AND the trace
+ // Collapse all observations AND the trace root
const allObservationIds =
props.observations.map((o) => o.id);
setCollapsedNodes([
...allObservationIds,
- props.trace.id,
+ traceRootId,
]);
}
}}