Skip to content

Review sidebar follow-ups: live refresh and quieter word diffs - #197

Open
stippi wants to merge 4 commits into
mainfrom
fix/review-sidebar-followups
Open

Review sidebar follow-ups: live refresh and quieter word diffs#197
stippi wants to merge 4 commits into
mainfrom
fix/review-sidebar-followups

Conversation

@stippi

@stippi stippi commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-ups to #191 (review sidebar).

  • Stale diffs while the agent edits. The panel only listed changes when opened or on session switch, and never re-requested a diff for a file still in the listing. Now:
    • git::ChangedFile carries a fingerprint (blob ids via diff --raw in branch mode; HEAD + mtime/size of the working-tree file otherwise). The view re-requests only diffs whose listing entry changed, keeping the old hunks on screen until the replacement arrives.
    • New git::ChangeWatcher: a recursive notify watch per listed repo (plus the private/common git dirs of linked worktrees), debounced, with Zed's .git event filter so object/hook/reflog/lock/temp churn never triggers a rescan. The ReviewView owns it while it has a listing; closing the panel or switching sessions detaches it. Window activation reloads as a safety net.
  • Word-level diff emphasis. A line whose emphasis would cover more than half of its non-whitespace bytes is shown as a plain change instead (rewritten prose paragraphs previously lit up every other word). Emphasis ranges separated only by whitespace are merged. Line cap per side follows Zed (8).

Test plan

  • cargo test -p git -p ui_gpui (new tests: fingerprint tracking in both modes, raw-diff parser, .git filter rules, git-dir detection incl. linked worktrees, watcher integration test, word-diff heuristics)
  • cargo clippy --all-targets --all-features -- -D warnings, cargo fmt --check
  • Manual: open the review sidebar, let the agent edit a listed file, diff updates without reopening
  • Manual: long prose paragraph with a small edit keeps word emphasis; a rewritten paragraph shows as a plain line change

Trim MCP client, permission tiers and UI communication sections to the
essentials and point to the existing docs. Drop sections duplicated by
the crate layer diagram and key entry points. Move the GPUI API primer
(copied from Zed's .rules) into docs/gpui-reference.md, keeping only the
deprecated-API rules in AGENTS.md.
The review panel only listed changes when it was opened or the session
switched, and a prepared diff for a file still in the listing was never
re-requested — so diffs went stale as soon as the agent kept editing.

- git: ChangedFile gains a fingerprint (blob ids in branch mode via
  `diff --raw`; HEAD + mtime/size of the working-tree file otherwise)
- ui_gpui: Gpui::files_changed_generation is bumped after every finished
  tool and at the end of a turn; the ReviewView re-lists (debounced) and
  re-requests only diffs whose listing entry changed, keeping the old
  hunks on screen until the replacement arrives
Replace the tool-end trigger with git::ChangeWatcher: a recursive
notify watch on each listed repo (plus the private and common git dirs
of linked worktrees), debounced, with Zed's .git filter so object,
hook, reflog, lock and temp-file churn never triggers a rescan. The
ReviewView owns the watcher while it has a listing; closing the panel
or switching sessions detaches it. Window activation reloads as a
safety net for what a watcher can miss.
Two changes to the intra-line word diff:

- Drop a line's emphasis when it would cover more than half of the
  line's non-whitespace bytes. Rewritten prose paragraphs share enough
  common words to pass similar's ratio cutoff, yet the result lit up
  every other word and stray spaces; a mostly rewritten line now shows
  as a plain change. A small edit inside a long paragraph keeps its
  emphasis — length is not the criterion.
- Merge emphasis ranges separated only by whitespace, so two changed
  words with an unchanged space between them highlight as one.

The line cap follows Zed (8 per side).
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