Skip to content

feat(review): diff scopes, lazy per-file patches, split/wrap/whitespace toggles, syntax colour (#1493 C) - #1500

Merged
currentbits merged 4 commits into
mainfrom
coder/1493-c-better-diffs-b75d42
Oct 6, 2026
Merged

currentbits merged 4 commits into
mainfrom
coder/1493-c-better-diffs-b75d42

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Item C of #1493.

What changed

  • Scope toggle in Changes: Uncommitted / Whole branch / This turn, remembered per thread.
  • No more 100 KB cut:
    • numstat comes back for every file, and whole-file patches up to the old budget arrive inline. The rest load per file when expanded.
    • A file over 60k chars shows "Large diff" with Show anyway (up to 1 MB).
    • No file is ever cut mid-file.
  • Toggles: Split (now one setting shared with the turn panel), Wrap, and Ignore whitespace (git diff -w). All persist.
  • Syntax colour: diff lines in Changes and the turn panel, plus markdown code blocks. highlight.js core with 19 languages lives in its own lazy ~100 kB chunk. Big files are coloured in idle slices, and colours come from the theme variables in light and dark.
  • IPC: git.diff input widened; no new channel.

Verified independently, on main merged with this branch and #1498:

  • typecheck exits 0 and vite build passes. The main chunk is 1,068 kB; the highlighter isn't in it.
  • test:renderer passes 2785 of 2785.
  • test:electron passes 4194 of 4194, including 4 new real-git tests for the scopes, -w and large files with the path-escape check.
  • Screenshots reviewed: Uncommitted unified and Whole branch split, light and dark.

Known limits

  • Highlighting is per line, so multi-line comments and strings only colour their first line.
  • Ignore whitespace can re-surface hunks already marked reviewed, because the marks key on hunk text.
  • On SSH projects, This turn is empty and Whole branch compares against origin/HEAD.

🤖 Generated with Claude Code

Willem and others added 4 commits October 6, 2026 15:42
…-file patches

git.diff takes scope/ignoreWhitespace/path/full. Branch diffs the merge
base with the thread's base to the working tree; turn reuses the newest
checkpoint range. The list patch keeps whole files up to the old 100k
budget and flags the rest (large: over the 60k per-file cap, lazy: past
the budget) so the pane can fetch them one at a time (#1493).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…and syntax colour in Changes

The Git pane reviews Uncommitted, Whole branch or This turn, remembered
per thread; staging, discard and commit stay on Uncommitted. Files whose
patch was left out of the list payload load when opened, or behind Show
anyway when large. Split, Wrap and Ignore whitespace persist globally.
Diff lines and markdown code blocks are coloured by highlight.js core,
loaded as its own chunk and filled in idle slices (#1493).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T14:06:56.074930Z d280908 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d28090877c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

*/
function budgetPatch(patch) {
const omitted = new Map();
if (patch.length <= PATCH_TRUNCATE) return { patch, omitted };

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Enforce the per-file cap before returning the full patch

When the combined patch is at most 100 KB but one file exceeds the 60 KB per-file cap, this early return bypasses the chunk inspection entirely. For example, a single 63 KB file is returned inline without patchOmitted: "large", so the renderer eagerly parses and highlights it instead of showing the intended “Large diff” gate. Apply the per-file cap regardless of whether the total patch exceeds PATCH_TRUNCATE.

Useful? React with 👍 / 👎.

// Porcelain status for all entries; -uall lists untracked files
// individually instead of collapsing whole directories into "?? dir/".
// raw: the 2-char XY column starts with a significant space.
const porcelain = await gitOutForDiffAsync(project, cwd, ["status", "--porcelain", "-uall"], {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Filter tracked status entries when ignoring whitespace

In the local-worktree Uncommitted scope, a tracked file whose only change is whitespace is still inserted from unconditional git status output even though the subsequent git diff -w patch and numstat are empty. I reproduced a whitespace-only edit returning one M file with 0 additions, 0 deletions, and an empty patch, so the “Ignore whitespace” view remains nonempty and shows “No textual diff” rather than hiding the change.

Useful? React with 👍 / 👎.

// XY PATH or XY ORIG -> PATH for renames
const status = line.slice(0, 2).trim() || line.slice(0, 1);
// Branch scope takes tracked letters from name-status below.
if (scope === "branch" && status !== "??") continue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Synthesize patches for untracked files in branch scope

In the local-worktree Whole branch scope, this explicitly retains untracked files, but every patch request still uses git diff, which does not include untracked contents. I reproduced a branch containing only new.txt returning the file row with an empty patch; selecting it shows “No textual diff,” and the per-file request is also empty. Either generate a /dev/null patch for these entries or mark them for a fetch path that reads their contents so newly created files can actually be reviewed.

Useful? React with 👍 / 👎.

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.

1 participant