# diff-review Browser-based git diff review bridge for Pi. | **Pi bridge** | | --------------------------------------------- | | ![Pi bridge](assets/diff_review_terminal.gif) | ## Install / load Loaded through the root pi-ext package. See [root README](../../README.md). ## Commands / tools / settings Commands: - `/diff-review` - `/diff-review --staged` - `/diff-review --base ` or `/diff-review --base=` - `/diff-review --files ` or `/diff-review --files=` - `/diff-review-cancel` Tools: none. Hooks: - `session_start`: restores persisted review rounds and open findings state. Persisted live reviews are not auto-reopened. - `session_shutdown`: closes active review server. Settings: none. ## E2E Run root `mise run e2e` first to install browsers and execute every extension suite. After that bootstrap, run `mise run e2e` here, or `mise //extensions/diff-review:e2e` from the repository root, to test only the browser review flow in Chromium and Firefox. ## Behavior Opens a local browser UI for reviewing git diffs and sending findings back to Pi. - Requires interactive Pi UI. - Runs from Pi cwd inside a git repo. - Waits for Pi idle before collecting diff. - Default source: unstaged working-tree diff. - `--staged`: reviews staged diff. - `--base `: reviews `...HEAD`. - `--base` rejects refs that start with `-` or contain NUL. - `--staged` and `--base` are mutually exclusive. - `--files` accepts comma-separated relative paths. Absolute paths, `..`, and NUL are rejected. - Path filters are rebased from Pi cwd to repo root before `git diff`. - Uses `git diff --no-ext-diff --find-renames --src-prefix=a/ --dst-prefix=b/ --unified=3`. - Preserves rename metadata in staged diffs. - Normalizes quoted git paths for diff parsing. - Starts a local HTTP server on `127.0.0.1`; prefers port `47717`, falls back to an ephemeral port if busy. - Review URL carries a token. Index access requires that token. - Static files require the strict token cookie. API requests require bearer token or strict token cookie. - Opens the browser via platform opener when available; otherwise Pi shows the URL. - Server renders review HTML with file tree, split diffs, finding UI, summary, notes, search, and theme controls. - Browser JS handles line selection, theme mode, pane layout, code search, heartbeats, polling, cancel, and submit. - Code search accepts literal text or `/regex/` and returns up to 500 hits. - Browser fetches current review data, polls for diff changes every 2s, and refreshes diff before submit. - Browser posts heartbeat every 5s. Server checks heartbeat loss every 10s and treats the browser as gone after 30s. - Browser close, browser cancel, `/diff-review-cancel`, heartbeat loss, or session shutdown closes the server. - Submit appends a `diff-review` custom session entry and sends formatted markdown back to Pi as a user message. - Submit clears browser drafts and notes, then keeps the review server live until closed. - Findings use severity `high`, `medium`, or `low`; category `bug`, `style`, `perf`, or `question`; side `additions` or `deletions`. - Finding validation requires selected lines to exist in rendered diff context. - Finding anchors include selected lines plus 3 nearby context lines on each side when available. - Session state stores review rounds and one live review entry. - Open findings from previous rounds are carried into review payloads. - Binary files are recorded as skipped. - Per-file diff limit: 10 MiB. Total renderable diff limit: 50 MiB. Request body limit: 10 MiB. - If all changed files are binary or over limits, review fails with the skipped file list.