Skip to content

Diff Review

Every LLM-issued code change flows through DiffReviewService. Line-level LCS diff, hunks with 3 lines of context, per-hunk accept/reject, undo history.

When a change is proposed:

  1. Compute longest common subsequence diff between original + proposed.
  2. Group consecutive changes into hunks with 3 lines of context.
  3. Present via custom TextDocumentContentProvider (scheme: codebuddy-diff).
  4. Track for undo.

50-change undo history.

ActionEffect
Accept allApply every proposed change across all files
Accept fileApply for one file only
Accept hunkApply a single hunk, leave others pending
RejectDiscard all changes
EditModify the proposed changes before applying

Hunks render: added lines green, removed lines red, 3 lines context above and below.

{ "codebuddy.autoApprove": true }

Auto-approve applies to safe operations (reads, searches, diagnostics). Write operations still show diffs unless codebuddy.requireDiffApproval is false.

Review Selected Code + PR reviews annotate files inline via VS Code’s Comments API. InlineReviewService parses the LLM’s review output into severity-colored gutter annotations.

Severity:

SeverityIconMeaning
Critical🔴Security vulnerability, data loss risk, crash
Moderate🟡Logic error, perf issue, bad practice
Minor🔵Style, naming, minor improvement
Infoℹ️Suggestion, alternative approach

Comments are read-only — informational. No reply widget.

Two-pass parser:

  1. JSON extraction — looks for a REVIEW_COMMENTS JSON block in the LLM output.
  2. Markdown fallback — parses markdown headers with severity indicators (🔴 / 🟡 / 🔵 emojis or “Critical Issues” / “Moderate Issues” headers).

Stops at non-issue sections (strengths, recommendations, optimizations) to avoid false positives.

Cap: 500 threads total to keep the editor responsive on large reviews.

Settings:

SettingDefaultPurpose
codebuddy.review.inlineCommentstrueEnable inline thread annotations

Commands:

  • Clear Inline Review Comments — remove all threads.

Review Pull Request command:

  1. Detect changes — identify modified files vs. base branch.
  2. Base branch selection — auto-detect or prompt.
  3. Diff generation — compute diffs for all changed files.
  4. LLM review — send diff with a review-specific prompt.
  5. Inline annotations — appear as threads (when enabled).
  6. Summary — high-level summary in the chat panel.

The PR review prompt structures the diff for optimal LLM analysis (file paths, change types, surrounding context).

CodeBuddy: Undo Last Changes

Or built-in Cmd/Ctrl+Z for individual file undos. The diff service emits added / applied / rejected events that other services subscribe to for audit logging.

  • Composer — atomic multi-file edits that go through diff review
  • Security — invariant that every LLM-controlled path is diff-reviewed