🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(ui): resolve peek trace id across v3/v4 URL dialects (LFE-11041) (#15199)
Niklas Semmler45a9464f86fe
diff --git a/web/src/components/session/index.tsx b/web/src/components/session/index.tsxindex 4fd43479cd..e2953fc808 100644--- a/web/src/components/session/index.tsx+++ b/web/src/components/session/index.tsx@@ -328,8 +328,12 @@ export const SessionPage: React.FC<{() => ({expandConfig: {basePath: `/project/${projectId}/traces`,+ pathParam: "traceId",+ reader: "trace" as const,},- queryParams: ["observation", "display", "timestamp"],+ // traceId: not written here, but cleared so a v4-dialect shared URL+ // cannot pin the trace peek (LFE-11041).+ queryParams: ["observation", "display", "timestamp", "traceId"],extractParamsValuesFromRow: (row: any) => ({timestamp: row.timestamp.toISOString(),}),@@ -754,8 +758,12 @@ const LoadedSessionEventsPage: React.FC<{() => ({expandConfig: {basePath: `/project/${projectId}/traces`,+ pathParam: "traceId",+ reader: "trace" as const,},- queryParams: ["observation", "display", "timestamp"],+ // traceId: not written here, but cleared so a v4-dialect shared URL+ // cannot pin the trace peek (LFE-11041).+ queryParams: ["observation", "display", "timestamp", "traceId"],// observationId: set by a card's "Open in trace view" on a truncated// observation so the peek opens AT that observation (LFE-10958).extractParamsValuesFromRow: (row: any) => ({diff --git a/web/src/components/table/peek/hooks/usePeekNavigation.clienttest.tsx b/web/src/components/table/peek/hooks/usePeekNavigation.clienttest.tsxnew file mode 100644index 0000000000..1168bef331--- /dev/null+++ b/web/src/components/table/peek/hooks/usePeekNavigation.clienttest.tsx@@ -0,0 +1,110 @@+import { renderHook } from "@testing-library/react";+import { beforeEach, describe, expect, it, vi } from "vitest";++import { usePeekNavigation } from "@/src/components/table/peek/hooks/usePeekNavigation";++const { mockPush, mockPathname } = vi.hoisted(() => ({+ mockPush: vi.fn(),+ mockPathname: { value: "/project/[projectId]/traces" },+}));++vi.mock("next/router", () => ({+ useRouter: () => ({ push: mockPush, pathname: mockPathname.value }),+}));+vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({+ usePostHogClientCapture: () => vi.fn(),+}));+vi.mock("@/src/features/events/hooks/useV4Beta", () => ({+ useV4Beta: () => ({ isBetaEnabled: false }),+}));++// expandPeek builds the standalone-page path from `expandConfig.pathParam`.+// The trace reader's expand must survive both peek URL dialects (LFE-11041):+// v4 URLs put the trace id in `traceId`, v3 URLs put it in `peek`.+describe("usePeekNavigation expandPeek", () => {+ const config = {+ queryParams: ["observation", "display", "timestamp", "traceId"],+ expandConfig: {+ basePath: "/project/p1/traces",+ pathParam: "traceId",+ reader: "trace" as const,+ },+ };++ beforeEach(() => {+ mockPush.mockReset();+ });++ it("v4-dialect URL: expands to the traceId param, not the observation id in peek", () => {+ window.history.replaceState(+ {},+ "",+ "/project/p1/traces?peek=obs-uuid&observation=obs-uuid&traceId=trace-1×tamp=2026-07-14T19%3A47%3A57.703Z",+ );++ const { result } = renderHook(() => usePeekNavigation(config));+ result.current.expandPeek(false);++ expect(mockPush).toHaveBeenCalledTimes(1);+ const target = mockPush.mock.calls[0][0] as string;+ expect(target.startsWith("/project/p1/traces/trace-1?")).toBe(true);+ });++ it("v4-dialect URL: does not forward the observation startTime as the trace timestamp", () => {+ // The timestamp on a v4-dialect URL is the observation's startTime; the+ // standalone page would use it as the trace-timestamp lookup filter+ // (day-equality) and observation-window anchor — 404s / truncated trees+ // on long traces (LFE-10947 class).+ window.history.replaceState(+ {},+ "",+ "/project/p1/traces?peek=obs-uuid&observation=obs-uuid&traceId=trace-1×tamp=2026-07-14T19%3A47%3A57.703Z",+ );++ const { result } = renderHook(() => usePeekNavigation(config));+ result.current.expandPeek(false);++ const target = mockPush.mock.calls[0][0] as string;+ expect(target).not.toContain("timestamp=");+ expect(target).toContain("observation=obs-uuid");+ });++ it("v3-dialect URL (no traceId param): falls back to peek for the path segment and keeps the trace timestamp", () => {+ window.history.replaceState(+ {},+ "",+ "/project/p1/traces?peek=trace-1×tamp=2026-07-14T19%3A47%3A57.703Z",+ );++ const { result } = renderHook(() => usePeekNavigation(config));+ result.current.expandPeek(false);++ expect(mockPush).toHaveBeenCalledTimes(1);+ const target = mockPush.mock.calls[0][0] as string;+ expect(target.startsWith("/project/p1/traces/trace-1?")).toBe(true);+ expect(target).toContain("timestamp=2026-07-14T19:47:57.703Z");+ });++ it("without a reader, expand forwards params verbatim (non-trace peeks unchanged)", () => {+ window.history.replaceState(+ {},+ "",+ "/project/p1/traces?peek=obs-uuid&traceId=trace-1×tamp=2026-07-14T19%3A47%3A57.703Z",+ );++ const { result } = renderHook(() =>+ usePeekNavigation({+ ...config,+ expandConfig: {+ basePath: "/project/p1/traces",+ pathParam: "traceId",+ },+ }),+ );+ result.current.expandPeek(false);++ const target = mockPush.mock.calls[0][0] as string;+ expect(target.startsWith("/project/p1/traces/trace-1?")).toBe(true);+ expect(target).toContain("timestamp=");+ });+});diff --git a/web/src/components/table/peek/hooks/usePeekNavigation.ts b/web/src/components/table/peek/hooks/usePeekNavigation.tsindex 699d9840bd..dadc9d1fc0 100644--- a/web/src/components/table/peek/hooks/usePeekNavigation.ts+++ b/web/src/components/table/peek/hooks/usePeekNavigation.ts@@ -3,6 +3,7 @@ import { type ListEntry } from "@/src/features/navigate-detail-pages/context";import { useRouter } from "next/router";import { useCallback } from "react";import { urlSearchParamsToQuery } from "@/src/utils/navigation";+import { resolvePeekTraceParams } from "@/src/components/table/peek/resolvePeekTraceParams";import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useV4Beta } from "@/src/features/events/hooks/useV4Beta";@@ -39,6 +40,12 @@ interface PeekConfigWithExpand extends BasePeekConfig {basePath: string;/** URL parameter to use for path param (defaults to "peek") */pathParam?: string;+ /**+ * Set for trace-detail peeks: routes the expand target's trace id and+ * timestamp through resolvePeekTraceParams so the standalone page gets+ * the same dialect handling as the peek pane (LFE-11041).+ */+ reader?: "trace" | "observation";};}@@ -198,11 +205,36 @@ export function usePeekNavigation(config?: PeekConfig | PeekConfigWithExpand) {const url = new URL(window.location.href);const params = new URLSearchParams(url.search);const pathParam = config?.expandConfig?.pathParam ?? PEEK_PARAM;-- const pathname = `${config?.expandConfig?.basePath}/${params.get(pathParam)}`;+ const reader = config?.expandConfig?.reader;++ // Trace-detail expands resolve the id and timestamp through the shared+ // dialect helper so the standalone page gets the same params as the+ // pane (LFE-11041): a v4-dialect timestamp is an observation startTime+ // and must not become the trace-timestamp lookup filter.+ const resolved = reader+ ? resolvePeekTraceParams({+ reader,+ peek: params.get(PEEK_PARAM) ?? undefined,+ traceId: params.get("traceId") ?? undefined,+ timestamp: params.get("timestamp") ?? undefined,+ })+ : undefined;++ // Fall back to `peek` when the configured pathParam is absent: the trace+ // reader's URLs carry the trace id in `traceId` (v4 dialect) or in+ // `peek` (v3 dialect) — see resolvePeekTraceParams (LFE-11041).+ const pathId = resolved+ ? resolved.traceId+ : (params.get(pathParam) ?? params.get(PEEK_PARAM));+ const pathname = `${config?.expandConfig?.basePath}/${pathId}`;const queryParams = config?.queryParams?.map((param) => {- const value = params.get(param);+ // The resolved trace id is the path segment; don't repeat it.+ if (resolved && param === "traceId") return null;+ const value =+ resolved && param === "timestamp"+ ? (resolved.timestamp?.toISOString() ?? null)+ : params.get(param);return value ? `${param}=${value}` : null;}).filter(Boolean)diff --git a/web/src/components/table/peek/peek-observation-detail.tsx b/web/src/components/table/peek/peek-observation-detail.tsxindex c9994f7903..6765fd8593 100644--- a/web/src/components/table/peek/peek-observation-detail.tsx+++ b/web/src/components/table/peek/peek-observation-detail.tsx@@ -8,7 +8,7 @@ import {traceDetailTitle,} from "@/src/components/trace/TraceDetailBody";import { TraceDetailActions } from "@/src/components/trace/TraceDetailActions";-import { parseTraceTimestampFromQuery } from "@/src/utils/parseTraceTimestampFromQuery";+import { resolvePeekTraceParams } from "@/src/components/table/peek/resolvePeekTraceParams";import { useRouter } from "next/router";import { useRef } from "react";@@ -23,9 +23,13 @@ export const TablePeekViewObservationDetail = (const router = useRouter();const { projectId } = props;- const peekId = router.query.peek as string | undefined;- const timestamp = parseTraceTimestampFromQuery(router.query.timestamp);- const traceId = router.query.traceId as string | undefined;+ const peekObservationId = router.query.peek as string | undefined;+ const { traceId, timestamp } = resolvePeekTraceParams({+ reader: "observation",+ peek: peekObservationId,+ traceId: router.query.traceId as string | undefined,+ timestamp: router.query.timestamp,+ });// Live handle on the peeked observation's trace id: an in-flight delete that// resolves after K/J-navigation reads the CURRENT trace here, so it only@@ -68,7 +72,11 @@ export const TablePeekViewObservationDetail = () : undefined}>- <TraceDetailBody trace={trace.data} context="peek" keySuffix={peekId} />+ <TraceDetailBody+ trace={trace.data}+ context="peek"+ keySuffix={peekObservationId}+ /></TablePeekView>);};diff --git a/web/src/components/table/peek/peek-trace-detail.tsx b/web/src/components/table/peek/peek-trace-detail.tsxindex 59a95343ea..ca23d7e1c6 100644--- a/web/src/components/table/peek/peek-trace-detail.tsx+++ b/web/src/components/table/peek/peek-trace-detail.tsx@@ -10,7 +10,7 @@ import {shouldClosePeekAfterDelete,} from "@/src/components/table/peek";import { TraceDetailActions } from "@/src/components/trace/TraceDetailActions";-import { parseTraceTimestampFromQuery } from "@/src/utils/parseTraceTimestampFromQuery";+import { resolvePeekTraceParams } from "@/src/components/table/peek/resolvePeekTraceParams";export const TablePeekViewTraceDetail = (props: Omit<@@ -23,18 +23,22 @@ export const TablePeekViewTraceDetail = (const { projectId } = props;const router = useRouter();- const peekId = router.query.peek as string | undefined;- const timestamp = parseTraceTimestampFromQuery(router.query.timestamp);+ const { traceId, timestamp } = resolvePeekTraceParams({+ reader: "trace",+ peek: router.query.peek as string | undefined,+ traceId: router.query.traceId as string | undefined,+ timestamp: router.query.timestamp,+ });// Live handle on the peeked trace id: an in-flight delete that resolves after// K/J-navigation reads the CURRENT peek here (not the stale value captured// when the delete was fired), so it only closes the peek it actually deleted.- const peekIdRef = useRef(peekId);- peekIdRef.current = peekId;+ const peekIdRef = useRef(traceId);+ peekIdRef.current = traceId;const trace = usePeekData({projectId,- traceId: peekId,+ traceId,timestamp,});@@ -57,7 +61,7 @@ export const TablePeekViewTraceDetail = (return (<TablePeekView{...props}- title={traceDetailTitle(trace.data, peekId)}+ title={traceDetailTitle(trace.data, traceId)}actions={actionProps ? <TraceDetailActions {...actionProps} /> : undefined}diff --git a/web/src/components/table/peek/resolvePeekTraceParams.clienttest.ts b/web/src/components/table/peek/resolvePeekTraceParams.clienttest.tsnew file mode 100644index 0000000000..a19df7e564--- /dev/null+++ b/web/src/components/table/peek/resolvePeekTraceParams.clienttest.ts@@ -0,0 +1,99 @@+import { describe, expect, it } from "vitest";++import { resolvePeekTraceParams } from "@/src/components/table/peek/resolvePeekTraceParams";++// The two peek URL dialects (LFE-11041):+// - v3 TracesTable: peek=<trace id>, timestamp=<trace timestamp>+// - v4 EventsTable: peek=<observation id>, traceId=<trace id>,+// timestamp=<observation startTime>+// Each reader must accept the other dialect's URLs, since links cross the+// v4-beta boundary between users.++const TRACE_ID = "gist_service_8944222577377194128";+const OBSERVATION_ID = "2df44465-3d61-43b3-8f92-b9580395c8a1";+const TIMESTAMP = "2026-07-14T19:47:57.703Z";++describe("resolvePeekTraceParams", () => {+ describe("trace reader (v3 TracesTable peek)", () => {+ it("native v3 URL: uses peek as trace id and keeps the timestamp", () => {+ const result = resolvePeekTraceParams({+ reader: "trace",+ peek: TRACE_ID,+ timestamp: TIMESTAMP,+ });+ expect(result.traceId).toBe(TRACE_ID);+ expect(result.timestamp?.toISOString()).toBe(TIMESTAMP);+ });++ it("v4-generated URL: prefers the traceId param over peek", () => {+ const result = resolvePeekTraceParams({+ reader: "trace",+ peek: OBSERVATION_ID,+ traceId: TRACE_ID,+ timestamp: TIMESTAMP,+ });+ expect(result.traceId).toBe(TRACE_ID);+ });++ it("v4-generated URL: drops the timestamp (it is an observation startTime, not the trace timestamp)", () => {+ const result = resolvePeekTraceParams({+ reader: "trace",+ peek: OBSERVATION_ID,+ traceId: TRACE_ID,+ timestamp: TIMESTAMP,+ });+ expect(result.timestamp).toBeUndefined();+ });+ });++ describe("observation reader (v4 EventsTable peek)", () => {+ it("native v4 URL: uses the traceId param and keeps the timestamp", () => {+ const result = resolvePeekTraceParams({+ reader: "observation",+ peek: OBSERVATION_ID,+ traceId: TRACE_ID,+ timestamp: TIMESTAMP,+ });+ expect(result.traceId).toBe(TRACE_ID);+ expect(result.timestamp?.toISOString()).toBe(TIMESTAMP);+ });++ it("empty traceId param (v4 row without a trace): stays empty so the query remains disabled, no peek fallback", () => {+ // All v4 writers set traceId to "" when the row has no trace+ // (`row.traceId || ""`). Falling back to peek here would query an+ // observation id as a trace id inside a native v4 flow.+ const result = resolvePeekTraceParams({+ reader: "observation",+ peek: OBSERVATION_ID,+ traceId: "",+ timestamp: TIMESTAMP,+ });+ expect(result.traceId).toBe("");+ });++ it("v3-generated URL (no traceId param): falls back to peek as trace id, keeps the trace timestamp", () => {+ const result = resolvePeekTraceParams({+ reader: "observation",+ peek: TRACE_ID,+ timestamp: TIMESTAMP,+ });+ expect(result.traceId).toBe(TRACE_ID);+ expect(result.timestamp?.toISOString()).toBe(TIMESTAMP);+ });+ });++ it("decodes URL-encoded timestamps", () => {+ const result = resolvePeekTraceParams({+ reader: "trace",+ peek: TRACE_ID,+ timestamp: encodeURIComponent(TIMESTAMP),+ });+ expect(result.timestamp?.toISOString()).toBe(TIMESTAMP);+ });++ it("returns undefined trace id when neither param is present", () => {+ const result = resolvePeekTraceParams({ reader: "trace" });+ expect(result.traceId).toBeUndefined();+ expect(result.timestamp).toBeUndefined();+ });+});diff --git a/web/src/components/table/peek/resolvePeekTraceParams.ts b/web/src/components/table/peek/resolvePeekTraceParams.tsnew file mode 100644index 0000000000..bc676bc199--- /dev/null+++ b/web/src/components/table/peek/resolvePeekTraceParams.ts@@ -0,0 +1,42 @@+import { parseTraceTimestampFromQuery } from "@/src/utils/parseTraceTimestampFromQuery";++/**+ * The trace-peek URL comes in two dialects, and links cross the v4-beta+ * boundary between users (LFE-11041):+ *+ * - v3 `TracesTable`: `peek=<trace id>`, `timestamp=<trace timestamp>`+ * - v4 `EventsTable`: `peek=<observation id>`, `traceId=<trace id>`,+ * `timestamp=<observation startTime>`+ *+ * Both peek readers resolve their query input through this one helper so each+ * accepts the other dialect's URLs:+ *+ * - trace reader (v3): a `traceId` param marks a v4-generated URL — prefer it+ * over `peek`, and drop the timestamp: it is an observation startTime, and+ * `traces.byIdWithObservationsAndScores` would use it as the trace-timestamp+ * filter, 404ing long traces (same class as LFE-10947).+ * - observation reader (v4): a missing `traceId` param marks a v3-generated+ * URL — fall back to `peek` as the trace id. The v3 timestamp is the trace+ * timestamp, a safe lookup anchor, so it is kept in both cases.+ */+export function resolvePeekTraceParams({+ reader,+ peek,+ traceId,+ timestamp,+}: {+ reader: "trace" | "observation";+ peek?: string;+ traceId?: string;+ timestamp?: string | string[];+}): { traceId?: string; timestamp?: Date } {+ // A `traceId` param on the trace reader marks a v4-generated URL.+ const dropTimestamp = reader === "trace" && !!traceId;++ return {+ traceId: traceId ?? peek,+ timestamp: dropTimestamp+ ? undefined+ : parseTraceTimestampFromQuery(timestamp),+ };+}diff --git a/web/src/components/table/use-cases/traces.tsx b/web/src/components/table/use-cases/traces.tsxindex 6d235c5a18..2b51a1fab8 100644--- a/web/src/components/table/use-cases/traces.tsx+++ b/web/src/components/table/use-cases/traces.tsx@@ -1322,12 +1322,17 @@ export default function TracesTable({);const peekNavigationProps = usePeekNavigation({- queryParams: ["observation", "display", "timestamp"],+ // traceId is not written by this table but arrives on v4-dialect shared+ // URLs (LFE-11041); listing it clears it on open/navigate/close so it+ // cannot pin the peek to the originally shared trace.+ queryParams: ["observation", "display", "timestamp", "traceId"],extractParamsValuesFromRow: (row: TracesTableRow) => ({timestamp: row.timestamp?.toISOString() || "",}),expandConfig: {basePath: `/project/${projectId}/traces`,+ pathParam: "traceId",+ reader: "trace",},});diff --git a/web/src/features/datasets/components/DatasetCompareRunsTable.tsx b/web/src/features/datasets/components/DatasetCompareRunsTable.tsxindex 39eb0a4b10..747f7a5b34 100644--- a/web/src/features/datasets/components/DatasetCompareRunsTable.tsx+++ b/web/src/features/datasets/components/DatasetCompareRunsTable.tsx@@ -107,7 +107,10 @@ function DatasetCompareRunsTableInternal(props: {}, [datasetItemsWithRunData.isSuccess, datasetItemsWithRunData.data]);const { closePeek, expandPeek } = usePeekNavigation({- queryParams: ["observation", "display", "timestamp"],+ // traceId: not written here, but cleared (and preferred by the trace+ // reader) so a stray param cannot pin the peek to a foreign trace+ // (LFE-11041).+ queryParams: ["observation", "display", "timestamp", "traceId"],expandConfig: {basePath: `/project/${props.projectId}/traces`,},diff --git a/web/src/features/evals/components/code-eval-test-run-card.tsx b/web/src/features/evals/components/code-eval-test-run-card.tsxindex 2606077e0a..0f109638e6 100644--- a/web/src/features/evals/components/code-eval-test-run-card.tsx+++ b/web/src/features/evals/components/code-eval-test-run-card.tsx@@ -74,7 +74,10 @@ export function CodeEvalTestRunCard({useEventsTable: isBetaEnabled,});const peekNavigationProps = usePeekNavigation({- queryParams: ["observation", "display", "timestamp"],+ // traceId: not written here, but cleared (and preferred by the trace+ // reader) so a stray param cannot pin the peek to a foreign trace+ // (LFE-11041).+ queryParams: ["observation", "display", "timestamp", "traceId"],expandConfig: {basePath: `/project/${projectId}/traces`,},