Skip to content

fix(vscode): keep binary diffs collapsed - #11151

Merged
marius-kilocode merged 1 commit into
mainfrom
fix/vscode-binary-diffs
Jun 12, 2026
Merged

fix(vscode): keep binary diffs collapsed#11151
marius-kilocode merged 1 commit into
mainfrom
fix/vscode-binary-diffs

Conversation

@marius-kilocode

@marius-kilocode marius-kilocode commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Binary and audio changes currently appear as expandable rows even though the review surface has no text content to render. Expanding them creates large empty panels and makes bulk expand actions include files that cannot be reviewed as text.

Use Git's binary classification for tracked files and a bounded content sample for untracked files, without relying on filename extensions. Binary entries remain visible for file actions, but the inline and full-screen review surfaces omit their chevron, exclude them from open state and bulk expansion, and avoid requesting or materializing text detail. Large text summaries remain expandable and continue loading on demand.

Before:
file-4c8d80f237fbd371495953ced9b7a500

After:
file-2e66534324dbd603241abba77b51e3d8

@kilo-code-bot

kilo-code-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (13 files)
  • .changeset/quiet-binary-diffs.md
  • packages/kilo-vscode/src/diff/shared/binary.ts
  • packages/kilo-vscode/src/agent-manager/local-diff.ts
  • packages/kilo-vscode/src/diff/sources/git-status.ts
  • packages/kilo-vscode/src/diff/sources/session.ts
  • packages/kilo-vscode/src/diff/sources/staged.ts
  • packages/kilo-vscode/src/diff/sources/unstaged.ts
  • packages/kilo-vscode/webview-ui/diff-viewer/diff-open-policy.ts
  • packages/kilo-vscode/webview-ui/agent-manager/DiffPanel.tsx
  • packages/kilo-vscode/webview-ui/diff-viewer/FullScreenDiffView.tsx
  • packages/kilo-vscode/tests/unit/agent-manager-diff-state.test.ts
  • packages/kilo-vscode/tests/unit/diff-session-source.test.ts
  • packages/kilo-vscode/tests/unit/local-diff.test.ts

Notes

The implementation is clean, well-reasoned, and consistent across all diff sources:

  • binary.ts: File handle is properly closed via .finally(() => handle.close()) — no resource leak. The null-byte heuristic mirrors git's own binary detection. Limiting the sample to 8 KB is appropriate.
  • local-diff.ts: Meta gains a binary flag; summarize() maps it to summarized: !meta.binary, so binary entries get summarized: false with empty content. diffFile short-circuits before the OOM-guard size probe — correct ordering.
  • git-status.ts / staged.ts / unstaged.ts: parseNumstat now surfaces binary from the -/- sentinel in git's numstat output. Both list and single-file entry paths propagate the flag. Untracked files use binaryFile() for content-based detection.
  • session.ts: The summarized logic fix (raw.patch === "" && (raw.additions !== 0 || raw.deletions !== 0)) correctly distinguishes binary files (zero stats + empty patch → summarized: false) from large-file summaries (nonzero stats + empty patch → summarized: true).
  • diff-open-policy.ts: isDiffExpandable guard (diff.summarized === true || Boolean(diff.patch || diff.before || diff.after)) blocks binary entries (all fields empty/falsy, summarized: false) while preserving large-file summary behavior. sanitizeOpenFiles is applied at all entry points: onChange, poll-driven setOpen, and initialOpenFiles.
  • binary field scoping: Correctly kept internal — DiffFile and WorktreeFileDiff (the webview type) never expose it. Binary state is encoded purely through the summarized/content fields that cross the extension↔webview boundary.
  • Tests: Cover untracked binary by content (not extension), tracked binary via git numstat, session binary via zero-stat empty patch, and the isDiffExpandable/sanitizeOpenFiles unit tests.

Reviewed by claude-4.6-sonnet-20260217 · 1,386,475 tokens

Review guidance: REVIEW.md from base branch main

@marius-kilocode
marius-kilocode force-pushed the fix/vscode-binary-diffs branch from 94beb68 to 77fe7c9 Compare June 12, 2026 08:26
@marius-kilocode
marius-kilocode merged commit 84a62a1 into main Jun 12, 2026
21 checks passed
@marius-kilocode
marius-kilocode deleted the fix/vscode-binary-diffs branch June 12, 2026 08:40
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants