🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat(corrections): add global toggle for showing corrections in session and IOPreview components (#11522)
marliessophiea2b3ab9b93d1
diff --git a/web/src/components/session/TraceRow.tsx b/web/src/components/session/TraceRow.tsxindex f4e829bb9f..ab14e25e21 100644--- a/web/src/components/session/TraceRow.tsx+++ b/web/src/components/session/TraceRow.tsx@@ -35,11 +35,13 @@ const TraceRow = React.memo(projectId,openPeek,traceCommentCounts,+ showCorrections,}: {trace: RouterOutputs["sessions"]["byIdWithScores"]["traces"][number];projectId: string;openPeek: (id: string, row: any) => void;traceCommentCounts: Map<string, number> | undefined;+ showCorrections: boolean;}) => {return (<Card className="border-border shadow-none">@@ -49,6 +51,7 @@ const TraceRow = React.memo(traceId={trace.id}projectId={projectId}timestamp={new Date(trace.timestamp)}+ showCorrections={showCorrections}/></div><div className="hidden bg-border md:block"></div>@@ -165,10 +168,11 @@ export const LazyTraceRow = React.forwardRef<openPeek: (id: string, row: any) => void;index: number;traceCommentCounts: Map<string, number> | undefined;+ showCorrections: boolean;onLoad?: (index: number) => void;}>((props, measureRef) => {- const { index, onLoad: onLoad, ...cardProps } = props;+ const { index, onLoad: onLoad, showCorrections, ...cardProps } = props;const [shouldLoad, setShouldLoad] = useState(false);const internalRef = useRef<HTMLDivElement>(null);@@ -196,7 +200,11 @@ export const LazyTraceRow = React.forwardRef<return (<div ref={combinedRef} className="pb-3">- {shouldLoad ? <TraceRow {...cardProps} /> : <TraceSkeleton />}+ {shouldLoad ? (+ <TraceRow showCorrections={showCorrections} {...cardProps} />+ ) : (+ <TraceSkeleton />+ )}</div>);});diff --git a/web/src/components/session/index.tsx b/web/src/components/session/index.tsxindex 956131b0b4..04212b25dd 100644--- a/web/src/components/session/index.tsx+++ b/web/src/components/session/index.tsx@@ -36,6 +36,8 @@ import { usePeekNavigation } from "@/src/components/table/peek/hooks/usePeekNaviimport { type WithStringifiedMetadata } from "@/src/utils/clientSideDomainTypes";import { LazyTraceRow } from "@/src/components/session/TraceRow";import { useParsedTrace } from "@/src/hooks/useParsedTrace";+import useLocalStorage from "@/src/components/useLocalStorage";+import { Switch } from "@/src/components/ui/switch";// some projects have thousands of users in a session, paginate to avoid rendering all at onceconst INITIAL_USERS_DISPLAY_COUNT = 10;@@ -171,6 +173,11 @@ export const SessionPage: React.FC<{},);+ const [showCorrections, setShowCorrections] = useLocalStorage(+ "showCorrections",+ false,+ );+const sessionComments = api.comments.getByObjectId.useQuery({projectId,objectId: sessionId,@@ -369,6 +376,16 @@ export const SessionPage: React.FC<{variant="outline"/></div>+ <div className="flex items-center">+ <Switch+ checked={showCorrections}+ onCheckedChange={setShowCorrections}+ className="scale-75"+ />+ <span className="text-xs text-muted-foreground">+ Show corrections+ </span>+ </div></>),}}@@ -419,6 +436,7 @@ export const SessionPage: React.FC<{openPeek={openPeek}traceCommentCounts={traceCommentCounts.data}index={virtualItem.index}+ showCorrections={showCorrections}onLoad={() => {// Force virtualizer to remeasure this specific itemvirtualizer.measureElement(@@ -454,10 +472,12 @@ export const SessionIO = ({traceId,projectId,timestamp,+ showCorrections,}: {traceId: string;projectId: string;timestamp: Date;+ showCorrections: boolean;}) => {const trace = api.traces.byId.useQuery({ traceId, projectId, timestamp },@@ -499,6 +519,7 @@ export const SessionIO = ({projectId={projectId}traceId={traceId}environment={trace.data.environment}+ showCorrections={showCorrections}/>) : (<div className="p-2 text-xs text-muted-foreground">diff --git a/web/src/components/trace2/components/IOPreview/IOPreview.tsx b/web/src/components/trace2/components/IOPreview/IOPreview.tsxindex e68931b551..a99a752c45 100644--- a/web/src/components/trace2/components/IOPreview/IOPreview.tsx+++ b/web/src/components/trace2/components/IOPreview/IOPreview.tsx@@ -61,6 +61,7 @@ export interface IOPreviewProps extends ExpansionStateProps {projectId: string;traceId: string;environment?: string;+ showCorrections?: boolean;}/**@@ -106,6 +107,7 @@ export function IOPreview({projectId,traceId,environment = "default",+ showCorrections = true,}: IOPreviewProps) {const capture = usePostHogClientCapture();const [dismissedTraceViewNotifications, setDismissedTraceViewNotifications] =@@ -158,6 +160,7 @@ export function IOPreview({projectId,traceId,environment,+ showCorrections,};// Only show empty state popup for traces (not observations) when there's no input/output@@ -215,6 +218,7 @@ export function IOPreview({projectId={projectId}traceId={traceId}environment={environment}+ showCorrections={showCorrections}/>) : selectedView === "json" ? (<IOPreviewJSONSimple {...sharedProps} />diff --git a/web/src/components/trace2/components/IOPreview/IOPreviewJSON.tsx b/web/src/components/trace2/components/IOPreview/IOPreviewJSON.tsxindex acc4b1a34a..8a92f3abe8 100644--- a/web/src/components/trace2/components/IOPreview/IOPreviewJSON.tsx+++ b/web/src/components/trace2/components/IOPreview/IOPreviewJSON.tsx@@ -52,6 +52,7 @@ export interface IOPreviewJSONProps extends ExpansionStateProps {projectId: string;traceId: string;environment?: string;+ showCorrections?: boolean;}/**@@ -84,6 +85,7 @@ function IOPreviewJSONInner({projectId,traceId,environment = "default",+ showCorrections = true,}: IOPreviewJSONProps) {const selectionContext = useInlineCommentSelectionOptional();@@ -428,14 +430,16 @@ function IOPreviewJSONInner({) : (viewerContent)}- <CorrectedOutputField- actualOutput={parsedOutput}- existingCorrection={outputCorrection}- observationId={observationId}- projectId={projectId}- traceId={traceId}- environment={environment}- />+ {showCorrections && (+ <CorrectedOutputField+ actualOutput={parsedOutput}+ existingCorrection={outputCorrection}+ observationId={observationId}+ projectId={projectId}+ traceId={traceId}+ environment={environment}+ />+ )}</div></div>);diff --git a/web/src/components/trace2/components/IOPreview/IOPreviewJSONSimple.tsx b/web/src/components/trace2/components/IOPreview/IOPreviewJSONSimple.tsxindex 556dc2eca7..e849421db6 100644--- a/web/src/components/trace2/components/IOPreview/IOPreviewJSONSimple.tsx+++ b/web/src/components/trace2/components/IOPreview/IOPreviewJSONSimple.tsx@@ -24,6 +24,7 @@ export interface IOPreviewJSONSimpleProps extends ExpansionStateProps {projectId: string;traceId: string;environment?: string;+ showCorrections?: boolean;}/**@@ -57,6 +58,7 @@ export function IOPreviewJSONSimple({projectId,traceId,environment = "default",+ showCorrections = true,}: IOPreviewJSONSimpleProps) {// Parse data if not pre-parsed// IMPORTANT: Don't parse while isParsing=true to avoid double-parsing with different object references@@ -107,14 +109,16 @@ export function IOPreviewJSONSimple({onExternalExpansionChange={onOutputExpansionChange}/>)}- <CorrectedOutputField- actualOutput={effectiveOutput}- existingCorrection={outputCorrection}- observationId={observationId}- projectId={projectId}- traceId={traceId}- environment={environment}- />+ {showCorrections && (+ <CorrectedOutputField+ actualOutput={effectiveOutput}+ existingCorrection={outputCorrection}+ observationId={observationId}+ projectId={projectId}+ traceId={traceId}+ environment={environment}+ />+ )}{showMetadata && (<PrettyJsonViewtitle="Metadata"diff --git a/web/src/components/trace2/components/IOPreview/IOPreviewPretty.tsx b/web/src/components/trace2/components/IOPreview/IOPreviewPretty.tsxindex 3508c16c69..328f511758 100644--- a/web/src/components/trace2/components/IOPreview/IOPreviewPretty.tsx+++ b/web/src/components/trace2/components/IOPreview/IOPreviewPretty.tsx@@ -3,7 +3,6 @@ import { type Prisma, type ScoreDomain, deepParseJson } from "@langfuse/shared";import { PrettyJsonView } from "@/src/components/ui/PrettyJsonView";import { MARKDOWN_RENDER_CHARACTER_LIMIT } from "@/src/utils/constants";import { type MediaReturnType } from "@/src/features/media/validation";-import { useChatMLParser } from "./hooks/useChatMLParser";import { ChatMessageList } from "./components/ChatMessageList";import { SectionToolDefinitions } from "./components/SectionToolDefinitions";@@ -98,6 +97,7 @@ export interface IOPreviewPrettyProps extends ExpansionStateProps {projectId: string;traceId: string;environment?: string;+ showCorrections?: boolean;}/**@@ -136,6 +136,7 @@ export function IOPreviewPretty({projectId,traceId,environment = "default",+ showCorrections = true,}: IOPreviewPrettyProps) {// Use pre-parsed data if available (from useParsedObservation hook),// otherwise parse with size/depth limits to prevent UI freeze@@ -255,19 +256,7 @@ export function IOPreviewPretty({messageToToolCallNumbers={messageToToolCallNumbers}inputMessageCount={inputMessageCount}/>- <CorrectedOutputField- actualOutput={parsedOutput}- existingCorrection={outputCorrection}- observationId={observationId}- projectId={projectId}- traceId={traceId}- environment={environment}- />- </div>- ) : (- <>- <JsonInputOutputView {...jsonViewProps} />- <div className="[&_.io-message-content]:px-2 [&_.io-message-header]:px-2">+ {showCorrections && (<CorrectedOutputFieldactualOutput={parsedOutput}existingCorrection={outputCorrection}@@ -276,6 +265,22 @@ export function IOPreviewPretty({traceId={traceId}environment={environment}/>+ )}+ </div>+ ) : (+ <>+ <JsonInputOutputView {...jsonViewProps} />+ <div className="[&_.io-message-content]:px-2 [&_.io-message-header]:px-2">+ {showCorrections && (+ <CorrectedOutputField+ actualOutput={parsedOutput}+ existingCorrection={outputCorrection}+ observationId={observationId}+ projectId={projectId}+ traceId={traceId}+ environment={environment}+ />+ )}</div></>)}diff --git a/web/src/components/trace2/components/IOPreview/components/CorrectedOutputField.tsx b/web/src/components/trace2/components/IOPreview/components/CorrectedOutputField.tsxindex 4640d03392..4dc492fc74 100644--- a/web/src/components/trace2/components/IOPreview/components/CorrectedOutputField.tsx+++ b/web/src/components/trace2/components/IOPreview/components/CorrectedOutputField.tsx@@ -152,7 +152,7 @@ export function CorrectedOutputField({onClick={handleEdit}disabled={!hasAccess}className={cn(- "w-full cursor-pointer rounded-md border px-3 py-8 text-center text-sm text-muted-foreground transition-colors hover:bg-muted/50",+ "w-full cursor-pointer rounded-md border px-3 py-4 text-center text-xs text-muted-foreground transition-colors hover:bg-muted/50",)}>Click to add corrected outputdiff --git a/web/src/features/annotation-queues/components/processors/SessionAnnotationProcessor.tsx b/web/src/features/annotation-queues/components/processors/SessionAnnotationProcessor.tsxindex f013d0312b..160b60d7fe 100644--- a/web/src/features/annotation-queues/components/processors/SessionAnnotationProcessor.tsx+++ b/web/src/features/annotation-queues/components/processors/SessionAnnotationProcessor.tsx@@ -126,6 +126,7 @@ export const SessionAnnotationProcessor: React.FC<traceId={trace.id}projectId={projectId}timestamp={trace.timestamp}+ showCorrections/></Card>))}