From bd4d85229e82dd3ddd26e490e0b8536b0b54cb26 Mon Sep 17 00:00:00 2001 From: Marius Date: Wed, 15 Apr 2026 12:46:09 +0200 Subject: [PATCH] perf(vscode): exclude patch from diff hash to reduce memory overhead (#8967) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * perf(vscode): exclude patch from diff hash to reduce memory overhead The hashFileDiffs function included diff.patch in its hash key, pulling in multi-MB payloads generated by opencode's context: MAX_SAFE_INTEGER setting. The extension never renders the patch string — VS Code's native diff editor uses before/after file contents instead — so the field was pure overhead. Closes #8951 * chore(kilo-docs): update source links --- packages/kilo-docs/source-links.md | 4 +++- packages/kilo-vscode/src/review-utils.ts | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/kilo-docs/source-links.md b/packages/kilo-docs/source-links.md index 6ba0ad51c3..03b016912c 100644 --- a/packages/kilo-docs/source-links.md +++ b/packages/kilo-docs/source-links.md @@ -1,7 +1,7 @@ # Source Code Links - + - @@ -55,6 +55,8 @@ - +- + - - diff --git a/packages/kilo-vscode/src/review-utils.ts b/packages/kilo-vscode/src/review-utils.ts index e5c56a3b28..6dadb3b0a6 100644 --- a/packages/kilo-vscode/src/review-utils.ts +++ b/packages/kilo-vscode/src/review-utils.ts @@ -42,6 +42,19 @@ export async function resolveLocalDiffTarget( return { directory: root, baseBranch: base } } +/** + * Produces a lightweight hash key for a list of file diffs. + * + * Intentionally excludes `diff.patch` — the extension never renders the + * unified-diff patch string (VS Code's native diff editor uses before/after + * file contents instead). Including it would pull in multi-MB payloads + * generated by opencode's `context: MAX_SAFE_INTEGER` setting, inflating + * memory for no benefit. The remaining fields (file, status, additions, + * deletions, tracked, generatedLike, summarized, stamp) are sufficient to + * detect when the diff list has meaningfully changed. + * + * See: https://github.com/Kilo-Org/kilocode/issues/8951 + */ export function hashFileDiffs( diffs: Array< SnapshotFileDiff & { @@ -54,7 +67,6 @@ export function hashFileDiffs( ): string { return diffs .map((diff) => { - const content = diff.summarized ? "" : diff.patch return [ diff.file, diff.status, @@ -64,7 +76,6 @@ export function hashFileDiffs( diff.generatedLike ? "generated" : "source", diff.summarized ? "summary" : "detail", diff.stamp ?? "", - content, ].join(":") }) .join("|")