Skip to content

feat(review): say in the footer when the diff changed on disk - #170

Merged
backnotprop merged 1 commit into
mainfrom
feat/review-disk-notice
Nov 20, 2026
Merged

backnotprop merged 1 commit into
mainfrom
feat/review-disk-notice

Conversation

@backnotprop

@backnotprop backnotprop commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

The code review screen now says in the footer when the diff changed on disk, for example after an agent edits files: the diff changed on disk · r refreshes. Nothing reloads by itself. r refreshes as before, and notes follow their lines exactly as they do with r today.

How it checks

  • Repo::disk_stamp(scope) (new stamp module in plannotator-tui-review) runs one git --no-optional-locks status --porcelain=v2 -z --branch --untracked-files=all --no-renames. It hashes HEAD's commit, the records, and the mtime and size of each listed file. The mtimes catch a changed file that changes again, which status alone reports the same way. With --no-optional-locks, status never takes index.lock and never rewrites the index, so it cannot get in the way of the agent's own git commands.
  • A staged review counts only HEAD and the index side of each file (status letter and blob ids). Edits to the work tree and untracked files do not count.
  • A commit or pull request review has nothing on disk to watch and starts no thread. For a PR, checking the head sha means a gh call to the network every few seconds, which is not cheap.
  • A branch review does not notice its base ref moving. r still recaptures it.

When it checks (review/watch.rs)

  • One worker thread runs one check at a time. The screen asks for a check only when none is in flight. A mutex keeps a check from running git at the same time as a reload's capture.
  • No check starts while the comment box is open or within 1.5 s of a key or paste.
  • Checks run at most every 3 s. A slow repository is checked less often: the next check waits 50 times as long as the last one took, so checking stays under about 2% of one core.
  • After the diff is known to have changed, no more checks run until a reload.

Measured (disk_stamp on the uncommitted scope, release build, median of 20, Apple silicon):

repository tracked files one check interval one full capture (r)
plannotator-tui 246 23 ms 3 s 86 ms
sentry 21k 110 ms 5.5 s 129 ms
t3code 29k 124 ms 6.2 s 193 ms

Most of the time in a large repository is the untracked-file scan (sentry: 30 ms with --untracked-files=no). Repositories that enable core.untrackedCache or core.fsmonitor get faster checks automatically.

Tests: stamps against real repositories (a second edit of a changed file, an untracked file and its removal, a commit, staged versus work tree, no watch for commits and PRs). Screen flows: the notice appears and r clears it with the note moved, no check starts while the comment box is open or right after a key, and a commit review starts no checks.

Docs: README (code review section and key table) and the ? help screen.

Checked by hand in tmux on a scratch repository: a note, an edit from outside, the notice about 2 s later, r with the note moved. With the comment box open, an edit from outside caused no check for 8 s. The notice appeared about 2 s after the box closed.

Every few seconds a worker thread takes a cheap stamp of what the scope's diff
depends on: one git status (porcelain v2, --no-optional-locks, so it never takes
the index lock) and the mtime and size of each file it lists. When the stamp
differs from the one taken after the last capture, the footer says "the diff
changed on disk · r refreshes". Nothing reloads by itself.

One check at a time, never alongside a reload's capture, none while the comment
box is open or within 1.5 s of a key, and a slow repository is checked less often
(50 times the last check's duration, at least 3 s). Commit and pull request
reviews have nothing on disk to watch and start no thread.
@backnotprop
backnotprop force-pushed the feat/review-disk-notice branch from 194613d to d8dc722 Compare November 20, 2026 01:41
@backnotprop
backnotprop added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 8bb937a Nov 20, 2026
3 checks passed
@backnotprop
backnotprop deleted the feat/review-disk-notice branch November 20, 2026 01:51
@backnotprop backnotprop mentioned this pull request Nov 23, 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.

1 participant