Skip to content

feat(review): viewed marks shared with the browser app (x, ctrl+n) - #171

Merged
backnotprop merged 1 commit into
mainfrom
feat/viewed-marks
Nov 20, 2026
Merged

backnotprop merged 1 commit into
mainfrom
feat/viewed-marks

Conversation

@backnotprop

Copy link
Copy Markdown
Contributor

In the code review screen, you can now mark files as viewed. The marks use the browser app's own review-progress records, so a review you start in one app continues in the other.

What it does

  • x (toggle-viewed) marks the file under the cursor as viewed. Press x again to unmark it.
  • ctrl+n (next-unviewed) goes to the next file that is not viewed, in diff order, and wraps around. This is n with a modifier. previous-unviewed has no default key, because most terminals send Ctrl+Shift+N as Ctrl+N. You can bind it under [keys]. n/N are unchanged.
  • The header shows a count: Uncommitted · 7 files +4 −1 · 2/7 viewed. The footer shows ✓ viewed when the file under the cursor is marked.
  • Limitation: there is no tick in the file list. diffs-rs 0.2.0 draws that list and has no API to decorate a file. A small diffs-rs API (for example, per-file badges) would make this possible.

Storage (docs/spec-review-progress.md)

  • Each file has one record: <data-dir>/review-progress/<key>/<sha256(path)>.json containing {"v":1,"path","fingerprint","viewed","suppressed"}. The app writes a temp file (mode 0600) and then renames it, so the last write wins and a record is never left half-written.
  • key = sha256(JSON.stringify(["git", realpath(root), branch ref or HEAD sha, [diffType, base|null]])). The scopes map to the browser's diff types in Scope::diff_type.
  • fingerprint = sha256(JSON.stringify([oldPath, newPath, oldMode, newMode, oldOid, newOid])). The values come from git diff --raw, run the same way the browser runs it for each diff type: the tracked diff, then untracked files. Working-tree sides are hashed with git hash-object and checked against the patch's index line. When a file changes, its mark stops counting.
  • Some files get no fingerprint, the same as in the browser: submodules, any side over 5 MiB, and paths that --stdin-paths cannot take. You can still mark them, but the mark lasts only for the session.
  • The app respects PLANNOTATOR_REVIEW_PROGRESS and reviewProgress in config.json.
  • Pull request reviews keep their marks in this app's own folder (clients/plannotator-tui/review-progress/). The browser fingerprints PR files from GitHub's patch text, which this app never has byte for byte. Nothing is sent to GitHub.
  • The new code is in crates/plannotator-tui-review/src/progress.rs and crates/plannotator-tui/src/review/viewed.rs, with small hooks in input.rs, draw.rs, mod.rs and overlays.rs.

How the format match was checked

  • The browser source I read: packages/shared/review-progress.ts, packages/shared/review-core.ts (parseRawDiffEntries, resolveReviewFileIdentities, runGitDiff), packages/server/review.ts (captureProgress, the base upgrade) and packages/shared/config.ts.
  • I copied those hashing and loading function bodies into a standalone Node script outside the browser repo and ran it on a scratch repository. The repo has a modified file, a deleted file, a rename, a mode-only change, untracked regular, executable and symlink files, an ignored file, and a branch commit.
  • The Rust tests contain the resulting keys, identity strings and fingerprints, with the derivation in comments. Those tests cover uncommitted, since-base, staged, detached, commit and PR cases, plus JSON escapes, record bytes, malformed records and concurrent writers.
  • I ran the real binary in tmux. Its record folder name and fingerprints matched the Node script, and the browser's loadReviewProgress logic read the tui's marks as viewed. After an edit, the edited file dropped out.
  • Not verified: Windows paths (the review screen is Unix-only), clean/smudge filters, and SHA-256 repositories. These are covered only by reading the code.

Size

The release binary on macOS arm64 grows from 10,113,568 to 10,247,184 bytes (+133,616). This PR adds no new dependencies.

x marks the file under the cursor viewed, ctrl+n goes to the next file not
viewed, and the header counts them. Marks are the browser app's
review-progress records (<data-dir>/review-progress/<key>/<sha256(path)>.json,
same key and file fingerprint), so a review continues in either app and a
mark stops counting once its file changes. Pull request marks stay in this
app's own folder. See docs/spec-review-progress.md.
@backnotprop
backnotprop added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 87030cd Nov 20, 2026
3 checks passed
@backnotprop
backnotprop deleted the feat/viewed-marks branch November 20, 2026 01:20
This was referenced Nov 20, 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