From db3b9e08075f9d08598e27c522bee88258494161 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 19 Feb 2026 04:41:38 +0000 Subject: [PATCH] Fix redundant truthiness check and misleading incremental diff fallback - Remove redundant 'checkpointCwd &&' guard in revertToCheckpoint (providerManager.ts:323) since checkpointCwd is guaranteed truthy after the throw on lines 310-313. - Remove latestPatchByPath deduplication fallback in DiffPanel.tsx that kept only the most recent turn's per-file incremental diff, which was misleading for files changed across multiple turns. The per-turn patchForSummary fallback (which prefers cached checkpoint diffs) now handles the case, showing all turns' changes. --- apps/server/src/providerManager.ts | 2 +- apps/web/src/components/DiffPanel.tsx | 25 ++----------------------- 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/apps/server/src/providerManager.ts b/apps/server/src/providerManager.ts index 532f32f7fa..992e4eef18 100644 --- a/apps/server/src/providerManager.ts +++ b/apps/server/src/providerManager.ts @@ -320,7 +320,7 @@ export class ProviderManager extends EventEmitter { ); } - if (checkpointCwd && input.turnCount > 0) { + if (input.turnCount > 0) { const hasCheckpoint = await this.filesystemCheckpointStore.hasCheckpoint({ cwd: checkpointCwd, threadId: beforeSnapshot.threadId, diff --git a/apps/web/src/components/DiffPanel.tsx b/apps/web/src/components/DiffPanel.tsx index 6cf7b61ced..4688d728e5 100644 --- a/apps/web/src/components/DiffPanel.tsx +++ b/apps/web/src/components/DiffPanel.tsx @@ -241,29 +241,8 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) { } // Fallback when a conversation checkpoint diff isn't available yet: - // keep one patch per file path (latest change wins) so files aren't duplicated. - const latestPatchByPath = new Map(); - for (const summary of turnDiffSummaries) { - for (const file of summary.files) { - if (latestPatchByPath.has(file.path)) { - continue; - } - const patch = file.diff?.trim(); - if (!patch) { - continue; - } - latestPatchByPath.set(file.path, patch); - } - } - if (latestPatchByPath.size > 0) { - return Array.from(latestPatchByPath.entries()) - .toSorted(([leftPath], [rightPath]) => - leftPath.localeCompare(rightPath, undefined, { numeric: true, sensitivity: "base" }), - ) - .map(([, patch]) => patch) - .join("\n\n"); - } - + // show each turn's diff (oldest first) via patchForSummary, which prefers + // cached checkpoint diffs when available. const patches = turnDiffSummaries .toReversed() .map((summary) => patchForSummary(summary)?.trim())