Skip to content

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

fix(sessions): Improve handling of reasoning (#18527)

Ben Bachem2cc5e6b936c4
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.tsx
index bb69361f5c..e0efabeae5 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
@@ -2482,6 +2482,195 @@ const meta = preview.meta({
});
export default meta;
+export const ReasoningOnlyAndEmptySidebarStates = meta.story({
+ name: "(Test) Reasoning-Only And Empty Sidebar States",
+ args: {
+ transcriptTraces: [
+ {
+ ...traces[0]!,
+ state: {
+ type: "transcript",
+ result: {
+ state: "loaded",
+ cutoff: false,
+ transcript: {
+ threads: [
+ {
+ conversationHistory: [],
+ currentTurn: {
+ nestingLevel: 0,
+ observations: [],
+ messages: [
+ {
+ observationId: "reasoning-only",
+ traceId: "trace-1",
+ startTime: new Date("2026-09-24T12:00:00Z"),
+ endTime: null,
+ role: "assistant",
+ source: "output",
+ parts: [
+ {
+ type: "reasoning",
+ content: {
+ kind: "text",
+ text: "Only reasoning in this trace",
+ },
+ },
+ {
+ type: "reasoning",
+ content: {
+ kind: "encrypted",
+ data: "encrypted-payload",
+ },
+ },
+ ],
+ },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ },
+ },
+ {
+ ...traces[1]!,
+ state: { type: "empty" },
+ },
+ ],
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const sidebar = within(canvas.getByRole("complementary"));
+ const timeline = within(
+ canvas.getByLabelText("Session conversation timeline"),
+ );
+ await expect(await sidebar.findByText("Reasoning only")).toBeVisible();
+ await expect(sidebar.getAllByText("No messages or tools")).toHaveLength(1);
+ await expect(
+ sidebar.queryByRole("button", { name: "Assistant message" }),
+ ).not.toBeInTheDocument();
+ await expect(timeline.getByText("Encrypted reasoning")).toBeInTheDocument();
+ await userEvent.click(timeline.getByRole("button", { name: "Reasoning" }));
+ await expect(
+ timeline.getByText("Only reasoning in this trace"),
+ ).toBeVisible();
+ await userEvent.type(
+ sidebar.getByRole("textbox", { name: "Search session" }),
+ "missing-message",
+ );
+ await waitFor(() =>
+ expect(sidebar.queryByText("Reasoning only")).not.toBeInTheDocument(),
+ );
+ },
+});
+
+export const OmitReasoningOnlySidebarMessages = meta.story({
+ name: "(Test) Omit Reasoning-Only Sidebar Messages",
+ args: {
+ transcriptTraces: [
+ {
+ ...traces[0]!,
+ state: {
+ type: "transcript",
+ result: {
+ state: "loaded",
+ cutoff: false,
+ transcript: {
+ threads: [
+ {
+ conversationHistory: [],
+ currentTurn: {
+ nestingLevel: 0,
+ observations: [],
+ messages: [
+ {
+ observationId: "reasoning-only",
+ traceId: "trace-1",
+ startTime: new Date("2026-09-24T12:00:00Z"),
+ endTime: null,
+ role: "assistant",
+ source: "output",
+ parts: [
+ {
+ type: "reasoning",
+ content: {
+ kind: "text",
+ text: "Reasoning without an answer",
+ },
+ },
+ ],
+ },
+ {
+ observationId: "encrypted-reasoning-only",
+ traceId: "trace-1",
+ startTime: new Date("2026-09-24T12:00:01Z"),
+ endTime: null,
+ role: "assistant",
+ source: "output",
+ parts: [
+ {
+ type: "reasoning",
+ content: {
+ kind: "encrypted",
+ data: "encrypted-payload",
+ },
+ },
+ ],
+ },
+ {
+ observationId: "reasoning-with-answer",
+ traceId: "trace-1",
+ startTime: new Date("2026-09-24T12:00:02Z"),
+ endTime: null,
+ role: "assistant",
+ source: "output",
+ parts: [
+ {
+ type: "reasoning",
+ content: {
+ kind: "text",
+ text: "Reasoning with an answer",
+ },
+ },
+ { type: "text", text: "The visible answer" },
+ ],
+ },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ },
+ },
+ ],
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const sidebar = within(canvas.getByRole("complementary"));
+ const timeline = within(
+ canvas.getByLabelText("Session conversation timeline"),
+ );
+ await sidebar.findByRole("button", { name: "Assistant message" });
+ await expect(
+ sidebar.getAllByRole("button", { name: "Assistant message" }),
+ ).toHaveLength(1);
+ await expect(timeline.getByText("Encrypted reasoning")).toBeInTheDocument();
+ const reasoningButtons = timeline.getAllByRole("button", {
+ name: "Reasoning",
+ });
+ await expect(reasoningButtons).toHaveLength(2);
+ await userEvent.click(reasoningButtons[0]!);
+ await expect(
+ timeline.getByText("Reasoning without an answer"),
+ ).toBeVisible();
+ await userEvent.click(reasoningButtons[1]!);
+ await expect(timeline.getByText("Reasoning with an answer")).toBeVisible();
+ await expect(timeline.getByText("The visible answer")).toBeVisible();
+ },
+});
+
export const ManualScrollSynchronization = meta.story({
name: "(Test) Manual Scroll Synchronization",
args: {
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.tsx
index 35b0f660fb..2b717ab2ae 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
@@ -127,6 +127,7 @@ export function SessionConversationalView(
});
if (props.state === "loaded" && !props.isSearchPending) {
for (const [itemIndex, item] of timelineItems.entries()) {
+ let emptyTranscriptReason: "reasoning-only" | undefined;
const transcriptRows = (() => {
if (item.state.type === "error") return null;
if (item.state.type === "loading") return undefined;
@@ -134,9 +135,17 @@ export function SessionConversationalView(
let toolGroupId: string | undefined;
return getSessionTranscriptRows(item.state.result.transcript)
.filter((row) => row.threadIndex === item.threadIndex)
- .map(({ id, threadIndex, row }) => {
+ .flatMap(({ id, threadIndex, row }) => {
if (row.type !== "tool") toolGroupId = undefined;
else if (toolGroupId === undefined) toolGroupId = id;
+ if (
+ row.type !== "tool" &&
+ row.message.parts.length > 0 &&
+ row.message.parts.every((part) => part.type === "reasoning")
+ ) {
+ emptyTranscriptReason = "reasoning-only";
+ return [];
+ }
const label =
row.type === "tool"
? (row.call?.toolName ?? row.result?.toolName ?? "Tool")
@@ -150,17 +159,20 @@ export function SessionConversationalView(
.join(" ") ||
row.message.senderName ||
row.message.role;
- return {
- id,
- threadIndex,
- toolGroupId:
- row.type === "tool"
- ? `${id.split(":")[0]}:${toolGroupId}`
- : undefined,
- observationId: row.message.observationId,
- label,
- role: row.type === "tool" ? ("tool" as const) : row.message.role,
- };
+ return [
+ {
+ id,
+ threadIndex,
+ toolGroupId:
+ row.type === "tool"
+ ? `${id.split(":")[0]}:${toolGroupId}`
+ : undefined,
+ observationId: row.message.observationId,
+ label,
+ role:
+ row.type === "tool" ? ("tool" as const) : row.message.role,
+ },
+ ];
});
})();
const matchingRows =
@@ -191,6 +203,8 @@ export function SessionConversationalView(
item.trace,
),
transcriptRows: matchingRows,
+ emptyTranscriptReason:
+ transcriptRows?.length === 0 ? emptyTranscriptReason : undefined,
threadCount: threadVisibility?.visibleThreads.length,
hiddenThreadCount: threadVisibility?.hiddenThreadCount,
});
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.tsx
index 22f5056609..d194aa4d59 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
@@ -27,6 +27,7 @@ export type SessionConversationSidebarTrace = {
idleGapSeconds: number | null;
threadCount?: number;
hiddenThreadCount?: number;
+ emptyTranscriptReason?: "reasoning-only";
transcriptRows:
| Array<{
id: string;
@@ -349,6 +350,12 @@ export function SessionConversationSidebar(
const showThreadHeaders =
!sidebarTrace.itemId &&
(sidebarTrace.threadCount ?? threads.size) > 1;
+ const emptyTranscriptLabel = (() => {
+ if (props.search.trim()) return "No matching messages or tools";
+ if (sidebarTrace.emptyTranscriptReason === "reasoning-only")
+ return "Reasoning only";
+ return "No messages or tools";
+ })();
return (
<div
key={item.key}
@@ -429,9 +436,7 @@ export function SessionConversationSidebar(
)}
{transcriptRows?.length === 0 && (
<p className="text-muted-foreground px-1 py-2 text-xs">
- {props.search.trim()
- ? "No matching messages or tools"
- : "No messages or tools"}
+ {emptyTranscriptLabel}
</p>
)}
<div className="flex flex-col">
diff --git a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelineCollapsibleRow/SessionTimelineCollapsibleRow.tsx b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelineCollapsibleRow/SessionTimelineCollapsibleRow.tsx
index 48712520c5..f99786e9f6 100644
--- a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelineCollapsibleRow/SessionTimelineCollapsibleRow.tsx
+++ b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelineCollapsibleRow/SessionTimelineCollapsibleRow.tsx
@@ -20,13 +20,17 @@ export function SessionTimelineCollapsibleRow({
labelTitle?: string;
searchableLabel?: boolean;
icon?: ReactNode;
- isExpanded: boolean;
- onExpandedChange: (isExpanded: boolean) => void;
onOpenObservation?: () => void;
trailingContent?: ReactNode;
showHoverDivider?: boolean;
- children: ReactNode;
-}) {
+ children?: ReactNode;
+} & (
+ | {
+ isExpanded: boolean;
+ onExpandedChange: (isExpanded: boolean) => void;
+ }
+ | { isExpanded?: never; onExpandedChange?: never }
+)) {
return (
<section
className={cn(
@@ -39,41 +43,54 @@ export function SessionTimelineCollapsibleRow({
className="group/collapsible-row flex w-full min-w-0 items-center gap-0.5"
data-expanded={isExpanded}
>
- <button
- type="button"
- onClick={onOpenObservation ?? (() => onExpandedChange(!isExpanded))}
- className="flex min-w-0 items-center gap-2 rounded-sm text-left focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none"
- aria-expanded={onOpenObservation ? undefined : isExpanded}
- aria-label={labelActionName}
- >
- {icon && (
- <span className="bg-background relative z-[1] flex shrink-0 rounded-full">
- {icon}
+ {onExpandedChange || onOpenObservation ? (
+ <button
+ type="button"
+ onClick={
+ onOpenObservation ?? (() => onExpandedChange?.(!isExpanded))
+ }
+ className="flex min-w-0 items-center gap-2 rounded-sm text-left focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none"
+ aria-expanded={onOpenObservation ? undefined : isExpanded}
+ aria-label={labelActionName}
+ >
+ {icon && (
+ <span className="bg-background relative z-[1] flex shrink-0 rounded-full">
+ {icon}
+ </span>
+ )}
+ <span
+ className="min-w-0 truncate text-xs font-normal hover:underline"
+ title={labelTitle ?? label}
+ data-session-search-content={searchableLabel || undefined}
+ >
+ {label}
</span>
- )}
+ </button>
+ ) : (
<span
- className="min-w-0 truncate text-xs font-normal hover:underline"
+ className="text-muted-foreground min-w-0 truncate text-xs"
title={labelTitle ?? label}
- data-session-search-content={searchableLabel || undefined}
>
{label}
</span>
- </button>
- <button
- type="button"
- className="text-muted-foreground hover:text-foreground shrink-0 rounded-sm p-0.5 transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none"
- aria-expanded={isExpanded}
- aria-label={`${isExpanded ? "Collapse" : "Expand"} ${label}`}
- onClick={() => onExpandedChange(!isExpanded)}
- >
- <ChevronDown
- className={cn(
- "icon-base transition-transform",
- !isExpanded && "-rotate-90",
- )}
- aria-hidden="true"
- />
- </button>
+ )}
+ {onExpandedChange && (
+ <button
+ type="button"
+ className="text-muted-foreground hover:text-foreground shrink-0 rounded-sm p-0.5 transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none"
+ aria-expanded={isExpanded}
+ aria-label={`${isExpanded ? "Collapse" : "Expand"} ${label}`}
+ onClick={() => onExpandedChange(!isExpanded)}
+ >
+ <ChevronDown
+ className={cn(
+ "icon-base transition-transform",
+ !isExpanded && "-rotate-90",
+ )}
+ aria-hidden="true"
+ />
+ </button>
+ )}
<div
className={cn(
"mx-3 min-w-0 flex-1",
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.tsx
index 8703cd05d7..522dfd0efa 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
@@ -11,6 +11,58 @@ const meta = preview.meta({
export default meta;
+export const ReasoningActions = meta.story({
+ name: "(Test) Reasoning Actions At Every Position",
+ args: {
+ role: "assistant",
+ onOpenObservation: fn(),
+ parts: [
+ { type: "reasoning", content: { kind: "text", text: "Before content" } },
+ {
+ type: "reasoning",
+ content: { kind: "encrypted", data: "encrypted-before" },
+ },
+ { type: "text", text: "The answer" },
+ { type: "reasoning", content: { kind: "text", text: "After content" } },
+ {
+ type: "reasoning",
+ content: { kind: "encrypted", data: "encrypted-after" },
+ },
+ ],
+ },
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const rows = canvasElement.querySelectorAll("section");
+ await expect(rows).toHaveLength(4);
+ for (const row of rows) {
+ const header = row.firstElementChild!;
+ const action = within(row).getByText("Open generation", {
+ selector: "button",
+ });
+ const divider = header.querySelector(
+ '[aria-hidden="true"].border-dashed',
+ )!;
+ await expect(divider).toBeInTheDocument();
+ await expect(action).toHaveClass("group-hover/collapsible-row:visible");
+ const trigger = within(row).queryByRole("button", { name: "Reasoning" });
+ if (trigger) {
+ await userEvent.click(trigger);
+ await expect(trigger).toHaveFocus();
+ await expect(trigger).toHaveAttribute("aria-expanded", "true");
+ await expect(action).toBeVisible();
+ await expect(divider).toBeVisible();
+ }
+ await userEvent.click(action);
+ }
+ await expect(args.onOpenObservation).toHaveBeenCalledTimes(4);
+ await expect(
+ canvas.queryByRole("button", { name: "Expand Encrypted reasoning" }),
+ ).not.toBeInTheDocument();
+ await expect(canvas.getByText("Before content")).toBeVisible();
+ await expect(canvas.getByText("After content")).toBeVisible();
+ },
+});
+
export const AccessibleCollapsedPreview = meta.story({
name: "(Test) Accessible Collapsed Preview",
args: {
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.tsx
index 0240259dc3..76a70d7a89 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
@@ -95,23 +95,25 @@ export function SessionTimelineContentMessage({
return (
<div
key={`reasoning-${groupIndex}`}
- className="group/bubble flex w-full flex-col gap-1"
+ className="flex w-full flex-col gap-1"
>
{group.parts.map((part, partIndex) => (
<SessionTimelinePart
key={`${part.content.kind}-${partIndex}`}
part={part}
+ trailingContent={
+ onOpenObservation && (
+ <button
+ type="button"
+ className="text-muted-foreground hover:text-foreground invisible shrink-0 font-mono text-xs group-focus-within/collapsible-row:visible group-hover/collapsible-row:visible hover:underline"
+ onClick={onOpenObservation}
+ >
+ Open generation
+ </button>
+ )
+ }
/>
))}
- {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>
);
}
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.tsx
index a3633f50c5..f053d6b47e 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
@@ -1,5 +1,7 @@
/* eslint-disable no-nested-ternary */
import { FileIcon, Wrench } from "lucide-react";
+import { useState, type ReactNode } from "react";
+import { SessionTimelineCollapsibleRow } from "../SessionTimelineCollapsibleRow/SessionTimelineCollapsibleRow";
import { assertUnreachable } from "@langfuse/shared";
import {
type FilePart,
@@ -13,55 +15,66 @@ import { PrettyJsonView } from "@/src/components/ui/PrettyJsonView";
import { getSafeImageUrl, getSafeLinkUrl } from "@/src/components/ui/safe-url";
import { decodeUnicodeEscapesOnly } from "@/src/utils/unicode";
-function SessionTimelineReasoning({ part }: { part: ReasoningPart }) {
+function SessionTimelineReasoning({
+ part,
+ trailingContent,
+}: {
+ part: ReasoningPart;
+ trailingContent?: ReactNode;
+}) {
+ const [isExpanded, setIsExpanded] = useState(false);
const content = part.content;
if (content.kind === "encrypted") {
return (
- <span className="text-muted-foreground py-1 font-mono text-xs">
- Encrypted reasoning
- </span>
+ <SessionTimelineCollapsibleRow
+ label="Encrypted reasoning"
+ trailingContent={trailingContent}
+ />
);
}
if (content.kind === "text") {
return (
- <SessionTimelineCollapsiblePart
+ <SessionTimelineCollapsibleRow
label="Reasoning"
- variant="plain"
- alignment="row"
+ isExpanded={isExpanded}
+ onExpandedChange={setIsExpanded}
+ trailingContent={trailingContent}
>
<MarkdownView
markdown={decodeUnicodeEscapesOnly(content.text, true)}
className="px-0 py-0"
/>
- </SessionTimelineCollapsiblePart>
+ </SessionTimelineCollapsibleRow>
);
}
if (content.kind === "data") {
return (
- <SessionTimelineCollapsiblePart
+ <SessionTimelineCollapsibleRow
label="Reasoning data"
- variant="plain"
- alignment="row"
+ isExpanded={isExpanded}
+ onExpandedChange={setIsExpanded}
+ trailingContent={trailingContent}
>
<PrettyJsonView json={content.value} currentView="pretty" />
- </SessionTimelineCollapsiblePart>
+ </SessionTimelineCollapsibleRow>
);
}
if (content.kind === "redacted") {
return (
- <SessionTimelineCollapsiblePart
+ <SessionTimelineCollapsibleRow
label="Redacted reasoning"
- variant="plain"
- alignment="row"
+ isExpanded={isExpanded}
+ onExpandedChange={setIsExpanded}
+ trailingContent={trailingContent}
>
<pre className="text-muted-foreground overflow-hidden font-mono text-xs break-all whitespace-pre-wrap">
{content.data}
</pre>
- </SessionTimelineCollapsiblePart>
+ </SessionTimelineCollapsibleRow>
);
}
@@ -119,8 +132,10 @@ function SessionTimelineFile({ part }: { part: FilePart }) {
export function SessionTimelinePart({
part,
+ trailingContent,
}: {
part: NormalizedMessage["parts"][number];
+ trailingContent?: ReactNode;
}) {
if (part.type === "text") {
return (
@@ -139,7 +154,9 @@ export function SessionTimelinePart({
}
if (part.type === "reasoning") {
- return <SessionTimelineReasoning part={part} />;
+ return (
+ <SessionTimelineReasoning part={part} trailingContent={trailingContent} />
+ );
}
if (part.type === "file") {