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.

Default behavior: changes auto-apply and are recorded as reviewable diffs — the per-hunk accept/reject gate is not active out of the box. Set codebuddy.requireDiffApproval: true to require explicit approval before any write lands; the accept/reject UI below then gates every change. Either way, changes stay undoable.

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 }

codebuddy.autoApprove governs whether the agent pauses for confirmation before a tool call. It’s separate from diff review: whether a write lands without an accept/reject step is controlled by codebuddy.requireDiffApproval (default false → writes auto-apply; set true to gate each change behind the hunk UI).

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).

Restore a prior turn from the chat UI (Checkpoints), or use VS Code’s 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