🪢 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
feat: trace messages internal preview (#17648)
marliessophie5e113040fcc3
diff --git a/packages/shared/src/server/repositories/events.ts b/packages/shared/src/server/repositories/events.tsindex a0b9bab44a..077764b214 100644--- a/packages/shared/src/server/repositories/events.ts+++ b/packages/shared/src/server/repositories/events.ts@@ -434,6 +434,10 @@ export const getObservationsForTraceFromEventsTable = async (params: {timestamp?: Date;selectIOAndMetadata?: boolean;selectToolData?: boolean;+ /** Restrict to these observation types. All types when omitted. */+ types?: ObservationType[];+ /** Rows read at most; `totalCount` exceeds it when the trace has more. */+ limit?: number;}): Promise<{ observations: FullEventsObservations; totalCount: number }> => {const {projectId,@@ -441,6 +445,8 @@ export const getObservationsForTraceFromEventsTable = async (params: {timestamp,selectIOAndMetadata = false,selectToolData = false,+ types,+ limit = MAX_OBSERVATIONS_PER_TRACE,} = params;const filter: FilterState = [@@ -462,12 +468,21 @@ export const getObservationsForTraceFromEventsTable = async (params: {});}+ if (types) {+ filter.push({+ column: "type",+ operator: "any of" as const,+ value: types,+ type: "stringOptions" as const,+ });+ }+const records =await getObservationsFromEventsTableInternal<EventsObservationQueryResult>({projectId,filter,orderBy: { column: "startTime", order: "ASC" },- limit: MAX_OBSERVATIONS_PER_TRACE + 1,+ limit: limit + 1,offset: 0,select: "rows",selectIOAndMetadata,@@ -477,7 +492,7 @@ export const getObservationsForTraceFromEventsTable = async (params: {const totalCount = records.length;const withModelData = await enrichObservationsWithModelData(- records.slice(0, MAX_OBSERVATIONS_PER_TRACE),+ records.slice(0, limit),projectId,false,null,diff --git a/web/src/features/events/server/eventsRouter.ts b/web/src/features/events/server/eventsRouter.tsindex 7e4b770a3b..5f8c449cef 100644--- a/web/src/features/events/server/eventsRouter.ts+++ b/web/src/features/events/server/eventsRouter.ts@@ -1,4 +1,7 @@import { type z, z as zodSchema } from "zod";+import { TRPCError } from "@trpc/server";+import { env } from "@/src/env.mjs";+import { hasInternalAccess } from "@/src/features/feature-flags/utils";import {createTRPCRouter,protectedProjectProcedure,@@ -27,6 +30,7 @@ import {getEventBatchIO,EVENT_FILTER_OPTIONS_COLUMNS,} from "./eventsService";+import { loadTraceTranscript } from "./loadTraceTranscript";import {instrumentAsync,getScoresAndCorrectionsForTraces,@@ -427,6 +431,63 @@ export const eventsRouter = createTRPCRouter({},);}),+ /**+ * Assemble the message transcript of a trace from its generations and tools,+ * see `loadTraceTranscript`. Internal surface: Langfuse admins and+ * deployments with experimental features enabled only, and only where the+ * events tables are written.+ */+ transcriptByTraceId: protectedGetEventsTraceProcedure+ .input(+ zodSchema.object({+ projectId: zodSchema.string(),+ traceId: zodSchema.string(),+ timestamp: zodSchema.date().optional(),+ }),+ )+ .query(async ({ input, ctx }) => {+ if (+ !hasInternalAccess({+ isAdmin: ctx.session?.user?.admin === true,+ isExperimentalFeaturesEnabled:+ env.LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES === "true",+ })+ ) {+ throw new TRPCError({+ code: "FORBIDDEN",+ message: "Transcripts are an internal preview.",+ });+ }+ if (env.LANGFUSE_MIGRATION_V4_WRITE_MODE === "legacy") {+ throw new TRPCError({+ code: "PRECONDITION_FAILED",+ message: "Transcripts need the events-backed trace view.",+ });+ }+ // The trace timestamp bounds the observation read; the trace is loaded+ // by the procedure, so the input is only a fallback.+ const timestamp = ctx.trace?.timestamp ?? input.timestamp;+ if (!timestamp) {+ throw new TRPCError({+ code: "BAD_REQUEST",+ message: "Trace timestamp is required.",+ });+ }++ return instrumentAsync(+ { name: "get-transcript-by-trace-id-trpc" },+ async (span) => {+ span.setAttribute("project_id", input.projectId);+ span.setAttribute("trace_id", input.traceId);++ return loadTraceTranscript({+ projectId: input.projectId,+ traceId: input.traceId,+ timestamp,+ });+ },+ );+ }),/*** Fetch all observations for a trace from the events table.* Returns up to MAX_OBSERVATIONS_PER_TRACE observations.diff --git a/web/src/features/events/server/loadTraceTranscript.ts b/web/src/features/events/server/loadTraceTranscript.tsnew file mode 100644index 0000000000..9fd78775eb--- /dev/null+++ b/web/src/features/events/server/loadTraceTranscript.ts@@ -0,0 +1,53 @@+import {+ assembleTranscript,+ getObservationsForTraceFromEventsTable,+ MAX_OBSERVATIONS_PER_TRACE,+ orderObservations,+ type Transcript,+} from "@langfuse/shared/src/server";++/** Generations and tools whose I/O one transcript reads at most. */+const MAX_TRANSCRIPT_OBSERVATIONS = 1_000;++const TRANSCRIPT_OBSERVATION_TYPES = new Set(["GENERATION", "TOOL"]);++/**+ * Load a trace's observations from the events table, walk them in trace tree+ * order, and assemble the transcript of its generations and tools.+ */+export async function loadTraceTranscript(trace: {+ projectId: string;+ traceId: string;+ /** Trace timestamp; observations from one hour before it onwards are read. */+ timestamp: Date;+}): Promise<{+ transcript: Transcript | null;+ /** The trace has more observations than the transcript could read. */+ cutoff: boolean;+}> {+ // The structure of every observation orders the walk; only generations and+ // tools carry I/O, which is what the transcript reads.+ const [structure, content] = await Promise.all([+ getObservationsForTraceFromEventsTable(trace),+ getObservationsForTraceFromEventsTable({+ ...trace,+ selectIOAndMetadata: true,+ types: ["GENERATION", "TOOL"],+ limit: MAX_TRANSCRIPT_OBSERVATIONS,+ }),+ ]);+ const contentById = new Map(content.observations.map((o) => [o.id, o]));+ // Generations and tools past the content cap have no I/O to show; leaving+ // them out beats rendering them as empty turns. `cutoff` tells the caller.+ const observations = structure.observations.flatMap((o) => {+ const withContent = contentById.get(o.id);+ if (withContent) return [withContent];+ return TRANSCRIPT_OBSERVATION_TYPES.has(o.type) ? [] : [o];+ });+ return {+ transcript: assembleTranscript(orderObservations(observations)),+ cutoff:+ structure.totalCount > MAX_OBSERVATIONS_PER_TRACE ||+ content.totalCount > MAX_TRANSCRIPT_OBSERVATIONS,+ };+}diff --git a/web/src/features/feature-flags/available-flags.ts b/web/src/features/feature-flags/available-flags.tsindex bb5eb37f00..8533eade3b 100644--- a/web/src/features/feature-flags/available-flags.ts+++ b/web/src/features/feature-flags/available-flags.ts@@ -15,6 +15,18 @@ type RestrictedFlag = (typeof restrictedFlags)[number];export const isRestrictedFlag = (flag: string): flag is RestrictedFlag =>restrictedFlags.some((restrictedFlag) => restrictedFlag === flag);+/**+ * Flags for Langfuse-internal surfaces. They are on for Langfuse admins and+ * for deployments with experimental features enabled, and for nobody else:+ * they are not feature previews, cannot be granted, and are never persisted.+ */+const internalFlags = ["traceMessages"] as const;++type InternalFlag = (typeof internalFlags)[number];++export const isInternalFlag = (flag: string): flag is InternalFlag =>+ internalFlags.some((internalFlag) => internalFlag === flag);+export const isFeaturePreviewFlag = (flag: string,): flag is FeaturePreviewFlag =>@@ -52,6 +64,7 @@ export const isFeaturePreviewAvailable = (export const availableFlags = [...featurePreviewFlags,...restrictedFlags,+ ...internalFlags,"searchBar","templateFlag","excludeClickhouseRead",diff --git a/web/src/features/feature-flags/hooks/useIsFeatureEnabled.ts b/web/src/features/feature-flags/hooks/useIsFeatureEnabled.tsindex 3ff653f6db..9fdf06f811 100644--- a/web/src/features/feature-flags/hooks/useIsFeatureEnabled.ts+++ b/web/src/features/feature-flags/hooks/useIsFeatureEnabled.ts@@ -1,7 +1,7 @@import { useSession } from "next-auth/react";-import { isRestrictedFlag } from "../available-flags";+import { isInternalFlag, isRestrictedFlag } from "../available-flags";import type { Flag } from "../types";-import { getContextualFeatureFlags } from "../utils";+import { getContextualFeatureFlags, hasInternalAccess } from "../utils";export default function useIsFeatureEnabled(feature: Flag,@@ -28,13 +28,18 @@ export default function useIsFeatureEnabled(organizationId,})?.[feature] ?? false;+ if (isInternalFlag(feature)) {+ return hasInternalAccess({ isAdmin, isExperimentalFeaturesEnabled });+ }+if (isRestrictedFlag(feature)) {return isFeatureEnabledOnUser;}return (- isExperimentalFeaturesEnabled ||- (enableForAdmins && isAdmin) ||- isFeatureEnabledOnUser+ hasInternalAccess({+ isAdmin: enableForAdmins && isAdmin,+ isExperimentalFeaturesEnabled,+ }) || isFeatureEnabledOnUser);}diff --git a/web/src/features/feature-flags/types.ts b/web/src/features/feature-flags/types.tsindex f136781dd2..92de9f3910 100644--- a/web/src/features/feature-flags/types.ts+++ b/web/src/features/feature-flags/types.ts@@ -4,7 +4,11 @@ export type Flag = (typeof availableFlags)[number];export type Flags = {[key in Exclude<Flag,- "modernSession" | "normalizedIoPreview" | "aiGateway" | "sessionTimeline"+ | "modernSession"+ | "normalizedIoPreview"+ | "aiGateway"+ | "sessionTimeline"+ | "traceMessages">]: boolean;} & {// Optional while older sessions and test fixtures roll across new flags.@@ -12,4 +16,5 @@ export type Flags = {normalizedIoPreview?: boolean;aiGateway?: boolean;sessionTimeline?: boolean;+ traceMessages?: boolean;};diff --git a/web/src/features/feature-flags/utils.ts b/web/src/features/feature-flags/utils.tsindex 204fa106f0..1e13e30eeb 100644--- a/web/src/features/feature-flags/utils.ts+++ b/web/src/features/feature-flags/utils.ts@@ -3,6 +3,7 @@ import {availableFlags,filterFeaturePreviewFlags,isRestrictedFlag,+ isInternalFlag,isFeaturePreviewFlag,isFeaturePreviewAvailable,type FeaturePreviewAvailabilityContext,@@ -13,6 +14,18 @@ import { type Flags } from "./types";export const getFeaturePreviewOptOutFlag = (flag: FeaturePreviewFlag) =>`feature-preview:${flag}:disabled`;+/**+ * Langfuse admins and deployments with experimental features enabled see+ * internal surfaces. Client and server gates share this rule.+ */+export const hasInternalAccess = ({+ isAdmin,+ isExperimentalFeaturesEnabled,+}: {+ isAdmin: boolean;+ isExperimentalFeaturesEnabled: boolean;+}) => isExperimentalFeaturesEnabled || isAdmin;+const receivesFeaturePreviewsByDefault = (email: string | null | undefined) => {const normalizedEmail = email?.toLowerCase();return (@@ -39,6 +52,13 @@ export const parseFlags = (return;}+ // Internal flags are decided per session by `hasInternalAccess`, never+ // by stored flags.+ if (isInternalFlag(flag)) {+ parsedFlags[flag] = false;+ return;+ }+if (isFeaturePreviewFlag(flag) &&dbFlags.includes(getFeaturePreviewOptOutFlag(flag))diff --git a/web/src/features/traces/components/TraceMessagesView/TraceMessagesView.tsx b/web/src/features/traces/components/TraceMessagesView/TraceMessagesView.tsxnew file mode 100644index 0000000000..bdfd8fe909--- /dev/null+++ b/web/src/features/traces/components/TraceMessagesView/TraceMessagesView.tsx@@ -0,0 +1,226 @@+/**+ * TraceMessagesView - the trace as a conversation transcript+ *+ * Internal preview behind the `traceMessages` flag. Renders the transcript+ * assembled server-side from the trace's generations and tools with the same+ * message components as the formatted IO view: replayed conversation history+ * first, then the current turn with links to the observations that emitted it.+ */++import { useMemo, useState } from "react";+import { ErrorBoundary } from "@sentry/nextjs";+import type { NormalizedMessage } from "@langfuse/shared/src/utils/normalized-io";+import { api, type RouterOutputs } from "@/src/utils/api";+import { Button } from "@/src/components/ui/button";+import { useMarkdownRenderCharacterLimit } from "@/src/hooks/useMarkdownRenderCharacterLimit";+import { type MediaReturnType } from "@/src/features/media/validation";+import { ChatMessageList } from "@/src/features/traces/components/ChatMessageList";+import { useSelection } from "@/src/features/traces/contexts/SelectionContext";+import { useTraceData } from "@/src/features/traces/contexts/TraceDataContext";+import { toIOPreview } from "@/src/features/traces/parsers/toIOPreview";+import { useDesktopLayoutContextOptional } from "../TraceLayoutDesktop";++type Transcript = NonNullable<+ RouterOutputs["events"]["transcriptByTraceId"]["transcript"]+>;+type Thread = Transcript["threads"][number];++// Media is looked up per contributing observation; bound the request fan-out+// of agentic turns with very many tool calls.+const MAX_MEDIA_LOOKUPS_PER_TURN = 20;++export function TraceMessagesView() {+ const { trace, observations } = useTraceData();+ const { data, isLoading, error } = api.events.transcriptByTraceId.useQuery({+ projectId: trace.projectId,+ traceId: trace.id,+ timestamp: trace.timestamp,+ });+ const observationNames = useMemo(+ () => new Map(observations.map((o) => [o.id, o.name ?? o.id])),+ [observations],+ );++ if (isLoading) {+ return <Notice>Assembling messages…</Notice>;+ }+ if (error) {+ return <Notice>{error.message}</Notice>;+ }+ if (!data?.transcript) {+ return (+ <div className="flex flex-col">+ {data?.cutoff && <CutoffNotice />}+ <Notice>+ No messages. Transcripts are assembled from generations and tool+ observations with chat-shaped input and output.+ </Notice>+ </div>+ );+ }++ const { threads } = data.transcript;+ return (+ <div className="flex h-full w-full flex-col gap-6 overflow-y-auto p-3">+ {data.cutoff && <CutoffNotice />}+ {threads.map((thread, index) => (+ <ErrorBoundary+ key={index}+ fallback={<Notice>Unprocessable content.</Notice>}+ >+ <ThreadBlock+ thread={thread}+ title={threads.length > 1 ? `Thread ${index + 1}` : undefined}+ observationNames={observationNames}+ projectId={trace.projectId}+ traceId={trace.id}+ />+ </ErrorBoundary>+ ))}+ </div>+ );+}++function ThreadBlock({+ thread,+ title,+ observationNames,+ projectId,+ traceId,+}: {+ thread: Thread;+ title?: string;+ observationNames: Map<string, string>;+ projectId: string;+ traceId: string;+}) {+ const { setSelectedNodeId } = useSelection();+ const layout = useDesktopLayoutContextOptional();+ // History is context, not the point of the view; start folded.+ const [showHistory, setShowHistory] = useState(false);+ // Media of the emitting observations, so inline references resolve the way+ // they do in the formatted view. History has no emitter to ask.+ const mediaQueries = api.useQueries((t) =>+ thread.currentTurn.observations+ .slice(0, MAX_MEDIA_LOOKUPS_PER_TURN)+ .map(({ id }) =>+ t.media.getByTraceOrObservationId(+ { projectId, traceId, observationId: id },+ { refetchOnWindowFocus: false, staleTime: 50 * 60 * 1000 },+ ),+ ),+ );+ const media = mediaQueries.flatMap((query) => query.data ?? []);++ const selectObservation = (id: string) => {+ setSelectedNodeId(id);+ layout?.expandDetailPanel();+ };++ return (+ <section className="flex flex-col gap-3">+ {title && <h3 className="text-sm font-bold">{title}</h3>}+ {thread.conversationHistory.length > 0 && (+ <>+ <SectionLabel>+ <button+ type="button"+ className="hover:text-foreground"+ onClick={() => setShowHistory((shown) => !shown)}+ >+ {showHistory ? "Hide" : "Show"} conversation history (+ {thread.conversationHistory.length})+ </button>+ </SectionLabel>+ {showHistory && (+ <div className="opacity-70">+ <MessageList messages={thread.conversationHistory} media={[]} />+ </div>+ )}+ <SectionLabel>Current turn</SectionLabel>+ </>+ )}+ <div className="flex flex-wrap gap-1">+ {thread.currentTurn.observations.map(({ id }) => (+ <Button+ key={id}+ variant="outline"+ size="sm"+ className="h-6 px-2 text-xs"+ title="Show observation"+ onClick={() => selectObservation(id)}+ >+ {observationNames.get(id) ?? id}+ </Button>+ ))}+ </div>+ <MessageList messages={thread.currentTurn.messages} media={media} />+ </section>+ );+}++/** Formatted IO rendering of normalized messages, without re-parsing. */+function MessageList({+ messages,+ media,+}: {+ messages: NormalizedMessage[];+ media: MediaReturnType[];+}) {+ const characterLimit = useMarkdownRenderCharacterLimit();+ const preview = useMemo(+ () =>+ toIOPreview({+ messages,+ toolDefinitions: [],+ span: { input: undefined, output: undefined, metadata: undefined },+ }),+ [messages],+ );+ // Same size gate as the formatted view.+ const shouldRenderMarkdown = useMemo(+ () => JSON.stringify(preview.allMessages).length <= characterLimit,+ [preview, characterLimit],+ );++ return (+ <div className="[&_.io-message-content]:px-2 [&_.io-message-header]:px-2">+ <ChatMessageList+ messages={preview.allMessages}+ shouldRenderMarkdown={shouldRenderMarkdown}+ media={media}+ currentView="pretty"+ messageToToolCallNumbers={preview.messageToToolCallNumbers}+ inputMessageCount={preview.inputMessageCount}+ collapseLongHistory={false}+ />+ </div>+ );+}++function SectionLabel({ children }: { children: React.ReactNode }) {+ return (+ <div className="text-muted-foreground flex items-center gap-2 text-xs tracking-wide uppercase">+ <span className="bg-border h-px flex-1" />+ {children}+ <span className="bg-border h-px flex-1" />+ </div>+ );+}++function CutoffNotice() {+ return (+ <Notice>+ This trace exceeds the observation cap. Later observations are not part of+ the transcript.+ </Notice>+ );+}++function Notice({ children }: { children: React.ReactNode }) {+ return (+ <div className="text-muted-foreground m-3 rounded-md border border-dashed p-3 text-sm">+ {children}+ </div>+ );+}diff --git a/web/src/features/traces/components/TracePanelNavigation.tsx b/web/src/features/traces/components/TracePanelNavigation.tsxindex c724c74d0b..fe626c7e86 100644--- a/web/src/features/traces/components/TracePanelNavigation.tsx+++ b/web/src/features/traces/components/TracePanelNavigation.tsx@@ -2,7 +2,7 @@* TracePanelNavigation - Pure content component for navigation panel** Responsibility:- * - Decide which navigation view to show (Tree/Timeline/Search)+ * - Decide which navigation view to show (Tree/Timeline/Graph/Messages/Search)* - The Timeline is either the classic gantt or the Compact Timeline, depending* on that feature preview* - NO layout structure - just returns the content component@@ -24,6 +24,9 @@ import { TraceTree } from "./TraceTree";import { TraceSearchList } from "./TraceSearchList";import { TraceTimelineCompact } from "./TraceTimelineDense/TraceTimelineCompact";import { TraceGraphView } from "./TraceGraphView/TraceGraphView";+import { TraceMessagesView } from "./TraceMessagesView/TraceMessagesView";+import useIsFeatureEnabled from "@/src/features/feature-flags/hooks/useIsFeatureEnabled";+import { useReadPath } from "@/src/features/events";import { useMemo } from "react";export function TracePanelNavigation() {@@ -31,9 +34,14 @@ export function TracePanelNavigation() {const { isGraphViewAvailable, isLoading: isGraphLoading } =useTraceGraphData();const [viewMode] = useQueryParam("view", StringParam);+ const { isV4 } = useReadPath();+ const messagesEnabled = useIsFeatureEnabled("traceMessages") && isV4;const hasQuery = searchQuery.trim().length > 0;const isTimelineView = viewMode === "timeline";+ // Internal preview of the events-backed trace view; a stale ?view=messages+ // falls back to tree for everyone else.+ const isMessagesView = viewMode === "messages" && messagesEnabled;// Availability is false while the graph query loads, so hold the view until it// resolves. Stale ?view=graph then falls back to tree.const isGraphView =@@ -49,6 +57,9 @@ export function TracePanelNavigation() {//// The Tree still hands a query to the flat list; highlighting it is its own// change.+ if (isMessagesView) {+ return <TraceMessagesView />;+ }if (isGraphView) {return <TraceGraphView />;}@@ -59,7 +70,7 @@ export function TracePanelNavigation() {return <TraceSearchList />;}return <TraceTree />;- }, [hasQuery, isGraphView, isTimelineView]);+ }, [hasQuery, isGraphView, isMessagesView, isTimelineView]);return content;}diff --git a/web/src/features/traces/components/TracePanelNavigationHeader/TracePanelNavigationHeader.tsx b/web/src/features/traces/components/TracePanelNavigationHeader/TracePanelNavigationHeader.tsxindex 60e627e9ec..93f9e47924 100644--- a/web/src/features/traces/components/TracePanelNavigationHeader/TracePanelNavigationHeader.tsx+++ b/web/src/features/traces/components/TracePanelNavigationHeader/TracePanelNavigationHeader.tsx@@ -21,6 +21,7 @@ import {TooltipTrigger,} from "@/src/components/ui/tooltip";import { useReadPath } from "@/src/features/events";+import useIsFeatureEnabled from "@/src/features/feature-flags/hooks/useIsFeatureEnabled";import { Command, CommandInput } from "@/src/components/ui/command";import { Button } from "@/src/components/ui/button";import {@@ -103,6 +104,9 @@ function TracePanelNavigationHeaderExpanded({isLoading: isGraphLoading,} = useTraceGraphData();const { isV4 } = useReadPath();+ // Internal preview of the events-backed trace view; legacy traces have no+ // transcript to offer.+ const messagesEnabled = useIsFeatureEnabled("traceMessages") && isV4;const [viewMode, setViewMode] = useQueryParam("view", StringParam);const capture = usePostHogClientCapture();const analyticsDimensions = useTraceAnalyticsDimensions();@@ -196,7 +200,9 @@ function TracePanelNavigationHeaderExpanded({? "timeline": viewMode === "graph" && graphResolved? "graph"- : "tree";+ : viewMode === "messages" && messagesEnabled+ ? "messages"+ : "tree";return (<Command className="flex h-auto shrink-0 flex-col gap-1 overflow-hidden rounded-none border-b">@@ -326,6 +332,7 @@ function TracePanelNavigationHeaderExpanded({<ViewModeSwitchactiveView={activeView}graphDisabledReason={graphDisabledReason}+ showMessages={messagesEnabled}onSelect={(view) => {// Clicking the already-active segment is a no-op — don't count it.if (view !== activeView) {@@ -335,6 +342,10 @@ function TracePanelNavigationHeaderExpanded({});}setViewMode(view === "tree" ? null : view);+ // The transcript wants the width; the rail's "Show detail+ // panel" button and selecting an observation bring it back.+ if (view === "messages")+ layout?.detailPanelRef.current?.collapse();}}/>{/* When the detail panel is closed it shows its own collapsed rail@@ -353,16 +364,19 @@ const GRAPH_UNAVAILABLE_COPY: Record<GraphUnavailableReason, string> = {"no-structure": "Nothing to graph. This trace has only one node.",};-type TraceViewMode = "tree" | "timeline" | "graph";+type TraceViewMode = "tree" | "timeline" | "graph" | "messages";function ViewModeSwitch({activeView,graphDisabledReason,+ showMessages,onSelect,}: {activeView: TraceViewMode;/** Present when the trace has no graph: the segment renders disabled. */graphDisabledReason?: string;+ /** Internal preview: the Messages segment exists only for internal users. */+ showMessages: boolean;onSelect: (view: TraceViewMode) => void;}) {return (@@ -387,6 +401,13 @@ function ViewModeSwitch({disabled={Boolean(graphDisabledReason)}title={graphDisabledReason}/>+ {showMessages && (+ <ViewModeSegment+ active={activeView === "messages"}+ onClick={() => onSelect("messages")}+ label="Messages"+ />+ )}</div>);}