Skip to content

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

fix(sessions): Surface tool status messages (#18537)

Ben Bachem8e467b738bd0
diff --git a/web/src/__tests__/server/unit/loadTraceTranscript.servertest.ts b/web/src/__tests__/server/unit/loadTraceTranscript.servertest.ts
index 0e65bd49b5..8e4a70ab68 100644
--- a/web/src/__tests__/server/unit/loadTraceTranscript.servertest.ts
+++ b/web/src/__tests__/server/unit/loadTraceTranscript.servertest.ts
@@ -119,6 +119,132 @@ beforeEach(() => {
mocks.splitTurn.mockReset().mockImplementation(mocks.splitTurnActual);
});
+it("retains the source tool observation status on transcript messages", async () => {
+ const transcript = fixture(["search"], ["search"]);
+ mocks.observations.mockResolvedValue({
+ observations: [
+ {
+ id: "generation",
+ type: "GENERATION",
+ level: "DEFAULT",
+ statusMessage: null,
+ traceId: "trace",
+ },
+ {
+ id: "tool-0",
+ type: "TOOL",
+ level: "ERROR",
+ statusMessage: "Search timed out",
+ traceId: "trace",
+ },
+ ],
+ totalCount: 2,
+ });
+
+ const result = await loadTraceTranscript(trace);
+
+ expect(result.transcript?.threads[0]?.currentTurn.messages[1]).toMatchObject({
+ observationId: "tool-0",
+ level: "ERROR",
+ statusMessage: "Search timed out",
+ });
+ expect(transcript.threads[0]?.currentTurn.messages[1]).not.toHaveProperty(
+ "level",
+ );
+});
+
+it("does not copy generation errors onto unmatched tool calls", async () => {
+ const transcript = fixture(["search"], []);
+ mocks.observations.mockResolvedValue({
+ observations: [
+ {
+ id: "generation",
+ traceId: "trace",
+ type: "GENERATION",
+ level: "ERROR",
+ statusMessage: "Generation failed",
+ },
+ ],
+ totalCount: 1,
+ });
+ const result = await loadTraceTranscript(trace);
+ expect(result.transcript).toBe(transcript);
+ expect(
+ result.transcript?.threads[0]?.currentTurn.messages[0],
+ ).not.toHaveProperty("level");
+});
+
+it.each(["ERROR", "WARNING"] as const)(
+ "recovers %s tool status with null output",
+ async (level) => {
+ const generation = {
+ id: "generation",
+ traceId: "trace",
+ type: "GENERATION" as const,
+ name: "generation",
+ parentObservationId: null,
+ startTime: new Date(0),
+ endTime: new Date(1),
+ input: [{ role: "user", content: "Run a tool" }],
+ output: [
+ {
+ role: "assistant",
+ parts: [
+ {
+ type: "tool-call",
+ toolName: "search",
+ toolCallId: "call-1",
+ input: {},
+ },
+ ],
+ },
+ ],
+ metadata: {},
+ };
+ const tool = {
+ ...generation,
+ id: "tool",
+ type: "TOOL" as const,
+ name: "search",
+ parentObservationId: generation.id,
+ startTime: new Date(2),
+ input: {},
+ output: null,
+ level,
+ statusMessage: "Search unavailable",
+ metadata: { callID: "call-1" },
+ };
+ const observations = [generation, tool];
+ const snapshot = structuredClone(observations);
+ mocks.observations.mockResolvedValue({
+ observations,
+ totalCount: observations.length,
+ });
+ const result = await loadTraceTranscript({
+ ...trace,
+ recoverToolResponses: true,
+ });
+ expect(
+ result.transcript?.threads
+ .flatMap((thread) => thread.currentTurn.messages)
+ .find((message) => message.observationId === "tool"),
+ ).toMatchObject({
+ level,
+ statusMessage: tool.statusMessage,
+ role: "tool",
+ parts: [
+ {
+ type: "tool-result",
+ toolCallId: "call-1",
+ output: null,
+ isError: level === "ERROR",
+ },
+ ],
+ });
+ expect(observations).toEqual(snapshot);
+ },
+);
+
it.each(["image", "media-token"])(
"attaches reversed nested %s results by recovered call ID",
async (scenario) => {
diff --git a/web/src/components/design-system/CustomTooltip/CustomTooltip.tsx b/web/src/components/design-system/CustomTooltip/CustomTooltip.tsx
index 818ac11ef7..12eda73e9e 100644
--- a/web/src/components/design-system/CustomTooltip/CustomTooltip.tsx
+++ b/web/src/components/design-system/CustomTooltip/CustomTooltip.tsx
@@ -7,6 +7,7 @@ import {
offset,
safePolygon,
shift,
+ size,
useDismiss,
useFloating,
useFocus,
@@ -16,10 +17,24 @@ import {
type Placement,
} from "@floating-ui/react";
import * as React from "react";
+import { cva, type VariantProps } from "class-variance-authority";
import { useLayerContainer } from "@/src/context/LayerContext/LayerContext";
import { cn } from "@/src/utils/tailwind";
+const tooltipVariants = cva(
+ "bg-popover text-popover-foreground animate-in fade-in-0 zoom-in-95 max-w-xs rounded-md border text-sm shadow-md",
+ {
+ variants: {
+ padding: { default: "px-3 py-1.5", uniform: "p-2" },
+ overflow: {
+ hidden: "overflow-hidden",
+ scroll: "overflow-x-hidden overflow-y-auto overscroll-contain",
+ },
+ },
+ },
+);
+
type CustomTooltipProps = {
children: (controls: {
getTriggerProps: (props?: {
@@ -30,6 +45,8 @@ type CustomTooltipProps = {
delay?: number;
hoverableContent?: boolean;
placement?: Placement;
+ padding?: NonNullable<VariantProps<typeof tooltipVariants>["padding"]>;
+ overflow?: NonNullable<VariantProps<typeof tooltipVariants>["overflow"]>;
};
function mergeRefs<T>(...refs: Array<React.Ref<T> | undefined>) {
@@ -50,6 +67,8 @@ function CustomTooltip({
delay = 150,
hoverableContent = true,
placement = "top",
+ padding = "default",
+ overflow = "hidden",
}: CustomTooltipProps) {
const [isOpen, setIsOpen] = React.useState(false);
const layerContainer = useLayerContainer("tooltip");
@@ -58,7 +77,21 @@ function CustomTooltip({
onOpenChange: setIsOpen,
placement,
strategy: "fixed",
- middleware: [offset(4), flip(), shift({ padding: 8 })],
+ middleware: [
+ offset(4),
+ flip(),
+ shift({ padding: 8 }),
+ ...(overflow === "scroll"
+ ? [
+ size({
+ padding: 8,
+ apply({ availableHeight, elements }) {
+ elements.floating.style.maxHeight = `${Math.max(0, availableHeight)}px`;
+ },
+ }),
+ ]
+ : []),
+ ],
transform: false,
whileElementsMounted: autoUpdate,
});
@@ -90,7 +123,7 @@ function CustomTooltip({
<div
ref={refs.setFloating}
className={cn(
- "bg-popover text-popover-foreground animate-in fade-in-0 zoom-in-95 max-w-xs overflow-hidden rounded-md border px-3 py-1.5 text-sm shadow-md",
+ tooltipVariants({ padding, overflow }),
!hoverableContent && "pointer-events-none",
)}
style={floatingStyles}
diff --git a/web/src/components/design-system/StatusMessage/StatusMessage.stories.tsx b/web/src/components/design-system/StatusMessage/StatusMessage.stories.tsx
new file mode 100644
index 0000000000..dfd4caa871
--- /dev/null
+++ b/web/src/components/design-system/StatusMessage/StatusMessage.stories.tsx
@@ -0,0 +1,54 @@
+import preview from "@/.storybook/preview";
+import { expect } from "storybook/test";
+import { StatusMessage } from "./StatusMessage";
+
+const meta = preview.meta({
+ component: StatusMessage,
+ args: { size: "default" as const },
+});
+export default meta;
+
+export const Error = meta.story({
+ args: {
+ level: "ERROR",
+ message: "Upstream model request timed out after 30 seconds.",
+ },
+});
+
+export const Warning = meta.story({
+ args: {
+ level: "WARNING",
+ message: "The observation completed with a recoverable warning.",
+ },
+});
+
+export const Default = meta.story({
+ args: {
+ level: "DEFAULT",
+ message: "The observation completed with additional status details.",
+ },
+});
+
+export const Debug = meta.story({
+ args: {
+ level: "DEBUG",
+ message: "Detailed diagnostic information for this observation.",
+ },
+});
+
+export const Compact = Error.extend({ args: { size: "compact" } });
+export const DarkError = Error.extend({ globals: { theme: "dark" } });
+export const DarkWarning = Warning.extend({ globals: { theme: "dark" } });
+
+export const MultilineMessage = Error.extend({
+ name: "(Test) Preserves Multiline Status Message",
+ args: {
+ message:
+ "Request failed.\nRetry after 30 seconds.\nContact support if the problem persists.",
+ },
+ play: async ({ canvas, args }) => {
+ const message = canvas.getByText(/Request failed/);
+ await expect(message).toBeVisible();
+ await expect(message.textContent).toBe(args.message);
+ },
+});
diff --git a/web/src/components/design-system/StatusMessage/StatusMessage.tsx b/web/src/components/design-system/StatusMessage/StatusMessage.tsx
new file mode 100644
index 0000000000..64f17e5702
--- /dev/null
+++ b/web/src/components/design-system/StatusMessage/StatusMessage.tsx
@@ -0,0 +1,31 @@
+import { type ObservationLevelType } from "@langfuse/shared";
+import { cva, type VariantProps } from "class-variance-authority";
+
+const statusMessageVariants = cva(
+ "ph-no-capture rounded-md px-3 py-2 wrap-break-word whitespace-pre-wrap",
+ {
+ variants: {
+ size: { default: "text-base", compact: "text-sm" },
+ level: {
+ ERROR:
+ "dark:border-dark-red/20 dark:bg-light-red/35 border border-red-100 bg-red-50 text-red-900 dark:text-red-300",
+ WARNING:
+ "dark:border-dark-yellow/20 dark:bg-light-yellow/35 border border-yellow-100 bg-yellow-50 text-yellow-900 dark:text-yellow-300",
+ DEFAULT: "bg-surface-output text-foreground-secondary",
+ DEBUG: "bg-surface-output text-foreground-secondary",
+ } satisfies Record<ObservationLevelType, string>,
+ },
+ },
+);
+
+type StatusMessageProps = {
+ level: ObservationLevelType;
+ message: string;
+ size: NonNullable<VariantProps<typeof statusMessageVariants>["size"]>;
+};
+
+export function StatusMessage({ level, message, size }: StatusMessageProps) {
+ return (
+ <div className={statusMessageVariants({ level, size })}>{message}</div>
+ );
+}
diff --git a/web/src/features/events/server/loadTraceTranscript.ts b/web/src/features/events/server/loadTraceTranscript.ts
index cf341b3b99..fb68b5bbfe 100644
--- a/web/src/features/events/server/loadTraceTranscript.ts
+++ b/web/src/features/events/server/loadTraceTranscript.ts
@@ -32,6 +32,24 @@ type Observation = Awaited<
ReturnType<typeof getObservationsForTraceFromEventsTable>
>["observations"][number];
+type SessionTranscript = Omit<Transcript, "threads"> & {
+ threads: Array<
+ Omit<Transcript["threads"][number], "currentTurn"> & {
+ currentTurn: Omit<
+ Transcript["threads"][number]["currentTurn"],
+ "messages"
+ > & {
+ messages: Array<
+ Transcript["threads"][number]["currentTurn"]["messages"][number] & {
+ level?: Observation["level"];
+ statusMessage?: Observation["statusMessage"];
+ }
+ >;
+ };
+ }
+ >;
+};
+
/**
* Load a trace's observations from the events table, walk them in trace tree
* order, and assemble the transcript of its generations and tools.
@@ -50,7 +68,7 @@ export async function loadTraceTranscript(trace: {
/** Use root observation I/O when no generation/tool transcript exists. */
fallbackToRootIO?: boolean;
}): Promise<{
- transcript: Transcript | null;
+ transcript: SessionTranscript | null;
/** The trace has more observations than the transcript could read. */
cutoff: boolean;
}> {
@@ -137,11 +155,47 @@ export async function loadTraceTranscript(trace: {
structure.totalCount > MAX_OBSERVATIONS_PER_TRACE ||
content.totalCount > MAX_TRANSCRIPT_OBSERVATIONS;
return {
- transcript,
+ transcript: withToolObservationStatus(transcript, contentById),
cutoff,
};
}
+function withToolObservationStatus(
+ transcript: Transcript | null,
+ observationsById: ReadonlyMap<string, Observation>,
+): SessionTranscript | null {
+ if (!transcript) return null;
+ const hasToolStatus = [...observationsById.values()].some(
+ (observation) =>
+ observation.type === "TOOL" &&
+ (observation.level !== undefined ||
+ observation.statusMessage !== undefined),
+ );
+ if (!hasToolStatus) return transcript;
+ return {
+ ...transcript,
+ threads: transcript.threads.map((thread) => ({
+ ...thread,
+ currentTurn: {
+ ...thread.currentTurn,
+ messages: thread.currentTurn.messages.map((message) => {
+ const observation = observationsById.get(message.observationId);
+ if (
+ observation?.type !== "TOOL" ||
+ observation.traceId !== message.traceId
+ )
+ return message;
+ return {
+ ...message,
+ level: observation.level,
+ statusMessage: observation.statusMessage,
+ };
+ }),
+ },
+ })),
+ };
+}
+
// TODO: Look into moving session tool recovery into shared transcript assembly
// so normalized-output recovery does not need separate assembly orchestration.
function assembleSessionTraceTranscript(
@@ -170,6 +224,19 @@ function assembleSessionTraceTranscript(
messages,
(message) => message.source === "input",
);
+ if (
+ observation.type === "TOOL" &&
+ outputMessages.every((message) => message.parts.length === 0) &&
+ (observation.level === "ERROR" ||
+ observation.level === "WARNING" ||
+ observation.statusMessage)
+ ) {
+ outputMessages.push({
+ role: "tool",
+ source: "output",
+ parts: [{ type: "data", value: null }],
+ });
+ }
const [input, output] = partition(
[...inputMessages, ...transformOutput(observation, outputMessages)].map(
(message) => ({ message, key: messageKey(message) }),
@@ -322,6 +389,28 @@ function recoverToolCalls(observations: Observation[]) {
!resolvedCallIds.has(JSON.stringify([observation.traceId, callId]))
)
return messages;
+ if (
+ observation.output === null &&
+ (observation.level === "ERROR" ||
+ observation.level === "WARNING" ||
+ observation.statusMessage)
+ ) {
+ return [
+ {
+ role: "tool",
+ source: "output",
+ parts: [
+ {
+ type: "tool-result",
+ toolCallId: callId,
+ toolName: observation.name ?? "Tool",
+ output: null,
+ isError: observation.level === "ERROR",
+ },
+ ],
+ },
+ ];
+ }
const parts = messages.flatMap((message) => message.parts);
// Tool-result payloads are JSON; wrapping media would discard the file
// parts the session renderer needs for previews.
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 851c0caedc..cf466e85fe 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
@@ -11,6 +11,7 @@ import {
} from "@/src/features/sessions/hooks/useSessionConversationTimelineController";
import { type SessionConversationTimelineTrace } from "@/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/SessionConversationTimelineTrace";
import { getSessionConversationEntries } from "../../fns/getSessionConversationEntries";
+import { type Observation } from "@langfuse/shared";
type TraceProps = ComponentProps<typeof SessionConversationTimelineTrace>;
@@ -22,6 +23,8 @@ type WorkflowObservation = TranscriptObservation & {
inputTruncated: boolean;
outputTruncated: boolean;
metadataTruncated: boolean;
+ level?: Observation["level"];
+ statusMessage?: Observation["statusMessage"];
};
type WorkflowTrace = Pick<TraceProps, "trace" | "turnNumber"> & {
@@ -1187,6 +1190,8 @@ const inAppAgentActions: Array<{
input: Record<string, unknown>;
output: unknown;
outputAsText?: boolean;
+ level?: Observation["level"];
+ statusMessage?: Observation["statusMessage"];
}>;
}> = [
{
@@ -1223,6 +1228,9 @@ const inAppAgentActions: Array<{
{
name: "langfuse_listObservations",
latency: 0.233,
+ level: "WARNING",
+ statusMessage:
+ "Sample limited to 25 observations. More results are available on the next page.",
input: {
fields: ["id", "name", "level", "statusMessage"],
fromStartTime: "2026-01-01T00:00:00Z",
@@ -1267,15 +1275,18 @@ const inAppAgentActions: Array<{
{
name: "bash",
latency: 0.195,
+ level: "ERROR",
+ statusMessage:
+ "Could not parse one observation's status message. Re-fetch the sample before retrying.",
input: {
command: "jq 'group_by(.statusMessage)' synthetic-errors.json",
},
output: {
startedAt: "2026-01-08T09:00:17Z",
completedAt: "2026-01-08T09:00:17Z",
- exitCode: 0,
- stdout: "timeout: 9\ninvalid itinerary: 7\nmissing fare: 5\nother: 4",
- stderr: "",
+ exitCode: 1,
+ stdout: "",
+ stderr: "jq: parse error: Invalid numeric literal",
},
},
],
@@ -1288,6 +1299,9 @@ const inAppAgentActions: Array<{
{
name: "langfuse_listObservations",
latency: 0.219,
+ level: "WARNING",
+ statusMessage:
+ "Some observation payloads were truncated. Counts are complete, but examples may omit details.",
input: {
fields: ["id", "traceId", "input", "output", "statusMessage"],
filter: [
@@ -1846,30 +1860,34 @@ Active filter: level is ERROR
}),
...action.tools.map((tool, toolIndex) => {
const toolCallId = `error-analysis-call-${actionIndex + 1}-${toolIndex + 1}`;
- return codingAgentObservation({
- traceId: inAppAgentTraceId,
- id: `error-analysis-tool-${actionIndex + 1}-${toolIndex + 1}`,
- parentObservationId: inAppAgentTurnId,
- type: "TOOL",
- name: tool.name,
- offsetMs: action.offsetMs + Math.round(action.latency * 1_000),
- latency: tool.latency,
- input: JSON.stringify(tool.input),
- output: tool.outputAsText
- ? String(tool.output)
- : JSON.stringify({
- type: "tool-result",
- toolCallId,
- toolName: tool.name,
- output: tool.output,
- }),
- metadata: {
- ...inAppAgentMetadata,
- parentMessageId: `message-demo-${actionIndex + 1}`,
- toolCallApprovalSource: "automatic",
- toolCallId,
- },
- });
+ return {
+ level: tool.level,
+ statusMessage: tool.statusMessage,
+ ...codingAgentObservation({
+ traceId: inAppAgentTraceId,
+ id: `error-analysis-tool-${actionIndex + 1}-${toolIndex + 1}`,
+ parentObservationId: inAppAgentTurnId,
+ type: "TOOL",
+ name: tool.name,
+ offsetMs: action.offsetMs + Math.round(action.latency * 1_000),
+ latency: tool.latency,
+ input: JSON.stringify(tool.input),
+ output: tool.outputAsText
+ ? String(tool.output)
+ : JSON.stringify({
+ type: "tool-result",
+ toolCallId,
+ toolName: tool.name,
+ output: tool.output,
+ }),
+ metadata: {
+ ...inAppAgentMetadata,
+ parentMessageId: `message-demo-${actionIndex + 1}`,
+ toolCallApprovalSource: "automatic",
+ toolCallId,
+ },
+ }),
+ };
}),
];
}),
@@ -1909,7 +1927,10 @@ const implementationCodingAgentTrace = {
} satisfies TraceProps["trace"];
type WorkflowFixture = Pick<TraceProps, "trace" | "turnNumber"> & {
- observations: Array<TranscriptObservation & { environment: string }>;
+ observations: Array<
+ TranscriptObservation &
+ Pick<WorkflowObservation, "environment" | "level" | "statusMessage">
+ >;
};
const supportAgentWorkflow: WorkflowFixture[] = [
@@ -2028,8 +2049,14 @@ const workflowTranscripts = new Map(
manySimpleTurnsWorkflow,
].map((workflow) => [
workflow,
- workflow.map(
- (item): WorkflowTrace => ({
+ workflow.map((item): WorkflowTrace => {
+ const transcript = assembleTranscript(
+ orderObservations(item.observations),
+ );
+ const observationsById = new Map(
+ item.observations.map((observation) => [observation.id, observation]),
+ );
+ return {
trace: item.trace,
turnNumber: item.turnNumber,
state: {
@@ -2037,13 +2064,29 @@ const workflowTranscripts = new Map(
result: {
state: "loaded",
cutoff: false,
- transcript: assembleTranscript(
- orderObservations(item.observations),
- ),
+ transcript: transcript
+ ? {
+ ...transcript,
+ threads: transcript.threads.map((thread) => ({
+ ...thread,
+ currentTurn: {
+ ...thread.currentTurn,
+ messages: thread.currentTurn.messages.map((message) => ({
+ ...message,
+ level: observationsById.get(message.observationId)
+ ?.level,
+ statusMessage: observationsById.get(
+ message.observationId,
+ )?.statusMessage,
+ })),
+ },
+ })),
+ }
+ : null,
},
},
- }),
- ),
+ };
+ }),
]),
);
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 2b717ab2ae..9c8aa4b1c3 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
@@ -11,6 +11,7 @@ import {
import { SessionConversationTimeline } from "@/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/SessionConversationTimeline";
import { type SessionConversationTimelineController } from "@/src/features/sessions/hooks/useSessionConversationTimelineController";
import { getSessionTranscriptRows } from "@/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/fns/getSessionTranscriptRows";
+import { getSessionToolStatus } from "@/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/fns/getSessionToolStatus";
import { getSessionTranscriptThreads } from "../../fns/getSessionTranscriptThreads";
import { getSessionConversationEntries } from "../../fns/getSessionConversationEntries";
import { computeIdleGapSeconds } from "@/src/features/sessions/sessionIdleGap";
@@ -169,6 +170,12 @@ export function SessionConversationalView(
: undefined,
observationId: row.message.observationId,
label,
+ ...getSessionToolStatus({
+ level: row.message.level,
+ statusMessage: row.message.statusMessage,
+ isError:
+ row.type === "tool" ? row.result?.isError : undefined,
+ }),
role:
row.type === "tool" ? ("tool" as const) : row.message.role,
},
diff --git a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationSidebar/SessionConversationSidebar.stories.tsx b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationSidebar/SessionConversationSidebar.stories.tsx
index 1ac36cbfb6..eb0da28fde 100644
--- a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationSidebar/SessionConversationSidebar.stories.tsx
+++ b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationSidebar/SessionConversationSidebar.stories.tsx
@@ -1,5 +1,5 @@
import preview from "@/.storybook/preview";
-import { expect, fn, userEvent, within } from "storybook/test";
+import { expect, fn, userEvent, waitFor, within } from "storybook/test";
import { type ComponentProps, useState } from "react";
import { SessionConversationSidebar } from "@/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationSidebar/SessionConversationSidebar";
@@ -124,6 +124,185 @@ export const DarkMode = meta.story({
globals: { theme: "dark" },
});
export const Empty = meta.story({ args: { ...loadedArgs, traces: [] } });
+
+export const GroupedToolStatuses = meta.story({
+ name: "(Test) Grouped Tool Status Indicators",
+ args: {
+ ...loadedArgs,
+ traces: [
+ {
+ ...loadedArgs.traces[0]!,
+ transcriptRows: [
+ {
+ id: "0:0",
+ observationId: "search",
+ role: "tool",
+ label: "search",
+ level: "ERROR",
+ statusMessage: "Search timed out",
+ },
+ {
+ id: "0:1",
+ observationId: "fetch",
+ role: "tool",
+ label: "fetch",
+ level: "ERROR",
+ },
+ {
+ id: "0:2",
+ observationId: "list",
+ role: "tool",
+ label: "list",
+ level: "WARNING",
+ statusMessage: "Results truncated",
+ },
+ {
+ id: "0:3",
+ observationId: "validate",
+ role: "tool",
+ label: "validate",
+ level: "WARNING",
+ },
+ {
+ id: "0:4",
+ observationId: "cache",
+ role: "tool",
+ label: "cache",
+ level: "DEFAULT",
+ },
+ {
+ id: "0:5",
+ observationId: "debug",
+ role: "tool",
+ label: "debug",
+ level: "DEBUG",
+ },
+ ],
+ },
+ ],
+ },
+ play: async ({ canvas, canvasElement, userEvent, args }) => {
+ if (args.state !== "loaded")
+ throw new globalThis.Error("Expected loaded sidebar");
+ const errors = await canvas.findByLabelText("2 tool errors");
+ await expect(errors).toBeVisible();
+ await expect(canvas.getByLabelText("2 tool warnings")).toBeVisible();
+ const button = canvas.getByRole("button", { name: /^Tool:/ });
+ await userEvent.hover(button);
+ const tooltip = await within(canvasElement.ownerDocument.body).findByRole(
+ "tooltip",
+ );
+ await waitFor(async () => {
+ await expect(within(tooltip).getByText("search")).toBeVisible();
+ await expect(within(tooltip).getByText("fetch")).toBeVisible();
+ await expect(within(tooltip).getByText("list")).toBeVisible();
+ await expect(within(tooltip).getByText("validate")).toBeVisible();
+ });
+ await expect(within(tooltip).getByText("Search timed out")).toBeVisible();
+ await expect(within(tooltip).getByText("Results truncated")).toBeVisible();
+ await expect(
+ within(tooltip).getByRole("heading", { name: "Tool calls" }),
+ ).toBeVisible();
+ await expect(
+ within(tooltip).getByRole("heading", { name: "Errors" }),
+ ).toBeVisible();
+ await expect(
+ within(tooltip).getByRole("heading", { name: "Warnings" }),
+ ).toBeVisible();
+ await userEvent.click(button);
+ await expect(args.onSelect).toHaveBeenCalledWith(0, "search", "0:0", "0:0");
+ },
+});
+
+export const IndividualToolStatuses = meta.story({
+ name: "(Test) Individual Tool Status Indicators",
+ args: {
+ ...loadedArgs,
+ search: "search",
+ traces: [
+ {
+ ...loadedArgs.traces[0]!,
+ transcriptRows: [
+ {
+ id: "0:0",
+ observationId: "failed",
+ role: "tool",
+ label: "search_failed",
+ level: "ERROR",
+ statusMessage: "Search timed out",
+ },
+ {
+ id: "0:1",
+ observationId: "partial",
+ role: "tool",
+ label: "search_partial",
+ level: "WARNING",
+ statusMessage: "Results truncated",
+ },
+ {
+ id: "0:2",
+ observationId: "healthy",
+ role: "tool",
+ label: "search_healthy",
+ level: "DEFAULT",
+ statusMessage: "Search completed",
+ },
+ {
+ id: "0:3",
+ observationId: "debug",
+ role: "tool",
+ label: "search_debug",
+ level: "DEBUG",
+ statusMessage: "Diagnostics enabled",
+ },
+ ],
+ },
+ ],
+ },
+ play: async ({ canvas, canvasElement, userEvent, args }) => {
+ if (args.state !== "loaded")
+ throw new globalThis.Error("Expected loaded sidebar");
+ await expect(
+ await canvas.findByLabelText("Tool status: ERROR"),
+ ).toBeVisible();
+ await expect(canvas.getByLabelText("Tool status: WARNING")).toBeVisible();
+ await expect(
+ canvas.queryByLabelText("Tool status: DEFAULT"),
+ ).not.toBeInTheDocument();
+ await expect(
+ canvas.queryByLabelText("Tool status: DEBUG"),
+ ).not.toBeInTheDocument();
+ const overlays = within(canvasElement.ownerDocument.body);
+ const failed = canvas.getByRole("button", { name: "tool: search_failed" });
+ await userEvent.hover(failed);
+ await expect(await overlays.findByRole("tooltip")).toHaveTextContent(
+ "Search timed out",
+ );
+ await waitFor(async () => {
+ const tooltip = within(overlays.getByRole("tooltip"));
+ await expect(tooltip.getByText("search_failed")).toBeVisible();
+ await expect(tooltip.getByText("Search timed out")).toBeVisible();
+ });
+ await userEvent.unhover(failed);
+ await waitFor(() =>
+ expect(overlays.queryByRole("tooltip")).not.toBeInTheDocument(),
+ );
+ await userEvent.click(failed);
+ await expect(args.onSelect).toHaveBeenCalledWith(0, "failed", "0:0");
+ await userEvent.tab();
+ await expect(
+ canvas.getByRole("button", { name: "tool: search_partial" }),
+ ).toHaveFocus();
+ await expect(await overlays.findByRole("tooltip")).toHaveTextContent(
+ "Results truncated",
+ );
+ await waitFor(async () => {
+ const tooltip = within(overlays.getByRole("tooltip"));
+ await expect(tooltip.getByText("search_partial")).toBeVisible();
+ await expect(tooltip.getByText("Results truncated")).toBeVisible();
+ });
+ },
+});
export const Error = meta.story({
args: {
...loadedArgs,
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 15bcb82854..2d80314eaa 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
@@ -1,4 +1,5 @@
import {
+ cloneElement,
useCallback,
useLayoutEffect,
useRef,
@@ -6,9 +7,11 @@ import {
type ReactNode,
} from "react";
import { useVirtualizer } from "@tanstack/react-virtual";
-import { ChevronDown, Search } from "lucide-react";
+import { ChevronDown, CircleAlert, Search, TriangleAlert } from "lucide-react";
+import { type Observation } from "@langfuse/shared";
import { Input } from "@/src/components/ui/input";
-import { CustomTooltip } from "@/src/components/design-system/CustomTooltip/CustomTooltip";
+import { SessionToolTooltip } from "@/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionToolTooltip/SessionToolTooltip";
+import { SessionToolStatusCountBadge } from "@/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionToolStatusCountBadge/SessionToolStatusCountBadge";
import { type EventSessionTrace } from "@/src/features/sessions/sessionDetailPageTypes";
import {
formatIdleGap,
@@ -36,6 +39,8 @@ export type SessionConversationSidebarTrace = {
label: string;
role: "system" | "user" | "assistant" | "tool";
toolGroupId?: string;
+ level?: Observation["level"];
+ statusMessage?: Observation["statusMessage"];
}>
| null
| undefined;
@@ -474,21 +479,32 @@ export function SessionConversationSidebar(
}).map((group, groupIndex, groups) => {
if (group.type === "tools") {
const firstTool = group.rows[0]!;
+ const errors = group.rows.filter(
+ (row) => row.level === "ERROR",
+ );
+ const warnings = group.rows.filter(
+ (row) => row.level === "WARNING",
+ );
return (
- <CustomTooltip
+ <SessionToolTooltip
key={firstTool.id}
- placement="right"
- delay={200}
- content={
- <div className="flex flex-col gap-2">
- <h4 className="text-sm font-bold">
- Tool calls
- </h4>
- <div className="text-muted-foreground whitespace-pre-line">
- {group.title}
- </div>
- </div>
- }
+ variant="sidebar"
+ content={{
+ type: "group",
+ title: group.title,
+ errors: errors.map((row) => ({
+ name: row.label,
+ message:
+ row.statusMessage ||
+ "Tool failed",
+ })),
+ warnings: warnings.map((row) => ({
+ name: row.label,
+ message:
+ row.statusMessage ||
+ "Tool reported a warning",
+ })),
+ }}
>
{({ getTriggerProps }) => (
<button
@@ -503,7 +519,7 @@ export function SessionConversationSidebar(
firstTool.id,
)
}
- className="ph-no-capture text-muted-foreground hover:bg-foreground/10 -mr-2 -ml-1 flex min-w-0 items-center gap-2 rounded-sm px-1 py-1 text-left text-[13px] transition-colors duration-150"
+ className="ph-no-capture text-muted-foreground hover:bg-foreground/10 -mr-2 -ml-1 flex min-w-0 items-center gap-2 rounded-sm py-1 pr-2 pl-1 text-left text-[13px] transition-colors duration-150"
>
<span
className="min-w-0 flex-1 truncate"
@@ -514,9 +530,25 @@ export function SessionConversationSidebar(
? group.summary
: `Tool: ${group.summary}`}
</span>
+ {errors.length > 0 && (
+ <SessionToolStatusCountBadge
+ aria-label={`${errors.length} tool ${errors.length === 1 ? "error" : "errors"}`}
+ count={errors.length}
+ severity="error"
+ variant="sidebar"
+ />
+ )}
+ {warnings.length > 0 && (
+ <SessionToolStatusCountBadge
+ aria-label={`${warnings.length} tool ${warnings.length === 1 ? "warning" : "warnings"}`}
+ count={warnings.length}
+ severity="warning"
+ variant="sidebar"
+ />
+ )}
</button>
)}
- </CustomTooltip>
+ </SessionToolTooltip>
);
}
const row = group.row;
@@ -608,7 +640,13 @@ export function SessionConversationSidebar(
if (end < row.label.length)
excerpt.push("…");
}
- return (
+ const hasError =
+ row.role === "tool" &&
+ row.level === "ERROR";
+ const hasWarning =
+ row.role === "tool" &&
+ row.level === "WARNING";
+ const button = (
<button
key={row.id}
type="button"
@@ -619,7 +657,7 @@ export function SessionConversationSidebar(
row.id,
)
}
- className="ph-no-capture hover:bg-foreground/10 -mr-2 -ml-1 flex min-w-0 items-center gap-2 rounded-sm px-1 py-1 text-left transition-colors duration-150"
+ className="ph-no-capture hover:bg-foreground/10 -mr-2 -ml-1 flex min-w-0 items-center gap-2 rounded-sm py-1 pr-2 pl-1 text-left transition-colors duration-150"
aria-label={
row.role === "tool"
? `tool: ${row.label}`
@@ -649,8 +687,46 @@ export function SessionConversationSidebar(
</span>
)}
</span>
+ {hasError && (
+ <CircleAlert
+ className="icon-sm text-destructive shrink-0"
+ aria-label="Tool status: ERROR"
+ />
+ )}
+ {hasWarning && (
+ <TriangleAlert
+ className="icon-sm shrink-0 text-yellow-600 dark:text-yellow-500"
+ aria-label="Tool status: WARNING"
+ />
+ )}
</button>
);
+ if (hasError || hasWarning) {
+ return (
+ <SessionToolTooltip
+ key={row.id}
+ variant="sidebar"
+ content={{
+ type: "status",
+ name: row.label,
+ level: hasError ? "ERROR" : "WARNING",
+ message:
+ row.statusMessage ||
+ (hasError
+ ? "Tool failed"
+ : "Tool reported a warning"),
+ }}
+ >
+ {({ getTriggerProps }) =>
+ cloneElement(
+ button,
+ getTriggerProps(),
+ )
+ }
+ </SessionToolTooltip>
+ );
+ }
+ return button;
})}
</section>
))}
diff --git a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/SessionConversationTimelineTrace.stories.tsx b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/SessionConversationTimelineTrace.stories.tsx
index beaf0be21f..e9ee5f060a 100644
--- a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/SessionConversationTimelineTrace.stories.tsx
+++ b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/SessionConversationTimelineTrace.stories.tsx
@@ -1,6 +1,6 @@
import preview from "@/.storybook/preview";
import { type ComponentProps } from "react";
-import { expect, fn, userEvent, within } from "storybook/test";
+import { expect, fn, userEvent, waitFor, within } from "storybook/test";
import { SessionConversationTimelineTrace } from "@/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/SessionConversationTimelineTrace";
type Props = ComponentProps<typeof SessionConversationTimelineTrace>;
@@ -151,6 +151,9 @@ const weatherState = transcriptState({
function toolPreviewState(
previews: {
name: string;
+ level?: Thread["currentTurn"]["messages"][number]["level"];
+ statusMessage?: Thread["currentTurn"]["messages"][number]["statusMessage"];
+ isError?: boolean;
input: Extract<
Thread["currentTurn"]["messages"][number]["parts"][number],
{ type: "tool-call" }
@@ -164,7 +167,7 @@ function toolPreviewState(
return transcriptState({
history: [],
messages: previews.flatMap<Thread["currentTurn"]["messages"][number]>(
- ({ name, input, output }) => [
+ ({ name, input, output, level, statusMessage, isError }) => [
{
...provenance,
role: "assistant",
@@ -182,12 +185,15 @@ function toolPreviewState(
...provenance,
role: "tool",
source: "output",
+ level,
+ statusMessage,
parts: [
{
type: "tool-result",
toolCallId: name,
toolName: name,
output,
+ isError,
},
],
},
@@ -868,10 +874,377 @@ export const ToolFailure = meta.story({
},
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
- await expect(canvas.getByLabelText("Failed")).toBeInTheDocument();
+ await expect(canvas.getByLabelText("Tool status: ERROR")).toBeVisible();
+ await expect(
+ canvas.queryByLabelText("Tool status: WARNING"),
+ ).not.toBeInTheDocument();
await userEvent.click(
canvas.getByRole("button", { name: "Expand get_order" }),
);
await expect(canvas.getByText(/TOOL_TIMEOUT/)).toBeInTheDocument();
},
});
+
+export const ToolErrorStatus = meta.story({
+ name: "(Test) Tool Error Status Message",
+ args: {
+ ...commonArgs,
+ state: toolPreviewState([
+ {
+ name: "search",
+ input: null,
+ output: null,
+ level: "ERROR",
+ statusMessage: "Search timed out",
+ isError: true,
+ },
+ ]),
+ },
+ play: async ({ args, canvas, canvasElement, userEvent }) => {
+ if (args.state.type !== "transcript") {
+ throw new globalThis.Error("Expected transcript fixture");
+ }
+ const message =
+ args.state.result.transcript?.threads[0]?.currentTurn.messages.find(
+ (message) => message.role === "tool",
+ );
+ if (!message?.level || !message.statusMessage) {
+ throw new globalThis.Error("Expected tool status fixture");
+ }
+ const overlays = within(canvasElement.ownerDocument.body);
+ const indicator = canvas.getByLabelText(`Tool status: ${message.level}`);
+ if (message.level === "WARNING" || message.level === "ERROR") {
+ await expect(indicator).toBeVisible();
+ } else {
+ await expect(indicator).not.toBeVisible();
+ }
+ await expect(canvas.queryByLabelText("Failed")).not.toBeInTheDocument();
+ await expect(overlays.queryByRole("tooltip")).not.toBeInTheDocument();
+
+ // Simulated pointer events do not activate CSS :hover in browser tests.
+ if ("__vitest_browser__" in globalThis) {
+ const { userEvent: browserUserEvent } = await import("vitest/browser");
+ await browserUserEvent.hover(
+ canvas.getByRole("button", { name: "search" }),
+ );
+ await expect(indicator).toBeVisible();
+ await browserUserEvent.unhover(
+ canvas.getByRole("button", { name: "search" }),
+ );
+ }
+ await userEvent.click(canvas.getByRole("button", { name: "search" }));
+ await expect(indicator).toBeVisible();
+ await userEvent.hover(indicator);
+ await expect(await overlays.findByRole("tooltip")).toHaveTextContent(
+ message.statusMessage,
+ );
+ const tooltip = within(overlays.getByRole("tooltip"));
+ await waitFor(() => expect(tooltip.getByText("search")).toBeVisible());
+ const statusMessage = tooltip.getByText(message.statusMessage);
+ await waitFor(() => expect(statusMessage).toBeVisible());
+ await userEvent.unhover(indicator);
+ await waitFor(() =>
+ expect(overlays.queryByRole("tooltip")).not.toBeInTheDocument(),
+ );
+ await userEvent.click(canvas.getByRole("button", { name: "search" }));
+ await expect(canvas.getByRole("button", { name: "search" })).toHaveFocus();
+ await expect(indicator).toBeVisible();
+ await userEvent.tab();
+ await expect(indicator).toHaveFocus();
+ await expect(await overlays.findByRole("tooltip")).toHaveTextContent(
+ message.statusMessage,
+ );
+ },
+});
+
+export const ToolResultErrorOverridesWarning = meta.story({
+ name: "(Test) Tool Result Error Overrides Warning",
+ args: {
+ ...commonArgs,
+ state: toolPreviewState([
+ {
+ name: "search",
+ input: null,
+ output: null,
+ level: "WARNING",
+ statusMessage: "Search unavailable",
+ isError: true,
+ },
+ ]),
+ },
+ play: async ({ canvas, canvasElement, userEvent }) => {
+ const indicator = canvas.getByLabelText("Tool status: ERROR");
+ await expect(indicator).toBeVisible();
+ await expect(
+ canvas.queryByLabelText("Tool status: WARNING"),
+ ).not.toBeInTheDocument();
+ await expect(canvas.queryByLabelText("Failed")).not.toBeInTheDocument();
+ await userEvent.hover(indicator);
+ await expect(
+ await within(canvasElement.ownerDocument.body).findByRole("tooltip"),
+ ).toHaveTextContent("Search unavailable");
+ },
+});
+
+export const LongToolStatus = meta.story({
+ name: "(Test) Scrolls Long Tool Status",
+ args: {
+ ...commonArgs,
+ state: toolPreviewState([
+ {
+ name: "search",
+ input: null,
+ output: null,
+ level: "ERROR",
+ statusMessage: `${"A detailed tool failure\n".repeat(100)}End of status`,
+ },
+ ]),
+ },
+ play: async ({ canvas, canvasElement, userEvent }) => {
+ await userEvent.hover(canvas.getByLabelText("Tool status: ERROR"));
+ const tooltip = await within(canvasElement.ownerDocument.body).findByRole(
+ "tooltip",
+ );
+ await waitFor(() => {
+ const bounds = tooltip.getBoundingClientRect();
+ expect(bounds.top).toBeGreaterThanOrEqual(0);
+ expect(bounds.bottom).toBeLessThanOrEqual(
+ canvasElement.ownerDocument.documentElement.clientHeight,
+ );
+ expect(tooltip.scrollHeight).toBeGreaterThan(tooltip.clientHeight);
+ });
+ tooltip.scrollTo({ top: tooltip.scrollHeight });
+ await waitFor(() => expect(tooltip.scrollTop).toBeGreaterThan(0));
+ const textNodes = canvasElement.ownerDocument.createTreeWalker(
+ tooltip,
+ NodeFilter.SHOW_TEXT,
+ );
+ const finalText = canvasElement.ownerDocument.createRange();
+ let textNode = textNodes.nextNode();
+ while (textNode) {
+ const offset = textNode.textContent?.indexOf("End of status") ?? -1;
+ if (offset >= 0) {
+ finalText.setStart(textNode, offset);
+ finalText.setEnd(textNode, offset + "End of status".length);
+ break;
+ }
+ textNode = textNodes.nextNode();
+ }
+ await expect(textNode).not.toBeNull();
+ await waitFor(() => {
+ const visibleBounds = tooltip.getBoundingClientRect();
+ const textBounds = finalText.getBoundingClientRect();
+ expect(textBounds.height).toBeGreaterThan(0);
+ expect(textBounds.top).toBeGreaterThanOrEqual(visibleBounds.top);
+ expect(textBounds.bottom).toBeLessThanOrEqual(visibleBounds.bottom);
+ });
+ },
+});
+
+export const ToolWarningStatus = ToolErrorStatus.extend({
+ name: "(Test) Tool Warning Status Message",
+ args: {
+ state: toolPreviewState([
+ {
+ name: "search",
+ input: null,
+ output: null,
+ level: "WARNING",
+ statusMessage: "Search returned partial results",
+ },
+ ]),
+ },
+});
+
+export const ToolDefaultStatus = ToolErrorStatus.extend({
+ name: "(Test) Tool Default Status Message",
+ args: {
+ state: toolPreviewState([
+ {
+ name: "search",
+ input: null,
+ output: null,
+ level: "DEFAULT",
+ statusMessage: "Search completed",
+ },
+ ]),
+ },
+});
+
+export const ToolDebugStatus = ToolErrorStatus.extend({
+ name: "(Test) Tool Debug Status Message",
+ args: {
+ state: toolPreviewState([
+ {
+ name: "search",
+ input: null,
+ output: null,
+ level: "DEBUG",
+ statusMessage: "Search used cached results",
+ },
+ ]),
+ },
+});
+
+export const ToolDefaultWithoutMessage = meta.story({
+ name: "(Test) Tool Default Status Without Message",
+ args: {
+ ...commonArgs,
+ state: toolPreviewState([
+ { name: "search", input: null, output: null, level: "DEFAULT" },
+ ]),
+ },
+ play: async ({ canvas }) => {
+ await expect(canvas.getByRole("button", { name: "search" })).toBeVisible();
+ await expect(
+ canvas.queryByLabelText("Tool status: DEFAULT"),
+ ).not.toBeInTheDocument();
+ },
+});
+
+export const GroupedToolStatuses = meta.story({
+ name: "(Test) Grouped Tool Errors And Warnings",
+ args: {
+ ...commonArgs,
+ state: toolPreviewState([
+ {
+ name: "search",
+ input: null,
+ output: null,
+ level: "ERROR",
+ statusMessage: "Search timed out",
+ isError: true,
+ },
+ { name: "fetch", input: null, output: null, isError: true },
+ {
+ name: "list",
+ input: null,
+ output: null,
+ level: "WARNING",
+ statusMessage: "Results truncated",
+ },
+ { name: "validate", input: null, output: null, level: "WARNING" },
+ {
+ name: "cache",
+ input: null,
+ output: null,
+ level: "DEFAULT",
+ statusMessage: "Cache hit",
+ },
+ {
+ name: "debug",
+ input: null,
+ output: null,
+ level: "DEBUG",
+ statusMessage: "Diagnostics enabled",
+ },
+ ]),
+ },
+ play: async ({ canvas, canvasElement, userEvent }) => {
+ const overlays = within(canvasElement.ownerDocument.body);
+ const errors = canvas.getByLabelText("Tool group: 2 errors");
+ const warnings = canvas.getByLabelText("Tool group: 2 warnings");
+ const groupToggle = canvas.getByRole("button", { name: /Show tools:/ });
+ await expect(groupToggle).toHaveAttribute("aria-expanded", "false");
+ await expect(errors).toBeVisible();
+ await expect(warnings).toBeVisible();
+ await expect(
+ canvas.queryByLabelText("Tool status: ERROR"),
+ ).not.toBeInTheDocument();
+
+ await userEvent.hover(errors);
+ await expect(await overlays.findByRole("tooltip")).toHaveTextContent(
+ "Search timed out",
+ );
+ await waitFor(async () => {
+ const tooltip = within(overlays.getByRole("tooltip"));
+ await expect(tooltip.getByText("Search timed out")).toBeVisible();
+ await expect(tooltip.getByText("search")).toBeVisible();
+ await expect(tooltip.getByText("fetch")).toBeVisible();
+ });
+ await expect(
+ within(overlays.getByRole("tooltip")).queryByRole("heading", {
+ name: "Errors",
+ }),
+ ).not.toBeInTheDocument();
+ await expect(overlays.getByRole("tooltip")).not.toHaveTextContent(
+ "Results truncated",
+ );
+ await expect(
+ within(overlays.getByRole("tooltip")).queryByRole("heading", {
+ name: "Tool calls",
+ }),
+ ).not.toBeInTheDocument();
+ await userEvent.unhover(errors);
+ await waitFor(() =>
+ expect(overlays.queryByRole("tooltip")).not.toBeInTheDocument(),
+ );
+ await userEvent.hover(warnings);
+ await expect(await overlays.findByRole("tooltip")).toHaveTextContent(
+ "Results truncated",
+ );
+ await waitFor(() =>
+ expect(
+ within(overlays.getByRole("tooltip")).getByText("Results truncated"),
+ ).toBeVisible(),
+ );
+ await expect(
+ within(overlays.getByRole("tooltip")).queryByRole("heading", {
+ name: "Warnings",
+ }),
+ ).not.toBeInTheDocument();
+ await expect(overlays.getByRole("tooltip")).not.toHaveTextContent(
+ "Search timed out",
+ );
+ await userEvent.unhover(warnings);
+ await waitFor(() =>
+ expect(overlays.queryByRole("tooltip")).not.toBeInTheDocument(),
+ );
+
+ await userEvent.click(groupToggle);
+ await expect(canvas.getAllByLabelText("Tool status: ERROR")).toHaveLength(
+ 2,
+ );
+ for (const indicator of canvas.getAllByLabelText("Tool status: ERROR")) {
+ await expect(indicator).toBeVisible();
+ }
+ await expect(canvas.getAllByLabelText("Tool status: WARNING")).toHaveLength(
+ 2,
+ );
+ await expect(canvas.queryByLabelText("Failed")).not.toBeInTheDocument();
+ await expect(errors).toHaveTextContent("2 errors");
+ await expect(warnings).toHaveTextContent("2 warnings");
+ await userEvent.tab();
+ await userEvent.tab();
+ await expect(errors).toHaveFocus();
+ await expect(await overlays.findByRole("tooltip")).toHaveTextContent(
+ "Search timed out",
+ );
+ await expect(
+ canvas.getByRole("button", { name: /Hide tools:/ }),
+ ).toHaveAttribute("aria-expanded", "true");
+ },
+});
+
+export const HealthyToolGroup = meta.story({
+ name: "(Test) Healthy Tool Group Has No Status Summary",
+ args: {
+ ...commonArgs,
+ state: toolPreviewState(
+ ["search", "fetch", "cache", "validate"].map((name) => ({
+ name,
+ input: null,
+ output: null,
+ level: "DEFAULT",
+ })),
+ ),
+ },
+ play: async ({ canvas }) => {
+ await expect(
+ canvas.getByRole("button", { name: /Show tools:/ }),
+ ).toBeVisible();
+ await expect(
+ canvas.queryByLabelText(/Tool group:/),
+ ).not.toBeInTheDocument();
+ },
+});
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.tsx
index 5fc91a69b7..a5fc1ac207 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
@@ -12,6 +12,9 @@ import { SessionTimelineCollapsibleRow } from "@/src/features/sessions/component
import { formatIntervalSeconds } from "@/src/utils/dates";
import { groupConsecutiveTools } from "@/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/fns/groupConsecutiveTools";
import { cn } from "@/src/utils/tailwind";
+import { SessionToolTooltip } from "@/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionToolTooltip/SessionToolTooltip";
+import { getSessionToolStatus } from "@/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/fns/getSessionToolStatus";
+import { SessionToolStatusCountBadge } from "@/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionToolStatusCountBadge/SessionToolStatusCountBadge";
export function SessionTranscriptContent({
result,
@@ -65,6 +68,10 @@ export function SessionTranscriptContent({
type DisplayMessage = NormalizedMessage & {
timing: { startTime: Date; endTime: Date | null } | null;
observationId: string | null;
+ level?: NonNullable<
+ Extract<SessionTraceTranscriptState, { state: "loaded" }>["transcript"]
+ >["threads"][number]["currentTurn"]["messages"][number]["level"];
+ statusMessage?: string | null;
};
function SessionTranscriptThread({
@@ -236,6 +243,33 @@ function SessionTranscriptToolGroup({
</div>
);
}
+ const errors: Array<
+ Extract<
+ ComponentProps<typeof SessionToolTooltip>["content"],
+ { type: "group" }
+ >["errors"][number]
+ > = [];
+ const warnings: typeof errors = [];
+ for (const { row } of rows) {
+ if (row.type !== "tool") continue;
+ const name = row.call?.toolName ?? row.result?.toolName ?? "Tool";
+ const status = getSessionToolStatus({
+ level: row.message.level,
+ statusMessage: row.message.statusMessage,
+ isError: row.result?.isError,
+ });
+ if (status.level === "ERROR") {
+ errors.push({
+ name,
+ message: status.statusMessage || "Tool failed",
+ });
+ } else if (status.level === "WARNING") {
+ warnings.push({
+ name,
+ message: status.statusMessage || "Tool reported a warning",
+ });
+ }
+ }
return (
<SessionTimelineCollapsibleRow
label={summary}
@@ -250,6 +284,42 @@ function SessionTranscriptToolGroup({
requestId: props.scrollTarget?.requestId,
})
}
+ trailingContent={[
+ {
+ tools: errors,
+ label: "error" as const,
+ },
+ {
+ tools: warnings,
+ label: "warning" as const,
+ },
+ ].map(({ tools, label }) => {
+ if (tools.length === 0) return null;
+ const summary = `${tools.length} ${label}${tools.length === 1 ? "" : "s"}`;
+ return (
+ <SessionToolTooltip
+ key={label}
+ variant="timeline"
+ content={{
+ type: "group",
+ title,
+ errors: label === "error" ? tools : [],
+ warnings: label === "warning" ? tools : [],
+ }}
+ >
+ {({ getTriggerProps }) => (
+ <SessionToolStatusCountBadge
+ {...getTriggerProps()}
+ tabIndex={0}
+ aria-label={`Tool group: ${summary}`}
+ count={tools.length}
+ severity={label}
+ variant="timeline"
+ />
+ )}
+ </SessionToolTooltip>
+ );
+ })}
>
<div className="space-y-1">
{rows.map((item) => (
@@ -268,12 +338,17 @@ function SessionTranscriptTool({
trailingContent: ReactNode;
}) {
const [isExpanded, setIsExpanded] = useState(false);
+ const status = getSessionToolStatus({
+ level: row.message.level,
+ statusMessage: row.message.statusMessage,
+ isError: row.result?.isError,
+ });
return (
<SessionTimelineToolRow
name={row.call?.toolName ?? row.result?.toolName ?? "Tool"}
input={row.call?.input}
output={row.result?.output}
- isError={row.result?.isError}
+ {...status}
isExpanded={isExpanded}
onExpandedChange={setIsExpanded}
trailingContent={trailingContent}
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 f99786e9f6..6bdb10b090 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
@@ -7,6 +7,7 @@ export function SessionTimelineCollapsibleRow({
labelActionName,
labelTitle,
searchableLabel,
+ labelTrailingContent,
icon,
isExpanded,
onExpandedChange,
@@ -19,6 +20,7 @@ export function SessionTimelineCollapsibleRow({
labelActionName?: string;
labelTitle?: string;
searchableLabel?: boolean;
+ labelTrailingContent?: ReactNode;
icon?: ReactNode;
onOpenObservation?: () => void;
trailingContent?: ReactNode;
@@ -74,6 +76,7 @@ export function SessionTimelineCollapsibleRow({
{label}
</span>
)}
+ {labelTrailingContent}
{onExpandedChange && (
<button
type="button"
diff --git a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelineToolRow/SessionTimelineToolRow.tsx b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelineToolRow/SessionTimelineToolRow.tsx
index 088356af8d..29662b4cde 100644
--- a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelineToolRow/SessionTimelineToolRow.tsx
+++ b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelineToolRow/SessionTimelineToolRow.tsx
@@ -1,8 +1,11 @@
-import { CircleAlert } from "lucide-react";
+import { Bug, CircleAlert, Info, TriangleAlert } from "lucide-react";
import { type ReactNode } from "react";
import { Codeblock } from "@/src/components/design-system/Codeblock/Codeblock";
import { renderFilterIcon } from "@/src/components/ItemBadge";
import { SessionTimelineCollapsibleRow } from "@/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelineCollapsibleRow/SessionTimelineCollapsibleRow";
+import { cn } from "@/src/utils/tailwind";
+import { SessionToolTooltip } from "@/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionToolTooltip/SessionToolTooltip";
+import { type Observation } from "@langfuse/shared";
const hasPreviewValue = (value: unknown) =>
value !== null && value !== undefined && value !== "";
@@ -13,7 +16,8 @@ export function SessionTimelineToolRow({
output,
isExpanded,
onExpandedChange,
- isError,
+ level,
+ statusMessage,
trailingContent,
}: {
name: string;
@@ -21,9 +25,20 @@ export function SessionTimelineToolRow({
output: unknown;
isExpanded: boolean;
onExpandedChange: (isExpanded: boolean) => void;
- isError?: boolean;
+ level?: Observation["level"];
+ statusMessage?: Observation["statusMessage"];
trailingContent?: ReactNode;
}) {
+ const StatusIcon = level
+ ? (
+ {
+ ERROR: CircleAlert,
+ WARNING: TriangleAlert,
+ DEFAULT: Info,
+ DEBUG: Bug,
+ } satisfies Record<Observation["level"], typeof CircleAlert>
+ )[level]
+ : null;
return (
<SessionTimelineCollapsibleRow
label={name}
@@ -31,14 +46,44 @@ export function SessionTimelineToolRow({
icon={renderFilterIcon("TOOL")}
isExpanded={isExpanded}
onExpandedChange={onExpandedChange}
- trailingContent={
+ trailingContent={trailingContent}
+ labelTrailingContent={
<>
- {trailingContent}
- {isError ? (
- <CircleAlert
- className="icon-sm text-destructive"
- aria-label="Failed"
- />
+ {level &&
+ StatusIcon &&
+ (statusMessage || level === "WARNING" || level === "ERROR") ? (
+ <SessionToolTooltip
+ variant="timeline"
+ content={{
+ type: "status",
+ name,
+ level,
+ message: statusMessage || level,
+ }}
+ >
+ {({ getTriggerProps }) => (
+ <span
+ {...getTriggerProps()}
+ tabIndex={0}
+ aria-label={`Tool status: ${level}`}
+ className={cn(
+ "ml-1 flex shrink-0 items-center",
+ (
+ {
+ ERROR: "text-destructive",
+ WARNING: "text-yellow-600 dark:text-yellow-500",
+ DEFAULT:
+ "text-muted-foreground invisible group-focus-within/collapsible-row:visible group-hover/collapsible-row:visible group-data-[expanded=true]/collapsible-row:visible",
+ DEBUG:
+ "text-muted-foreground invisible group-focus-within/collapsible-row:visible group-hover/collapsible-row:visible group-data-[expanded=true]/collapsible-row:visible",
+ } satisfies Record<Observation["level"], string>
+ )[level],
+ )}
+ >
+ <StatusIcon className="icon-sm" aria-hidden="true" />
+ </span>
+ )}
+ </SessionToolTooltip>
) : null}
</>
}
diff --git a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionObservationStatusMessage/SessionObservationStatusMessage.tsx b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionObservationStatusMessage/SessionObservationStatusMessage.tsx
new file mode 100644
index 0000000000..8b5a8b8ab7
--- /dev/null
+++ b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionObservationStatusMessage/SessionObservationStatusMessage.tsx
@@ -0,0 +1,21 @@
+import { type ComponentProps } from "react";
+import { StatusMessage } from "@/src/components/design-system/StatusMessage/StatusMessage";
+
+type SessionObservationStatusMessageProps = {
+ name: string;
+} & Pick<ComponentProps<typeof StatusMessage>, "level" | "message">;
+
+export function SessionObservationStatusMessage({
+ name,
+ level,
+ message,
+}: SessionObservationStatusMessageProps) {
+ return (
+ <div className="flex flex-col gap-1">
+ <div className="text-muted-foreground text-xs wrap-break-word">
+ {name}
+ </div>
+ <StatusMessage level={level} message={message} size="compact" />
+ </div>
+ );
+}
diff --git a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionToolStatusCountBadge/SessionToolStatusCountBadge.tsx b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionToolStatusCountBadge/SessionToolStatusCountBadge.tsx
new file mode 100644
index 0000000000..f375b8f5a0
--- /dev/null
+++ b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionToolStatusCountBadge/SessionToolStatusCountBadge.tsx
@@ -0,0 +1,41 @@
+import { type ComponentProps } from "react";
+import { CircleAlert, TriangleAlert } from "lucide-react";
+import { BadgeShell } from "@/src/components/design-system/Badge/Badge";
+
+type SessionToolStatusCountBadgeProps = {
+ count: number;
+ severity: "error" | "warning";
+ variant: "timeline" | "sidebar";
+ ref?: ComponentProps<"span">["ref"];
+} & Pick<ComponentProps<typeof BadgeShell>, "aria-label" | "tabIndex">;
+
+export function SessionToolStatusCountBadge({
+ count,
+ severity,
+ variant,
+ ...props
+}: SessionToolStatusCountBadgeProps) {
+ const { color, Icon } = (
+ {
+ error: { color: "red", Icon: CircleAlert },
+ warning: { color: "yellow", Icon: TriangleAlert },
+ } satisfies Record<
+ SessionToolStatusCountBadgeProps["severity"],
+ {
+ color: Extract<
+ ComponentProps<typeof BadgeShell>["color"],
+ "red" | "yellow"
+ >;
+ Icon: typeof CircleAlert;
+ }
+ >
+ )[severity];
+ return (
+ <BadgeShell color={color} size="sm" {...props}>
+ {variant === "sidebar" && <Icon className="icon-sm" aria-hidden="true" />}
+ {variant === "timeline"
+ ? `${count} ${severity}${count === 1 ? "" : "s"}`
+ : count}
+ </BadgeShell>
+ );
+}
diff --git a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionToolTooltip/SessionToolTooltip.tsx b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionToolTooltip/SessionToolTooltip.tsx
new file mode 100644
index 0000000000..dc3d5316b0
--- /dev/null
+++ b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionToolTooltip/SessionToolTooltip.tsx
@@ -0,0 +1,102 @@
+import { type ComponentProps } from "react";
+import { CustomTooltip } from "@/src/components/design-system/CustomTooltip/CustomTooltip";
+import { SessionObservationStatusMessage } from "@/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionObservationStatusMessage/SessionObservationStatusMessage";
+
+type ToolStatus = Pick<
+ ComponentProps<typeof SessionObservationStatusMessage>,
+ "name" | "message"
+>;
+
+type SessionToolTooltipProps = {
+ children: ComponentProps<typeof CustomTooltip>["children"];
+ variant: "sidebar" | "timeline";
+ content:
+ | {
+ type: "group";
+ title: string;
+ errors: readonly ToolStatus[];
+ warnings: readonly ToolStatus[];
+ }
+ | ({ type: "status" } & ComponentProps<
+ typeof SessionObservationStatusMessage
+ >);
+};
+
+export function SessionToolTooltip({
+ children,
+ variant,
+ content,
+}: SessionToolTooltipProps) {
+ const sections =
+ content.type === "group"
+ ? [
+ { severity: "error" as const, tools: content.errors },
+ { severity: "warning" as const, tools: content.warnings },
+ ]
+ : [];
+ return (
+ <CustomTooltip
+ padding="uniform"
+ overflow="scroll"
+ placement={variant === "sidebar" ? "right" : "top"}
+ delay={variant === "sidebar" && content.type === "group" ? 200 : 150}
+ content={
+ <div className="flex flex-col gap-2">
+ {variant === "sidebar" && content.type === "group" && (
+ <>
+ <h4 className="text-sm font-bold">Tool calls</h4>
+ <div className="whitespace-pre-line">{content.title}</div>
+ </>
+ )}
+ {content.type === "status" && (
+ <SessionObservationStatusMessage
+ name={content.name}
+ level={content.level}
+ message={content.message}
+ />
+ )}
+ {sections.map(({ severity, tools }) => {
+ if (tools.length === 0) return null;
+ const presentation = (
+ {
+ error: {
+ label: "Errors",
+ level: "ERROR",
+ },
+ warning: {
+ label: "Warnings",
+ level: "WARNING",
+ },
+ } satisfies Record<
+ typeof severity,
+ {
+ label: string;
+ level: ComponentProps<
+ typeof SessionObservationStatusMessage
+ >["level"];
+ }
+ >
+ )[severity];
+ return (
+ <div key={severity} className="flex flex-col gap-2">
+ {variant === "sidebar" && (
+ <h4 className="text-sm font-bold">{presentation.label}</h4>
+ )}
+ {tools.map(({ name, message }, index) => (
+ <SessionObservationStatusMessage
+ key={index}
+ name={name}
+ level={presentation.level}
+ message={message}
+ />
+ ))}
+ </div>
+ );
+ })}
+ </div>
+ }
+ >
+ {children}
+ </CustomTooltip>
+ );
+}
diff --git a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/fns/getSessionToolStatus.ts b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/fns/getSessionToolStatus.ts
new file mode 100644
index 0000000000..07bd87c4b8
--- /dev/null
+++ b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/fns/getSessionToolStatus.ts
@@ -0,0 +1,19 @@
+import { type Observation } from "@langfuse/shared";
+
+export function getSessionToolStatus({
+ level,
+ statusMessage,
+ isError,
+}: {
+ level: Observation["level"] | undefined;
+ statusMessage: Observation["statusMessage"] | undefined;
+ isError: boolean | undefined;
+}) {
+ if (isError) {
+ return {
+ level: "ERROR" as const,
+ statusMessage: statusMessage || "Tool failed",
+ };
+ }
+ return { level, statusMessage };
+}
diff --git a/web/src/features/traces/components/IOPreview/components/StatusMessageSection.stories.tsx b/web/src/features/traces/components/IOPreview/components/StatusMessageSection.stories.tsx
index f9ae7f4add..7e82873961 100644
--- a/web/src/features/traces/components/IOPreview/components/StatusMessageSection.stories.tsx
+++ b/web/src/features/traces/components/IOPreview/components/StatusMessageSection.stories.tsx
@@ -1,5 +1,6 @@
import preview from "../../../../../../.storybook/preview";
import { StatusMessageSection } from "./StatusMessageSection";
+import { expect } from "storybook/test";
const meta = preview.meta({
component: StatusMessageSection,
@@ -36,6 +37,7 @@ export const Warning = meta.story({
});
export const Error = meta.story({
+ name: "(Test) Renders Error Message",
args: {
currentView: "pretty",
status: {
@@ -43,4 +45,8 @@ export const Error = meta.story({
message: "Upstream model request timed out after 30 seconds.",
},
},
+ play: async ({ canvas, args }) => {
+ await expect(canvas.getByText("Error")).toBeVisible();
+ await expect(canvas.getByText(args.status.message)).toBeVisible();
+ },
});
diff --git a/web/src/features/traces/components/IOPreview/components/StatusMessageSection.tsx b/web/src/features/traces/components/IOPreview/components/StatusMessageSection.tsx
index dc34bfeffa..349a3a77c7 100644
--- a/web/src/features/traces/components/IOPreview/components/StatusMessageSection.tsx
+++ b/web/src/features/traces/components/IOPreview/components/StatusMessageSection.tsx
@@ -1,7 +1,7 @@
import { useMemo } from "react";
import { MarkdownJsonViewHeader } from "@/src/components/ui/MarkdownJsonView";
import { PrettyJsonView } from "@/src/components/ui/PrettyJsonView";
-import { cn } from "@/src/utils/tailwind";
+import { StatusMessage } from "@/src/components/design-system/StatusMessage/StatusMessage";
import { copyTextToClipboard } from "@/src/utils/clipboard";
import {
getStatusMessagePresentation,
@@ -9,18 +9,6 @@ import {
type ObservationStatusMessage,
} from "./statusMessagePresentation";
-const STATUS_MESSAGE_CLASS_NAMES: Record<
- ObservationStatusMessage["level"],
- string
-> = {
- ERROR:
- "border-red-100 bg-red-50 text-red-900 dark:border-dark-red/20 dark:bg-light-red/35 dark:text-red-300",
- WARNING:
- "border-yellow-100 bg-yellow-50 text-yellow-900 dark:border-dark-yellow/20 dark:bg-light-yellow/35 dark:text-yellow-300",
- DEBUG: "bg-surface-output text-foreground-secondary",
- DEFAULT: "bg-surface-output text-foreground-secondary",
-};
-
export function StatusMessageSection({
status,
currentView,
@@ -53,15 +41,11 @@ export function StatusMessageSection({
handleOnCopy={() => copyTextToClipboard(status.message)}
hoverRevealControls
/>
- <div
- className={cn(
- "ph-no-capture rounded-md px-3 py-2 text-base wrap-break-word whitespace-pre-wrap",
- (status.level === "ERROR" || status.level === "WARNING") && "border",
- STATUS_MESSAGE_CLASS_NAMES[status.level],
- )}
- >
- {status.message}
- </div>
+ <StatusMessage
+ level={status.level}
+ message={status.message}
+ size="default"
+ />
</div>
);
}