🪢 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): Don't allow expanding empty reasoning messages (#19096)
Ben Bachemc431d9a4300b
diff --git a/web/src/components/ui/PrettyJsonView.tsx b/web/src/components/ui/PrettyJsonView.tsxindex 02a36ca43a..a3444db578 100644--- a/web/src/components/ui/PrettyJsonView.tsx+++ b/web/src/components/ui/PrettyJsonView.tsx@@ -495,6 +495,8 @@ function JsonPrettyTable({<Buttonvariant="ghost"size="sm"+ aria-label={`${row.getIsExpanded() ? "Collapse" : "Expand"} ${row.original.key}`}+ aria-expanded={row.getIsExpanded()}onClick={(e) => {e.stopPropagation();handleRowExpansion(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 92b6299cc0..94dd065504 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@@ -12,6 +12,61 @@ const meta = preview.meta({export default meta;+export const ReasoningVariants = meta.story({+ name: "(Test) Reasoning Variants",+ args: {+ role: "assistant",+ parts: [+ { type: "reasoning", content: { kind: "text", text: "" } },+ { type: "reasoning", content: { kind: "text", text: " \n\t " } },+ { type: "reasoning", content: { kind: "redacted", data: "" } },+ { type: "reasoning", content: { kind: "redacted", data: " \n\t " } },+ {+ type: "reasoning",+ content: { kind: "encrypted", data: "opaque-payload" },+ },+ {+ type: "reasoning",+ content: { kind: "text", text: "Readable reasoning" },+ },+ {+ type: "reasoning",+ content: { kind: "redacted", data: "Redacted payload" },+ },+ {+ type: "reasoning",+ content: {+ kind: "data",+ value: { checks: ["source available", "answer supported"] },+ },+ },+ { type: "text", text: "Here is the result." },+ ],+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ await expect(canvas.getAllByText("Reasoning")).toHaveLength(3);+ await expect(canvas.getAllByText("Redacted reasoning")).toHaveLength(3);+ await expect(canvas.getByText("Encrypted reasoning")).toBeVisible();++ const expandButtons = canvas.getAllByRole("button", { name: /^Expand / });+ await expect(expandButtons).toHaveLength(3);+ for (const button of expandButtons) {+ await expect(button).toHaveAttribute("aria-expanded", "false");+ await userEvent.click(button);+ await expect(button).toHaveAttribute("aria-expanded", "true");+ }+ await expect(canvas.getByText("Readable reasoning")).toBeVisible();+ await expect(canvas.getByText("Redacted payload")).toBeVisible();+ await expect(canvas.getByText("Reasoning data")).toBeVisible();+ await expect(+ canvas.getByRole("button", { name: /^(Expand|Collapse) checks$/ }),+ ).toBeVisible();+ await expect(canvasElement).toHaveTextContent("source available");+ await expect(canvasElement).toHaveTextContent("answer supported");+ },+});+export const ReasoningActions = meta.story({name: "(Test) Reasoning Actions At Every Position",args: {@@ -283,48 +338,6 @@ export const MixedTextAndData = meta.story({},});-export const ReasoningData = meta.story({- args: {- role: "assistant",- parts: [- {- type: "reasoning",- content: {- kind: "data",- value: { checks: ["source available", "answer supported"] },- },- },- { type: "text", text: "The answer is supported by the source." },- ],- },-});--export const RedactedReasoning = meta.story({- args: {- role: "assistant",- parts: [- {- type: "reasoning",- content: { kind: "redacted", data: "redacted-provider-payload" },- },- { type: "text", text: "Here is the result." },- ],- },-});--export const EncryptedReasoning = meta.story({- args: {- role: "assistant",- parts: [- {- type: "reasoning",- content: { kind: "encrypted", data: "encrypted-provider-payload" },- },- { type: "text", text: "Here is the result." },- ],- },-});-export const EmbeddedImages = meta.story({args: {role: "user",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 b62d5e1718..f8d7368c2e 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@@ -126,6 +126,15 @@ function SessionTimelineReasoning({}if (content.kind === "text") {+ if (content.text.trim().length === 0) {+ return (+ <SessionTimelineCollapsibleRow+ label="Reasoning"+ trailingContent={trailingContent}+ />+ );+ }+return (<SessionTimelineCollapsibleRowlabel="Reasoning"@@ -155,6 +164,15 @@ function SessionTimelineReasoning({}if (content.kind === "redacted") {+ if (content.data.trim().length === 0) {+ return (+ <SessionTimelineCollapsibleRow+ label="Redacted reasoning"+ trailingContent={trailingContent}+ />+ );+ }+return (<SessionTimelineCollapsibleRowlabel="Redacted reasoning"