🪢 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(sessions): Session view improvements (#18479)
Ben Bachem5f9f1c52e1a0
diff --git a/web/src/__tests__/server/unit/loadTraceTranscript.servertest.ts b/web/src/__tests__/server/unit/loadTraceTranscript.servertest.tsindex a644e76f17..77225e88a8 100644--- a/web/src/__tests__/server/unit/loadTraceTranscript.servertest.ts+++ b/web/src/__tests__/server/unit/loadTraceTranscript.servertest.ts@@ -2,13 +2,24 @@ import { beforeEach, expect, it, vi } from "vitest";import type { Transcript } from "@langfuse/shared/src/server";import { loadTraceTranscript } from "@/src/features/events/server/loadTraceTranscript";-const mocks = vi.hoisted(() => ({ assemble: vi.fn(), observations: vi.fn() }));-vi.mock("@langfuse/shared/src/server", () => ({- MAX_OBSERVATIONS_PER_TRACE: 10000,- orderObservations: (observations: unknown[]) => observations,- assembleTranscript: mocks.assemble,- getObservationsForTraceFromEventsTable: mocks.observations,+const mocks = vi.hoisted(() => ({+ assemble: vi.fn(),+ observations: vi.fn(),+ root: vi.fn(),}));+vi.mock("@langfuse/shared/src/server", async () => {+ const { normalizeSpanIO } =+ await import("@langfuse/shared/src/utils/normalized-io");+ return {+ MAX_OBSERVATIONS_PER_TRACE: 10000,+ orderObservations: (observations: unknown[]) => observations,+ assembleTranscript: mocks.assemble,+ getObservationsForTraceFromEventsTable: mocks.observations,+ getObservationByIdFromEventsTable: mocks.root,+ normalizeIO: ({ io }: { io: Parameters<typeof normalizeSpanIO>[0] }) =>+ normalizeSpanIO(io),+ };+});const trace = {projectId: "project",traceId: "trace",@@ -71,7 +82,169 @@ function fixture(});return transcript;}-beforeEach(() => vi.clearAllMocks());+beforeEach(() => vi.resetAllMocks());++it.each([+ { parentObservationId: null, isRootObservation: true },+ { parentObservationId: "", isRootObservation: undefined },+ { parentObservationId: "external-parent", isRootObservation: true },+])(+ "falls back to normalized root input/output with root provenance: %j",+ async ({ parentObservationId, isRootObservation }) => {+ const root = {+ id: "root",+ traceId: "trace",+ parentObservationId,+ isRootObservation,+ type: "SPAN",+ name: "Root",+ startTime: new Date(0),+ endTime: new Date(1000),+ input: "Question",+ output: "Answer",+ metadata: {},+ };+ mocks.assemble.mockReturnValue(null);+ mocks.observations.mockResolvedValue({+ observations: [root],+ totalCount: 1,+ });+ mocks.root.mockResolvedValue(root);++ const result = await loadTraceTranscript({+ ...trace,+ fallbackToRootIO: true,+ });++ expect(mocks.root).toHaveBeenCalledWith({+ projectId: "project",+ traceId: "trace",+ id: "root",+ startTime: new Date(0),+ fetchWithInputOutput: true,+ });+ expect(result.cutoff).toBe(false);+ expect(result.transcript?.threads).toHaveLength(1);+ expect(result.transcript?.threads[0]?.currentTurn).toMatchObject({+ nestingLevel: 0,+ observations: [{ id: "root", traceId: "trace" }],+ messages: [+ {+ role: "user",+ source: "input",+ parts: [{ type: "text", text: "Question" }],+ observationId: "root",+ traceId: "trace",+ startTime: root.startTime,+ endTime: root.endTime,+ },+ {+ role: "assistant",+ source: "output",+ parts: [{ type: "text", text: "Answer" }],+ observationId: "root",+ traceId: "trace",+ startTime: root.startTime,+ endTime: root.endTime,+ },+ ],+ });+ },+);++it("falls back to seeded JSON chat messages with an empty-string root parent", async () => {+ const root = {+ id: "t-seed-media-image-only",+ traceId: "seed-media-image-only",+ parentObservationId: "",+ startTime: new Date(0),+ endTime: null,+ input: JSON.stringify([+ {+ role: "user",+ content: [+ { type: "text", text: "Please analyze the seeded image attachment." },+ {+ type: "image_url",+ image_url: {+ url: "@@@langfuseMedia:type=image/png|id=seed-image|source=base64_data_uri@@@",+ },+ },+ ],+ },+ ]),+ output: JSON.stringify([{ role: "assistant", content: "Image analysis" }]),+ metadata: "{}",+ };+ mocks.assemble.mockReturnValue(null);+ mocks.observations.mockResolvedValue({ observations: [root], totalCount: 1 });+ mocks.root.mockResolvedValue(root);++ const result = await loadTraceTranscript({+ ...trace,+ traceId: root.traceId,+ fallbackToRootIO: true,+ });+ expect(result.transcript?.threads[0]?.currentTurn.messages).toMatchObject([+ {+ observationId: root.id,+ role: "user",+ parts: expect.arrayContaining([+ { type: "text", text: "Please analyze the seeded image attachment." },+ ]),+ },+ {+ observationId: root.id,+ role: "assistant",+ parts: [{ type: "text", text: "Image analysis" }],+ },+ ]);+});++it("does not fetch root I/O when an existing transcript is available", async () => {+ const original = fixture();+ const result = await loadTraceTranscript({+ ...trace,+ fallbackToRootIO: true,+ });+ expect(result.transcript).toBe(original);+ expect(mocks.root).not.toHaveBeenCalled();+});++it("leaves an empty transcript unchanged unless fallback is enabled", async () => {+ mocks.assemble.mockReturnValue(null);+ mocks.observations.mockResolvedValue({+ observations: [{ id: "root", parentObservationId: null }],+ totalCount: 1,+ });+ expect((await loadTraceTranscript(trace)).transcript).toBeNull();+ expect(mocks.root).not.toHaveBeenCalled();+});++it("leaves the transcript empty when no root was found", async () => {+ mocks.assemble.mockReturnValue(null);+ mocks.observations.mockResolvedValue({ observations: [], totalCount: 0 });+ expect(+ (await loadTraceTranscript({ ...trace, fallbackToRootIO: true }))+ .transcript,+ ).toBeNull();+ expect(mocks.root).not.toHaveBeenCalled();+});++it("leaves the transcript empty when the root has no input/output", async () => {+ mocks.assemble.mockReturnValue(null);+ mocks.observations.mockResolvedValue({+ observations: [+ { id: "root", parentObservationId: null, startTime: new Date(0) },+ ],+ totalCount: 1,+ });+ mocks.root.mockResolvedValue({ input: null, output: null, metadata: {} });+ expect(+ (await loadTraceTranscript({ ...trace, fallbackToRootIO: true }))+ .transcript,+ ).toBeNull();+});it("opts into provenance-based reverse multi-call responses without mutating assembly", async () => {const original = fixture();const snapshot = structuredClone(original);diff --git a/web/src/components/ui/MarkdownViewer.stories.tsx b/web/src/components/ui/MarkdownViewer.stories.tsxindex e5b25c277e..a768e093da 100644--- a/web/src/components/ui/MarkdownViewer.stories.tsx+++ b/web/src/components/ui/MarkdownViewer.stories.tsx@@ -1,5 +1,5 @@import preview from "../../../.storybook/preview";-import { expect, userEvent, waitFor, within } from "storybook/test";+import { expect, waitFor, within } from "storybook/test";import { MarkdownView } from "./MarkdownViewer";const meta = preview.meta({@@ -16,29 +16,6 @@ export const Default = meta.story({},});-export const CollapsedPlainTextFallback = meta.story({- name: "(Test) Collapsed Plain Text Fallback",- args: {- markdown: `${"> ".repeat(101)}Deeply nested content`,- fallbackDisplay: "collapsed",- },- play: async ({ canvasElement }) => {- const canvas = within(canvasElement);- const content = canvas.getByText(- `${"> ".repeat(101)}Deeply nested content`,- {- exact: false,- selector: "pre",- },- );- await expect(content).not.toBeVisible();- await userEvent.click(canvas.getByText("Expand content"));- await expect(content).toBeVisible();- await userEvent.click(canvas.getByText("Collapse content"));- await expect(content).not.toBeVisible();- },-});-export const NestedLists = meta.story({args: {markdown: `In practical terms, it helps you:diff --git a/web/src/components/ui/MarkdownViewer.tsx b/web/src/components/ui/MarkdownViewer.tsxindex aa4240a927..0ded7e7d63 100644--- a/web/src/components/ui/MarkdownViewer.tsx+++ b/web/src/components/ui/MarkdownViewer.tsx@@ -3,7 +3,6 @@import { cn } from "@/src/utils/tailwind";import {type FC,- type ComponentProps,type ReactNode,type ReactElement,memo,@@ -20,7 +19,7 @@ import ReactMarkdown, {import remarkGfm from "remark-gfm";import { Codeblock as CodeBlock } from "@/src/components/design-system/Codeblock/Codeblock";import { useTheme } from "next-themes";-import { ChevronRight, ImageOff, Info } from "lucide-react";+import { ImageOff, Info } from "lucide-react";import { MentionBadge } from "@/src/features/comments/components/MentionBadge";import {OpenAIUrlImageUrl,@@ -415,11 +414,9 @@ const markdownComponents: NonNullable<Options["components"]> = {function MarkdownRenderer({markdown,className,- fallbackDisplay,}: {markdown: string;className?: string;- fallbackDisplay?: "expanded" | "collapsed";}) {const promptReferenceProjectId = usePromptReferenceProjectId();const characterLimit = useMarkdownRenderCharacterLimit();@@ -441,34 +438,9 @@ function MarkdownRenderer({Content is too large or deeply nested to render as markdown.Displaying as plain text.</div>- {fallbackDisplay === "collapsed" ? (- <details className="group" data-markdown-fallback>- <Button- asChild- variant="ghost"- size="sm"- className="text-muted-foreground w-fit cursor-pointer justify-start gap-1.5 text-left text-xs [&::-webkit-details-marker]:hidden"- >- <summary>- <ChevronRight- className="icon-sm transition-transform group-open:rotate-90"- aria-hidden="true"- />- <span className="group-open:hidden">Expand content</span>- <span className="hidden group-open:inline">- Collapse content- </span>- </summary>- </Button>- <pre className="pt-2 text-base break-words whitespace-pre-wrap">- {markdown}- </pre>- </details>- ) : (- <pre className="text-base break-words whitespace-pre-wrap">- {markdown}- </pre>- )}+ <pre className="text-base break-words whitespace-pre-wrap">+ {markdown}+ </pre></div>);}@@ -539,7 +511,6 @@ export function MarkdownView({controlButtons,afterHeader,isSystemPrompt,- fallbackDisplay,}: {/** The UNPARSED content shape — see `canRenderContentAsMarkdown`. Mediareference strings must still be strings when they reach the part guards. */@@ -556,7 +527,6 @@ export function MarkdownView({(`role === "system"`) — the title can be a message `name` instead of therole. Falls back to matching the title for callers without role data. */isSystemPrompt?: boolean;- fallbackDisplay?: ComponentProps<typeof MarkdownRenderer>["fallbackDisplay"];}) {const { forcedTheme, resolvedTheme } = useTheme();const theme = forcedTheme ?? resolvedTheme;@@ -656,7 +626,6 @@ export function MarkdownView({<><MarkdownRenderermarkdown={isCollapsed ? truncatedContent : markdown}- fallbackDisplay={fallbackDisplay}/>{collapseToggle}</>@@ -669,10 +638,7 @@ export function MarkdownView({<>{isCollapsed ? (<>- <MarkdownRenderer- markdown={truncatedContent}- fallbackDisplay={fallbackDisplay}- />+ <MarkdownRenderer markdown={truncatedContent} />{(markdown ?? []).map((content, index) =>isOpenAITextContentPart(content)? null@@ -688,7 +654,6 @@ export function MarkdownView({{audio ? (<><MarkdownRenderer- fallbackDisplay={fallbackDisplay}markdown={audio.transcript ? "[Audio] \n" + audio.transcript : ""}@@ -735,13 +700,7 @@ export function MarkdownView({}if (isOpenAITextContentPart(content)) {- return (- <MarkdownRenderer- key={index}- markdown={content.text}- fallbackDisplay={fallbackDisplay}- />- );+ return <MarkdownRenderer key={index} markdown={content.text} />;}if (content.type === "image_url") {diff --git a/web/src/features/events/server/eventsRouter.ts b/web/src/features/events/server/eventsRouter.tsindex 8cf07fb84b..15cd1be148 100644--- a/web/src/features/events/server/eventsRouter.ts+++ b/web/src/features/events/server/eventsRouter.ts@@ -446,6 +446,7 @@ export const eventsRouter = createTRPCRouter({traceId: zodSchema.string(),timestamp: zodSchema.date().optional(),pairTextToolResponses: zodSchema.boolean().default(false),+ fallbackToRootIO: zodSchema.boolean().default(false),}),).query(async ({ input, ctx }) => {@@ -494,6 +495,7 @@ export const eventsRouter = createTRPCRouter({traceId: input.traceId,timestamp,pairTextToolResponses: input.pairTextToolResponses,+ fallbackToRootIO: input.fallbackToRootIO,});},);diff --git a/web/src/features/events/server/loadTraceTranscript.ts b/web/src/features/events/server/loadTraceTranscript.tsindex 44be87d266..78f3322c7f 100644--- a/web/src/features/events/server/loadTraceTranscript.ts+++ b/web/src/features/events/server/loadTraceTranscript.ts@@ -1,8 +1,10 @@import {assembleTranscript,+ getObservationByIdFromEventsTable,getObservationsForTraceFromEventsTable,MAX_OBSERVATIONS_PER_TRACE,orderObservations,+ normalizeIO,type Transcript,} from "@langfuse/shared/src/server";import type { ToolCallPart } from "@langfuse/shared/src/utils/normalized-io";@@ -27,6 +29,8 @@ export async function loadTraceTranscript(trace: {* Ambiguous responses remain unchanged. Disabled by default.*/pairTextToolResponses?: boolean;+ /** Use root observation I/O when no generation/tool transcript exists. */+ fallbackToRootIO?: boolean;}): Promise<{transcript: Transcript | null;/** The trace has more observations than the transcript could read. */@@ -52,6 +56,52 @@ export async function loadTraceTranscript(trace: {return TRANSCRIPT_OBSERVATION_TYPES.has(o.type) ? [] : [o];});let transcript = assembleTranscript(orderObservations(observations));+ if (!transcript && trace.fallbackToRootIO) {+ const root = structure.observations.find(+ (observation) =>+ observation.isRootObservation === true ||+ !observation.parentObservationId,+ );+ if (root) {+ const rootWithContent = await getObservationByIdFromEventsTable({+ projectId: trace.projectId,+ traceId: trace.traceId,+ id: root.id,+ startTime: root.startTime,+ fetchWithInputOutput: true,+ });+ if (rootWithContent) {+ const { messages } = normalizeIO({+ kind: "io",+ io: {+ input: rootWithContent.input,+ output: rootWithContent.output,+ metadata: rootWithContent.metadata,+ },+ });+ if (messages.length > 0) {+ transcript = {+ threads: [+ {+ conversationHistory: [],+ currentTurn: {+ nestingLevel: 0,+ observations: [{ id: root.id, traceId: trace.traceId }],+ messages: messages.map((message) => ({+ ...message,+ observationId: root.id,+ traceId: trace.traceId,+ startTime: rootWithContent.startTime,+ endTime: rootWithContent.endTime,+ })),+ },+ },+ ],+ };+ }+ }+ }+ }// TODO: Evaluate moving general pairing into shared transcript assembly once// it preserves resolved call identity for text-only tool responses.if (trace.pairTextToolResponses && transcript) {diff --git a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/SessionConversationalView.stories.tsx b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/SessionConversationalView.stories.tsxindex 58b44e5641..bb69361f5c 100644--- a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/SessionConversationalView.stories.tsx+++ b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/SessionConversationalView.stories.tsx@@ -2271,7 +2271,7 @@ function SessionConversationalViewStory({className="absolute top-0 left-0"onClick={() => setTranscriptsLoaded(true)}>- Load transcripts+ Load messages</button>)}<SessionConversationalView@@ -2742,7 +2742,7 @@ export const DelayedTranscriptNavigation = meta.story({sidebar.getByRole("button", { name: "2 Navigation turn 2" }),).toHaveAttribute("aria-current", "true");await userEvent.click(- canvas.getByRole("button", { name: "Load transcripts" }),+ canvas.getByRole("button", { name: "Load messages" }),);await expectNavigation(canvasElement,@@ -2760,20 +2760,31 @@ export const SidebarFollowResume = meta.story({const canvas = within(canvasElement);const feed = canvas.getByLabelText("Session conversation timeline");const list = canvas.getByRole("region", { name: "Session turns" });- list.dispatchEvent(new WheelEvent("wheel", { deltaY: 100, bubbles: true }));- feed.scrollTo({ top: feed.scrollHeight, behavior: "instant" });- await waitFor(() => expect(list.scrollTop).toBeGreaterThan(0), {- timeout: 3_000,- });const sidebar = within(canvas.getByRole("complementary"));- const active = await sidebar.findByRole("button", {- name: /^32\.2 Navigation turn 32/,- });- await expect(active).toHaveAttribute("aria-current", "true");- const activeRect = active.getBoundingClientRect();- const listRect = list.getBoundingClientRect();- await expect(activeRect.top).toBeGreaterThanOrEqual(listRect.top);- await expect(activeRect.bottom).toBeLessThanOrEqual(listRect.bottom);+ list.dispatchEvent(new WheelEvent("wheel", { deltaY: 100, bubbles: true }));+ await waitFor(+ () => {+ // Newly mounted rows replace estimates, moving the end of the timeline.+ feed.scrollTo({ top: feed.scrollHeight, behavior: "instant" });+ expect(+ sidebar.getByRole("button", { name: /^32\.2 Navigation turn 32/ }),+ ).toHaveAttribute("aria-current", "true");+ },+ { timeout: 3_000 },+ );+ await waitFor(+ () => {+ const active = sidebar.getByRole("button", {+ name: /^32\.2 Navigation turn 32/,+ });+ expect(active).toHaveAttribute("aria-current", "true");+ const activeRect = active.getBoundingClientRect();+ const listRect = list.getBoundingClientRect();+ expect(activeRect.top).toBeGreaterThanOrEqual(listRect.top);+ expect(activeRect.bottom).toBeLessThanOrEqual(listRect.bottom);+ },+ { timeout: 3_000 },+ );},});export const NestedThreadsHidden = meta.story({@@ -3049,7 +3060,7 @@ export const CollapsedLargeMessage = meta.story({parts: [{type: "text",- text: `${"> ".repeat(101)}Deeply nested diagnostic output\n\n${"Diagnostic line: operation completed successfully.\n".repeat(300)}`,+ text: `${"> ".repeat(101)}Deeply nested diagnostic output\n\n${"Diagnostic line: operation completed successfully.\n".repeat(300)}Search match near the end`,},],},@@ -3087,23 +3098,51 @@ export const CollapsedLargeMessage = meta.story({selector: "pre",},);- await expect(content).not.toBeVisible();+ const toggle = await timeline.findByRole("button", { name: "Show more" });+ const preview = canvasElement.ownerDocument.getElementById(+ toggle.getAttribute("aria-controls") ?? "",+ );+ await expect(toggle).toHaveAttribute("aria-expanded", "false");+ await expect(preview).toHaveClass("max-h-96");+ await expect(content.getBoundingClientRect().height).toBeGreaterThan(+ preview?.getBoundingClientRect().height ?? 0,+ );await expect(timeline.getByText("Summary: all operations completed successfully."),).toBeVisible();- await userEvent.click(timeline.getByText("Expand content"));- await expect(content).toBeVisible();- await userEvent.click(timeline.getByText("Collapse content"));- await expect(content).not.toBeVisible();+ await userEvent.click(toggle);+ await expect(+ timeline.getByRole("button", { name: "Show less" }),+ ).toHaveAttribute("aria-expanded", "true");+ await expect(preview).not.toHaveClass("max-h-96");+ await userEvent.click(timeline.getByRole("button", { name: "Show less" }));+ await expect(toggle).toHaveAttribute("aria-expanded", "false");+ await expect(preview).toHaveClass("max-h-96");const sidebar = within(within(canvasElement).getByRole("complementary"));await userEvent.type(sidebar.getByRole("textbox"),- "Deeply nested diagnostic output",+ "Search match near the end",);await userEvent.click(await sidebar.findByRole("button", { name: "Assistant message" }),);- await waitFor(() => expect(content).toBeVisible());+ await waitFor(() => {+ expect(+ timeline.getByRole("button", { name: "Show less" }),+ ).toHaveAttribute("aria-expanded", "true");+ expect(preview).not.toHaveClass("max-h-96");+ });+ await userEvent.click(timeline.getByRole("button", { name: "Show less" }));+ await expect(preview).toHaveClass("max-h-96");+ await userEvent.click(+ sidebar.getByRole("button", { name: "Assistant message" }),+ );+ await waitFor(() => {+ expect(+ timeline.getByRole("button", { name: "Show less" }),+ ).toHaveAttribute("aria-expanded", "true");+ expect(preview).not.toHaveClass("max-h-96");+ });},});export const ManySimpleTurns = meta.story({@@ -3213,9 +3252,7 @@ export const PendingSearch = meta.story({play: async ({ canvasElement }) => {const canvas = within(canvasElement);const sidebar = within(canvas.getByRole("complementary"));- await expect(- sidebar.getByText("Loading transcripts..."),- ).toBeInTheDocument();+ await expect(sidebar.getByText("Loading messages...")).toBeInTheDocument();await expect(sidebar.queryByRole("button", { name: "1 First turn" }),).not.toBeInTheDocument();diff --git a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/SessionConversationalView.tsx b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/SessionConversationalView.tsxindex e4067875e7..35b0f660fb 100644--- a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/SessionConversationalView.tsx+++ b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/SessionConversationalView.tsx@@ -284,7 +284,6 @@ export function SessionConversationalView(<SessionConversationTimelinetraces={timelineItems}controller={props.controller}- filterMeasurementKey="transcript"/></div></div>diff --git a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationSidebar/SessionConversationSidebar.tsx b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationSidebar/SessionConversationSidebar.tsxindex 13a85a46f3..22f5056609 100644--- a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationSidebar/SessionConversationSidebar.tsx+++ b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationSidebar/SessionConversationSidebar.tsx@@ -9,7 +9,6 @@ import { useVirtualizer } from "@tanstack/react-virtual";import { ChevronDown, Search } from "lucide-react";import { Input } from "@/src/components/ui/input";import { CustomTooltip } from "@/src/components/design-system/CustomTooltip/CustomTooltip";-import { SessionVirtualizedRow } from "@/src/features/sessions/SessionVirtualizedRow";import { type EventSessionTrace } from "@/src/features/sessions/sessionDetailPageTypes";import {formatIdleGap,@@ -255,8 +254,8 @@ export function SessionConversationSidebar(const searchQuery = props.search.trim();const emptyLabel = (() => {- if (props.isLoadingTranscripts) return "Loading transcripts...";- if (props.transcriptLoadError) return "Failed to load transcripts";+ if (props.isLoadingTranscripts) return "Loading messages...";+ if (props.transcriptLoadError) return "Failed to load messages";if (props.search) return "No matching turns";return "No turns";})();@@ -291,7 +290,7 @@ export function SessionConversationSidebar(ref={setListElement}role="region"aria-label="Session turns"- className="min-h-0 flex-1 overflow-y-auto"+ className="min-h-0 flex-1 overflow-y-auto [overflow-anchor:none]"onWheel={pauseAutoFollow}onTouchMove={pauseAutoFollow}onKeyDown={(event) => {@@ -351,13 +350,17 @@ export function SessionConversationSidebar(!sidebarTrace.itemId &&(sidebarTrace.threadCount ?? threads.size) > 1;return (- <SessionVirtualizedRow+ <divkey={item.key}- itemKey={String(item.key)}- measurementKey={`${String(item.key)}:${isCollapsed}:${props.search}`}- source="modern"- virtualItem={item}- virtualizer={virtualizer}+ ref={virtualizer.measureElement}+ data-index={item.index}+ data-session-virtualizer-row="modern"+ style={{+ position: "absolute",+ top: item.start,+ left: 0,+ width: "100%",+ }}>{props.search.trim() === "" &&idleGapSeconds !== null &&@@ -421,7 +424,7 @@ export function SessionConversationSidebar()}{transcriptRows === null && (<p className="text-muted-foreground px-1 py-2 text-xs">- Failed to load transcript+ Failed to load messages</p>)}{transcriptRows?.length === 0 && (@@ -649,7 +652,7 @@ export function SessionConversationSidebar()}</div></div>- </SessionVirtualizedRow>+ </div>);})}</div>diff --git a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/SessionConversationTimeline.stories.tsx b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/SessionConversationTimeline.stories.tsxindex a01b36022d..8fa0756e29 100644--- a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/SessionConversationTimeline.stories.tsx+++ b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/SessionConversationTimeline.stories.tsx@@ -1,39 +1,87 @@import preview from "@/.storybook/preview";-import { expect, fn, waitFor } from "storybook/test";+import { expect, fn, userEvent, waitFor } from "storybook/test";import { SessionConversationTimeline } from "@/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/SessionConversationTimeline";import { useSessionConversationTimelineController } from "@/src/features/sessions/hooks/useSessionConversationTimelineController";-function SessionConversationTimelineStory() {- const traces = Array.from({ length: 3 }, (_, index) => ({- trace: {- id: `trace-${index + 1}`,- name: `Turn ${index + 1}`,- timestamp: new Date("2026-09-24T12:00:00Z"),- environment: "default",- userId: null,- observationCount: 0,- latencyMs: null,- scores: [],- },- turnNumber: index + 1,- state: { type: "loading" as const },- onOpenTrace: fn(),- onOpenObservation: fn(),- scrollTarget: null,- }));+function SessionConversationTimelineStory({+ dynamicContent,+}: {+ dynamicContent: boolean;+}) {+ const traces = Array.from(+ { length: dynamicContent ? 40 : 3 },+ (_, index) => ({+ trace: {+ id: `trace-${index + 1}`,+ name: `Turn ${index + 1}`,+ timestamp: new Date("2026-09-24T12:00:00Z"),+ environment: "default",+ userId: null,+ observationCount: 0,+ latencyMs: null,+ scores: [],+ },+ turnNumber: index + 1,+ state: dynamicContent+ ? {+ type: "transcript" as const,+ result: {+ state: "loaded" as const,+ cutoff: false,+ transcript: {+ threads: [+ {+ conversationHistory: [],+ currentTurn: {+ nestingLevel: 0,+ observations: [+ {+ id: `observation-${index}`,+ traceId: `trace-${index + 1}`,+ },+ ],+ messages: [+ {+ role: "assistant" as const,+ source: "output" as const,+ observationId: `observation-${index}`,+ traceId: `trace-${index + 1}`,+ startTime: new Date("2026-09-24T12:00:00Z"),+ endTime: null,+ parts: [+ {+ type: "text" as const,+ text: "A dynamic message whose height changes when expanded or resized. ".repeat(+ 80 + index * 2,+ ),+ },+ ],+ },+ ],+ },+ },+ ],+ },+ },+ }+ : { type: "loading" as const },+ onOpenTrace: fn(),+ onOpenObservation: fn(),+ scrollTarget: null,+ }),+ );const controller = useSessionConversationTimelineController(traces);return (<div className="h-[200px]">- <SessionConversationTimeline- traces={traces}- filterMeasurementKey="storybook"- controller={controller}- />+ <SessionConversationTimeline traces={traces} controller={controller} /></div>);}-const meta = preview.meta({ component: SessionConversationTimelineStory });+const meta = preview.meta({+ component: SessionConversationTimelineStory,+ args: { dynamicContent: false },+});export default meta;export const ScrollableTimeline = meta.story({@@ -51,3 +99,51 @@ export const ScrollableTimeline = meta.story({});},});++export const DynamicRowMeasurement = meta.story({+ name: "(Test) Keeps Dynamic Rows Contiguous",+ args: { dynamicContent: true },+ play: async ({ canvas, canvasElement }) => {+ const timeline = canvas.getByLabelText("Session conversation timeline");+ const expectContiguousRows = async () => {+ await waitFor(() => {+ const rows = Array.from(+ timeline.querySelectorAll<HTMLElement>(+ "[data-session-virtualizer-row]",+ ),+ )+ .map((row) => row.getBoundingClientRect())+ .sort((left, right) => left.top - right.top);+ expect(rows.length).toBeGreaterThan(1);+ const viewport = timeline.getBoundingClientRect();+ expect(rows[0]!.top).toBeLessThanOrEqual(viewport.top + 1);+ expect(rows.at(-1)!.bottom).toBeGreaterThanOrEqual(viewport.bottom - 1);+ for (let index = 1; index < rows.length; index++) {+ expect(+ Math.abs(rows[index]!.top - rows[index - 1]!.bottom),+ ).toBeLessThan(2);+ }+ });+ };+ await canvas.findAllByRole("button", { name: "Show more" });+ await expectContiguousRows();+ await userEvent.click(+ canvas.getAllByRole("button", { name: "Show more" })[0]!,+ );+ await expectContiguousRows();+ await userEvent.click(canvas.getByRole("button", { name: "Show less" }));+ await expectContiguousRows();+ for (const offset of [1500, 4500, 9000, 2000, 0]) {+ timeline.scrollTop = offset;+ timeline.dispatchEvent(new Event("scroll", { bubbles: true }));+ await expectContiguousRows();+ }+ const originalWidth = canvasElement.style.width;+ try {+ canvasElement.style.width = "320px";+ await expectContiguousRows();+ } finally {+ canvasElement.style.width = originalWidth;+ }+ },+});diff --git a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/SessionConversationTimeline.tsx b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/SessionConversationTimeline.tsxindex 3f0dfb6321..7779c20c81 100644--- a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/SessionConversationTimeline.tsx+++ b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/SessionConversationTimeline.tsx@@ -1,15 +1,12 @@import { type ComponentProps } from "react";-import { SessionVirtualizedRow } from "@/src/features/sessions/SessionVirtualizedRow";import { SessionConversationTimelineTrace } from "@/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/SessionConversationTimelineTrace";import { type SessionConversationTimelineController } from "@/src/features/sessions/hooks/useSessionConversationTimelineController";export function SessionConversationTimeline({traces,- filterMeasurementKey,controller,}: {traces: readonly ComponentProps<typeof SessionConversationTimelineTrace>[];- filterMeasurementKey: string;controller: SessionConversationTimelineController;}) {const { feedRef, virtualItems, virtualizer } = controller;@@ -18,7 +15,7 @@ export function SessionConversationTimeline({<divref={feedRef}aria-label="Session conversation timeline"- className="h-full min-h-0 overflow-y-auto scroll-smooth"+ className="h-full min-h-0 overflow-y-auto [overflow-anchor:none]"><divstyle={{@@ -32,16 +29,20 @@ export function SessionConversationTimeline({if (!traceProps) return null;return (- <SessionVirtualizedRow+ <divkey={virtualItem.key}- itemKey={String(virtualItem.key)}- measurementKey={`${String(virtualItem.key)}:${filterMeasurementKey}`}- source="modern"- virtualItem={virtualItem}- virtualizer={virtualizer}+ ref={virtualizer.measureElement}+ data-index={virtualItem.index}+ data-session-virtualizer-row="modern"+ style={{+ position: "absolute",+ top: virtualItem.start,+ left: 0,+ width: "100%",+ }}><SessionConversationTimelineTrace {...traceProps} />- </SessionVirtualizedRow>+ </div>);})}</div>diff --git a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/SessionConversationTimelineTrace.tsx b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/SessionConversationTimelineTrace.tsxindex 0e311715b6..b4a51333c8 100644--- a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/SessionConversationTimelineTrace.tsx+++ b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/SessionConversationTimelineTrace.tsx@@ -25,7 +25,6 @@ export function SessionConversationTimelineTrace({scrollTarget,itemId,threadIndex,- threadNumber,displayNumber,}: {itemId?: string;@@ -71,9 +70,6 @@ export function SessionConversationTimelineTrace({>{trace.name ?? "Trace"} · {trace.id}</span>- {threadNumber !== undefined && (- <span className="shrink-0">(Thread {threadNumber})</span>- )}</button><div className="border-border min-w-0 flex-1 border-t border-dashed" /><button@@ -100,13 +96,13 @@ export function SessionConversationTimelineTrace({</Tooltip>)}{state.type === "transcript" && state.result.cutoff && (- <Tooltip label="This transcript may be incomplete because the observation limit was reached.">+ <Tooltip label="Some messages may be missing because the observation limit was reached.">{({ getTriggerProps }) => (<button{...getTriggerProps()}type="button"className="bg-muted text-muted-foreground hover:bg-muted/80 hover:text-foreground flex h-6 w-6 shrink-0 items-center justify-center rounded-md transition-colors"- aria-label="Transcript may be incomplete"+ aria-label="Some messages may be missing"><MessageSquareOff className="icon-base" aria-hidden="true" /></button>@@ -118,7 +114,7 @@ export function SessionConversationTimelineTrace({{state.type === "loading" && (<divrole="status"- aria-label="Loading transcript"+ aria-label="Loading messages"className="flex flex-col gap-5 py-2"><div className="flex items-center gap-2 py-1">@@ -151,12 +147,12 @@ export function SessionConversationTimelineTrace({)}{state.type === "error" && (<div className="border-destructive/40 bg-destructive/5 text-foreground rounded-lg border p-4 text-xs">- Failed to load transcript.+ Failed to load messages.</div>)}{state.type === "empty" && (<div className="text-muted-foreground flex items-center justify-between gap-4 rounded-lg border border-dashed p-4 text-xs">- <span>This trace has no transcript messages.</span>+ <span>This trace has no messages.</span></div>)}{state.type === "transcript" && (diff --git a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/SessionTranscriptContent.tsx b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/SessionTranscriptContent.tsxindex 2e18b88d57..ff4f3cdc2d 100644--- a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/SessionTranscriptContent.tsx+++ b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/SessionTranscriptContent.tsx@@ -36,7 +36,7 @@ export function SessionTranscriptContent({return (<div className="ph-no-capture space-y-4">{rows.length === 0 && (- <p className="text-muted-foreground text-sm">No transcript messages.</p>+ <p className="text-muted-foreground text-sm">No messages.</p>)}{visibleThreads.filter(@@ -142,6 +142,13 @@ function SessionTranscriptRow({item: ReturnType<typeof getSessionTranscriptRows>[number];} & Omit<ComponentProps<typeof SessionTranscriptThread>, "rows">) {const { row, id } = item;+ const scrollRequestId = (+ scrollTarget?.rowId+ ? scrollTarget.rowId === id+ : scrollTarget?.observationId === row.message.observationId+ )+ ? scrollTarget?.requestId+ : undefined;const timing = row.message.timing;const isTool = row.type === "tool";const isSystem = row.message.role === "system";@@ -179,20 +186,13 @@ function SessionTranscriptRow({data-session-system-row={isSystem ? "" : undefined}data-session-observation-id={row.message.observationId ?? undefined}data-session-transcript-row-id={id}- data-scroll-request-id={- (- scrollTarget?.rowId- ? scrollTarget.rowId === id- : scrollTarget?.observationId === row.message.observationId- )- ? scrollTarget?.requestId- : undefined- }+ data-scroll-request-id={scrollRequestId}>{row.type === "tool" ? (<SessionTranscriptTool row={row} trailingContent={metadata} />) : (<SessionTranscriptMessage+ expandRequestId={scrollRequestId}message={row.message}trailingContent={isSystem ? metadata : null}onOpenObservation={onOpenObservation}@@ -272,10 +272,12 @@ function SessionTranscriptMessage({message,trailingContent,onOpenObservation,+ expandRequestId,}: {message: DisplayMessage;trailingContent: ReactNode;onOpenObservation: (observationId: string) => void;+ expandRequestId?: number;}) {if (message.role === "system") {return (@@ -288,6 +290,7 @@ function SessionTranscriptMessage({}return (<SessionTimelineContentMessage+ expandRequestId={expandRequestId}role={message.role}parts={message.parts}senderName={message.senderName}diff --git a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelineContentMessage/SessionTimelineContentMessage.stories.tsx b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelineContentMessage/SessionTimelineContentMessage.stories.tsxindex 8bbd2a40c9..8703cd05d7 100644--- a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelineContentMessage/SessionTimelineContentMessage.stories.tsx+++ b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelineContentMessage/SessionTimelineContentMessage.stories.tsx@@ -1,5 +1,5 @@import preview from "@/.storybook/preview";-import { expect, userEvent, within } from "storybook/test";+import { expect, fn, userEvent, waitFor, within } from "storybook/test";import { SessionTimelineContentMessage } from "@/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelineContentMessage/SessionTimelineContentMessage";@@ -11,7 +11,150 @@ const meta = preview.meta({export default meta;+export const AccessibleCollapsedPreview = meta.story({+ name: "(Test) Accessible Collapsed Preview",+ args: {+ role: "assistant",+ parts: [+ {+ type: "text",+ text: `[Visible link](https://example.com/preview)\n\n${"A long paragraph that makes this message taller than the preview.\n\n".repeat(80)}[Clipped link](https://example.com/end)`,+ },+ ],+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const toggle = await canvas.findByRole("button", { name: "Show more" });+ const visibleLink = canvas.getByRole("link", { name: "Visible link" });+ const preventNavigation = fn((event: Event) => event.preventDefault());+ visibleLink.addEventListener("click", preventNavigation);+ try {+ await userEvent.click(visibleLink);+ await expect(preventNavigation).toHaveBeenCalled();+ await expect(visibleLink).toHaveFocus();+ await expect(toggle).toHaveAttribute("aria-expanded", "false");+ await userEvent.tab();+ await expect(+ canvas.getByRole("link", { name: "Clipped link" }),+ ).toHaveFocus();+ await expect(+ canvas.getByRole("button", { name: "Show less" }),+ ).toHaveAttribute("aria-expanded", "true");+ } finally {+ visibleLink.removeEventListener("click", preventNavigation);+ }+ },+});++export const TallPlainText = meta.story({+ name: "(Test) Tall Plain Text",+ args: {+ role: "assistant",+ parts: [+ {+ type: "text",+ text: "A long plain text paragraph that wraps across multiple lines. ".repeat(+ 250,+ ),+ },+ ],+ onOpenObservation: () => {},+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const toggle = await canvas.findByRole("button", { name: "Show more" });+ const content = canvasElement.ownerDocument.getElementById(+ toggle.getAttribute("aria-controls") ?? "",+ );+ await expect(toggle).toHaveAttribute("aria-expanded", "false");+ await expect(content).toHaveClass("max-h-96");+ await userEvent.click(toggle);+ await expect(+ canvas.getByRole("button", { name: "Show less" }),+ ).toHaveAttribute("aria-expanded", "true");+ await expect(content).not.toHaveClass("max-h-96");+ await userEvent.click(canvas.getByRole("button", { name: "Show less" }));+ await expect(toggle).toHaveAttribute("aria-expanded", "false");+ await expect(+ canvas.getByRole("button", { name: "Open observation" }),+ ).toBeInTheDocument();+ },+});++export const TallMarkdown = meta.story({+ name: "(Test) Tall Markdown",+ args: {+ role: "assistant",+ parts: [+ {+ type: "text",+ text: "## Heading\n\nA **formatted** paragraph.\n\n".repeat(40),+ },+ ],+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const toggle = await canvas.findByRole("button", { name: "Show more" });+ const content = canvasElement.ownerDocument.getElementById(+ toggle.getAttribute("aria-controls") ?? "",+ );+ await expect(toggle).toHaveAttribute("aria-expanded", "false");+ await expect(content).toHaveClass("max-h-96");+ await userEvent.click(toggle);+ await expect(+ canvas.getAllByRole("heading", { name: "Heading" }),+ ).toHaveLength(40);+ await expect(+ canvas.getByRole("button", { name: "Show less" }),+ ).toHaveAttribute("aria-expanded", "true");+ await expect(content).not.toHaveClass("max-h-96");+ await userEvent.click(canvas.getByRole("button", { name: "Show less" }));+ await expect(toggle).toHaveAttribute("aria-expanded", "false");+ await expect(content).toHaveClass("max-h-96");+ },+});++export const ResponsiveMessage = meta.story({+ name: "(Test) Rechecks Preview Height on Resize",+ args: {+ role: "assistant",+ parts: [+ {+ type: "text",+ text: "A paragraph that wraps as the available width changes. ".repeat(+ 12,+ ),+ },+ ],+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const originalWidth = canvasElement.style.width;+ try {+ canvasElement.style.width = "800px";+ await waitFor(() =>+ expect(+ canvas.queryByRole("button", { name: "Show more" }),+ ).not.toBeInTheDocument(),+ );+ canvasElement.style.width = "200px";+ await expect(+ await canvas.findByRole("button", { name: "Show more" }),+ ).toHaveAttribute("aria-expanded", "false");+ canvasElement.style.width = "800px";+ await waitFor(() =>+ expect(+ canvas.queryByRole("button", { name: "Show more" }),+ ).not.toBeInTheDocument(),+ );+ } finally {+ canvasElement.style.width = originalWidth;+ }+ },+});+export const NamedUser = meta.story({+ name: "(Test) Named User",args: {role: "user",senderName: "Customer",@@ -22,6 +165,12 @@ export const NamedUser = meta.story({},],},+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ await expect(+ canvas.queryByRole("button", { name: "Show more" }),+ ).not.toBeInTheDocument();+ },});export const Tool = meta.story({diff --git a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelineContentMessage/SessionTimelineContentMessage.tsx b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelineContentMessage/SessionTimelineContentMessage.tsxindex cf00cba196..0240259dc3 100644--- a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelineContentMessage/SessionTimelineContentMessage.tsx+++ b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelineContentMessage/SessionTimelineContentMessage.tsx@@ -6,6 +6,7 @@ import {} from "@langfuse/shared/src/utils/normalized-io";import { SessionTimelinePart } from "@/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelinePart/SessionTimelinePart";import { cn } from "@/src/utils/tailwind";+import { SessionTimelineMessageContent } from "./components/SessionTimelineMessageContent/SessionTimelineMessageContent";const rolePresentation = {user: {@@ -13,7 +14,7 @@ const rolePresentation = {icon: UserRound,wrapper: "justify-end",container:- "bg-blue-50 dark:bg-[color-mix(in_srgb,var(--color-muted)_85%,var(--color-light-blue))] max-w-[min(85%,48rem)] rounded-2xl px-4 py-2.5",+ "bg-blue-50 dark:bg-[color-mix(in_srgb,var(--color-muted)_85%,var(--color-light-blue))] max-w-[min(85%,48rem)] rounded-2xl px-4 py-2.5 [--session-message-toggle-hover:var(--color-blue-100)] dark:[--session-message-toggle-hover:color-mix(in_srgb,var(--color-muted)_75%,var(--color-light-blue))]",},assistant: {label: "Assistant",@@ -43,12 +44,14 @@ export function SessionTimelineContentMessage({senderName,timestamp,onOpenObservation,+ expandRequestId,}: {role: Exclude<NormalizedMessage["role"], "system">;parts: NormalizedMessage["parts"];senderName: NormalizedMessage["senderName"];timestamp?: Date | null;onOpenObservation?: () => void;+ expandRequestId?: number;}) {const presentation = rolePresentation[role];const Icon = presentation.icon;@@ -92,7 +95,7 @@ export function SessionTimelineContentMessage({return (<divkey={`reasoning-${groupIndex}`}- className="flex w-full flex-col gap-1"+ className="group/bubble flex w-full flex-col gap-1">{group.parts.map((part, partIndex) => (<SessionTimelinePart@@ -100,6 +103,15 @@ export function SessionTimelineContentMessage({part={part}/>))}+ {onOpenObservation && groupIndex === groups.length - 1 && (+ <button+ type="button"+ className="text-muted-foreground hover:text-foreground invisible w-fit font-mono text-[10px] group-focus-within/bubble:visible group-hover/bubble:visible hover:underline"+ onClick={onOpenObservation}+ >+ Open generation+ </button>+ )}</div>);}@@ -160,19 +172,23 @@ export function SessionTimelineContentMessage({</button>) : null}{!isJsonOnly || isJsonExpanded ? (- <div- className={cn(- "flex flex-col gap-2 text-sm",- isJsonOnly && "mt-2",- )}+ <SessionTimelineMessageContent+ expandRequestId={expandRequestId}>- {group.parts.map((part, partIndex) => (- <SessionTimelinePart- key={`${part.type}-${partIndex}`}- part={part}- />- ))}- </div>+ <div+ className={cn(+ "flex flex-col gap-2 text-sm",+ isJsonOnly && "mt-2",+ )}+ >+ {group.parts.map((part, partIndex) => (+ <SessionTimelinePart+ key={`${part.type}-${partIndex}`}+ part={part}+ />+ ))}+ </div>+ </SessionTimelineMessageContent>) : null}{(timestamp || onOpenObservation) &&groupIndex === groups.length - 1 && (diff --git a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelineContentMessage/components/SessionTimelineMessageContent/SessionTimelineMessageContent.tsx b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelineContentMessage/components/SessionTimelineMessageContent/SessionTimelineMessageContent.tsxnew file mode 100644index 0000000000..c2ab2ec9fb--- /dev/null+++ b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelineContentMessage/components/SessionTimelineMessageContent/SessionTimelineMessageContent.tsx@@ -0,0 +1,84 @@+import { useCallback, useId, useRef, useState, type ReactNode } from "react";+import { useResizeObserver } from "@/src/hooks/useResizeObserver";+import { cn } from "@/src/utils/tailwind";++const MESSAGE_PREVIEW_HEIGHT = 384;++export function SessionTimelineMessageContent({+ children,+ expandRequestId,+}: {+ children: ReactNode;+ expandRequestId?: number;+}) {+ const contentRef = useRef<HTMLDivElement>(null);+ const contentId = useId();+ const [exceedsPreviewHeight, setExceedsPreviewHeight] = useState(false);+ const [expansion, setExpansion] = useState<{+ isExpanded: boolean;+ requestId: number | undefined;+ }>({ isExpanded: false, requestId: undefined });+ const isExpanded =+ expansion.isExpanded ||+ (expandRequestId !== undefined && expansion.requestId !== expandRequestId);+ const measureContent = useCallback(() => {+ setExceedsPreviewHeight(+ (contentRef.current?.getBoundingClientRect().height ?? 0) >+ MESSAGE_PREVIEW_HEIGHT,+ );+ }, []);+ useResizeObserver(contentRef, measureContent);++ return (+ <div className="min-w-0">+ <div+ id={contentId}+ className={cn(+ exceedsPreviewHeight && !isExpanded && "max-h-96 overflow-hidden",+ )}+ onFocusCapture={(event) => {+ if (!exceedsPreviewHeight || isExpanded) return;+ const previewBounds = event.currentTarget.getBoundingClientRect();+ const targetBounds = event.target.getBoundingClientRect();+ if (+ targetBounds.bottom > previewBounds.bottom ||+ event.currentTarget.scrollTop > 0+ ) {+ setExpansion({ isExpanded: true, requestId: expandRequestId });+ }+ }}+ >+ <div+ ref={contentRef}+ className={cn(+ exceedsPreviewHeight &&+ !isExpanded &&+ "[mask-image:linear-gradient(to_bottom,black_21rem,transparent_24rem)] [mask-size:100%_24rem] [mask-repeat:no-repeat]",+ )}+ >+ {children}+ </div>+ </div>+ {exceedsPreviewHeight && (+ <div className="mt-2 flex items-center gap-3">+ <div className="bg-border h-px flex-1" aria-hidden="true" />+ <button+ type="button"+ className="text-muted-foreground hover:text-foreground shrink-0 rounded-md px-3 py-1 text-xs transition-colors hover:bg-[var(--session-message-toggle-hover,var(--color-muted))]"+ aria-expanded={isExpanded}+ aria-controls={contentId}+ onClick={() =>+ setExpansion({+ isExpanded: !isExpanded,+ requestId: expandRequestId,+ })+ }+ >+ {isExpanded ? "Show less" : "Show more"}+ </button>+ <div className="bg-border h-px flex-1" aria-hidden="true" />+ </div>+ )}+ </div>+ );+}diff --git a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelinePart/SessionTimelinePart.tsx b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelinePart/SessionTimelinePart.tsxindex a05c7cf5ab..a3633f50c5 100644--- a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelinePart/SessionTimelinePart.tsx+++ b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelinePart/SessionTimelinePart.tsx@@ -33,7 +33,6 @@ function SessionTimelineReasoning({ part }: { part: ReasoningPart }) {><MarkdownViewmarkdown={decodeUnicodeEscapesOnly(content.text, true)}- fallbackDisplay="collapsed"className="px-0 py-0"/></SessionTimelineCollapsiblePart>@@ -132,7 +131,6 @@ export function SessionTimelinePart({<div data-session-search-content><MarkdownViewmarkdown={decodeUnicodeEscapesOnly(part.text, true)}- fallbackDisplay="collapsed"className="px-0 py-0"/></div>diff --git a/web/src/features/sessions/hooks/useSessionConversationTimelineController.clienttest.tsx b/web/src/features/sessions/hooks/useSessionConversationTimelineController.clienttest.tsxindex 824895588a..e244310049 100644--- a/web/src/features/sessions/hooks/useSessionConversationTimelineController.clienttest.tsx+++ b/web/src/features/sessions/hooks/useSessionConversationTimelineController.clienttest.tsx@@ -313,7 +313,7 @@ describe("useSessionConversationTimelineController", () => {act(() => result.current.onSelect(0, "generation", "0:1"));expect(feed.scrollTo).toHaveBeenCalledWith({top: 250,- behavior: "smooth",+ behavior: "auto",});});@@ -413,7 +413,7 @@ describe("useSessionConversationTimelineController", () => {expect(result.current.activeItemId).toBe("trace:2");expect(feed.scrollTo).toHaveBeenCalledWith({top: 0,- behavior: "smooth",+ behavior: "auto",});});it("scrolls to the exact row when multiple rows share an observation", () => {@@ -439,7 +439,7 @@ describe("useSessionConversationTimelineController", () => {expect(result.current.activeItemId).toBe("trace");expect(feed.scrollTo).toHaveBeenCalledWith({top: 100,- behavior: "smooth",+ behavior: "auto",});});@@ -451,7 +451,7 @@ describe("useSessionConversationTimelineController", () => {useSessionConversationTimelineController([{ trace }]),);act(() => result.current.onSelect(0, "generation", "0:1"));- expect(feed.scrollTo).toHaveBeenCalledWith({ top: 0, behavior: "smooth" });+ expect(feed.scrollTo).toHaveBeenCalledWith({ top: 0, behavior: "auto" });vi.mocked(feed.scrollTo).mockClear();const traceElement = document.createElement("div");diff --git a/web/src/features/sessions/hooks/useSessionConversationTimelineController.ts b/web/src/features/sessions/hooks/useSessionConversationTimelineController.tsindex 074b739362..aa18b0ad40 100644--- a/web/src/features/sessions/hooks/useSessionConversationTimelineController.ts+++ b/web/src/features/sessions/hooks/useSessionConversationTimelineController.ts@@ -184,13 +184,6 @@ export function useSessionConversationTimelineController(): undefined;const mountedTarget = rowId || observationId ? row : entry;- row- ?.querySelectorAll<HTMLDetailsElement>(- "details[data-markdown-fallback]",- )- .forEach((fallback) => {- fallback.open = true;- });const measurements = virtualizer.measurementsCache;const itemOffset = measurements[currentIndex]?.start;if (itemOffset === undefined) {@@ -215,7 +208,7 @@ export function useSessionConversationTimelineController(if (previousTarget === undefined || Math.abs(previousTarget - top) > 1) {previousTarget = top;stableSince = performance.now();- feed.scrollTo({ top, behavior: "smooth" });+ feed.scrollTo({ top, behavior: "auto" });}if (virtualizer.isScrolling ||diff --git a/web/src/features/sessions/hooks/useSessionTraceTranscripts.clienttest.tsx b/web/src/features/sessions/hooks/useSessionTraceTranscripts.clienttest.tsxindex e78477f76d..f4ed15cf2b 100644--- a/web/src/features/sessions/hooks/useSessionTraceTranscripts.clienttest.tsx+++ b/web/src/features/sessions/hooks/useSessionTraceTranscripts.clienttest.tsx@@ -76,6 +76,9 @@ it("bounds concurrent requests and releases slots after success and failure", asexpect(query.mock.calls.every(([input]) => input.pairTextToolResponses === true),).toBe(true);+ expect(+ query.mock.calls.every(([input]) => input.fallbackToRootIO === true),+ ).toBe(true);expect(result.current.get("trace-4")).toEqual({ state: "loading" });expect(result.current.has("trace-6")).toBe(false);diff --git a/web/src/features/sessions/hooks/useSessionTraceTranscripts.ts b/web/src/features/sessions/hooks/useSessionTraceTranscripts.tsindex 5f67026042..210562e069 100644--- a/web/src/features/sessions/hooks/useSessionTraceTranscripts.ts+++ b/web/src/features/sessions/hooks/useSessionTraceTranscripts.ts@@ -31,6 +31,7 @@ export function useSessionTraceTranscripts({traceId: trace.id,timestamp: trace.timestamp,pairTextToolResponses: true,+ fallbackToRootIO: true,};return {queryKey: getQueryKey(api.events.transcriptByTraceId, input, "query"),