From 2fb9fe6d35abe9129cc57a0bc1a4a6297cc19e4d Mon Sep 17 00:00:00 2001 From: Val Alexander Date: Tue, 31 Mar 2026 23:39:41 -0500 Subject: [PATCH 1/2] Remove per-file diff context toggle - Drop stored patch/full context mode from diff review state - Simplify diff panel rendering to always use patch context - Update review-state tests for the slimmer state shape --- apps/web/src/components/DiffPanel.tsx | 113 +------------------ apps/web/src/lib/diffFileReviewState.test.ts | 57 +++------- apps/web/src/lib/diffFileReviewState.ts | 22 ---- 3 files changed, 14 insertions(+), 178 deletions(-) diff --git a/apps/web/src/components/DiffPanel.tsx b/apps/web/src/components/DiffPanel.tsx index 211df4ef2..d9bb00067 100644 --- a/apps/web/src/components/DiffPanel.tsx +++ b/apps/web/src/components/DiffPanel.tsx @@ -16,7 +16,6 @@ import { buildPatchCacheKey } from "../lib/diffRendering"; import { expandDiffFile, reconcileDiffFileReviewState, - setDiffFileContextMode, toggleDiffFileAccepted, toggleDiffFileCollapsed, type DiffFileReviewStateByPath, @@ -168,92 +167,33 @@ function summarizeFileDiffStats(fileDiff: FileDiffMetadata): { ); } -function resolveRenderableFileDiff( - renderablePatch: RenderablePatch | null, - filePath: string, -): FileDiffMetadata | null { - if (!renderablePatch || renderablePatch.kind !== "files") { - return null; - } - return ( - renderablePatch.files.find((candidate) => resolveFileDiffPath(candidate) === filePath) ?? null - ); -} - -interface FileScopedCheckpointDiffInput { - threadId: ThreadId | null; - fromTurnCount: number | null; - toTurnCount: number | null; - cacheScope?: string | null; - enabled: boolean; -} - function DiffFileSection(props: { fileDiff: FileDiffMetadata; filePath: string; fileKey: string; - checkpointDiffInput: FileScopedCheckpointDiffInput; diffRenderMode: DiffRenderMode; diffWordWrap: boolean; resolvedTheme: "light" | "dark"; collapsed: boolean; accepted: boolean; - contextMode: "patch" | "full"; onOpenInEditor: (filePath: string) => void; onToggleCollapsed: (filePath: string) => void; onToggleAccepted: (filePath: string) => void; - onContextModeChange: (filePath: string, contextMode: "patch" | "full") => void; }) { const { accepted, - checkpointDiffInput, collapsed, - contextMode, diffRenderMode, diffWordWrap, fileDiff, fileKey, filePath, - onContextModeChange, onOpenInEditor, onToggleAccepted, onToggleCollapsed, resolvedTheme, } = props; const stats = summarizeFileDiffStats(fileDiff); - const fullContextDiffQuery = useQuery( - checkpointDiffQueryOptions({ - ...checkpointDiffInput, - relativePath: filePath, - contextMode: "full", - enabled: checkpointDiffInput.enabled && !collapsed && contextMode === "full", - }), - ); - const fullContextPatch = useMemo( - () => - getRenderablePatch( - contextMode === "full" ? fullContextDiffQuery.data?.diff : undefined, - `diff-panel:file:${resolvedTheme}:${filePath}:full`, - ), - [contextMode, filePath, fullContextDiffQuery.data?.diff, resolvedTheme], - ); - const fullContextFileDiff = - contextMode === "full" ? resolveRenderableFileDiff(fullContextPatch, filePath) : null; - const resolvedFileDiff = contextMode === "full" ? (fullContextFileDiff ?? fileDiff) : fileDiff; - const fullContextError = - contextMode === "full" && fullContextDiffQuery.error - ? fullContextDiffQuery.error instanceof Error - ? fullContextDiffQuery.error.message - : "Failed to load full-file context." - : null; - const fullContextFallbackMessage = - contextMode === "full" && - !fullContextError && - !fullContextDiffQuery.isLoading && - fullContextDiffQuery.data && - fullContextFileDiff === null - ? "Full-file context is unavailable for this file. Showing patch context." - : null; return (
)} - { - const next = value[0]; - if (next === "patch" || next === "full") { - onContextModeChange(filePath, next); - } - }} - > - - Patch - - - Full - -