# Diff review

`/diff` is pi-jar's post-edit review UI: it inspects captured before/after content, then lets you accept (stop tracking) or explicitly confirm a revert. Its split-first presentation and soft/strong change backgrounds follow [Oh My Pi's Git diff pane](https://github.com/can1357/oh-my-pi/blob/b91db66e9b0b65a2c977e6a5bc74b0f4b1d58d1c/packages/tui/src/apps/git/diff-pane.ts). Existing hunk-navigation and bounded-rendering ideas also draw on [pi-show-diffs](https://github.com/xRyul/pi-show-diffs). No upstream code is copied, and the tool pre-approval flow is unchanged.

- Type `/` in the file list to filter by absolute/relative path or change status (content search is intentionally omitted to keep keystrokes bounded over large retained snapshots). Press Enter to keep the filter, Escape to clear it, and `n`/`N` to move through matching files.
- The right pane starts with the selected file's absolute path and change summary.
- Normal previews render a viewport of Git-style hunks. Each hunk header is preceded by a `┄ N unchanged lines ┄` label for the region it skips. `PgUp`/`PgDn`, `g`/`G`, `Home`/`End`, or the mouse wheel move through the preview; `n`/`p` jump hunks. Rendering windows the requested rows instead of constructing a rendered row for every file line.
- Wide panes open in aligned side-by-side **Before/After** columns with wrapping off, matching OMP's split-first defaults. `t` toggles unified rows and split columns: within a replacement, the k-th removed line sits beside the k-th added line, and a longer side continues alone. Panes narrower than 70 columns keep the unified layout. Toggling keeps the hunk at the top of the viewport. Split columns show one line number per side; unified rows retain old/new line-number gutters.
- `←`/`→` (or `[`/`]`) step the context through 0, 1, 3 (default), 5, 10, 25 lines and the whole file. `w` wraps long lines onto continuation rows instead of truncating them; with wrapping, `End` shows the last full page.
- Changed lines retain a colored `▌` rail. Native truecolor themes blend the neutral tool background with the added/removed foreground colors: soft backgrounds cover the padded text body, and stronger backgrounds mark changed words. The blend strengths follow OMP (18% soft/42% strong on dark palettes, 24%/48% on light palettes); pi-jar uses the theme's neutral tool background because terminal canvas RGB is not exposed here. Themes without accessible RGB colors retain tool success/error backgrounds and inverse-video word emphasis.
- Word changes use a bounded token LCS (lines that share no word, very long lines and coarse previews are not emphasized). Files whose language Pi recognizes are syntax-highlighted per line with the active theme; lines over 1,000 characters keep plain diff colours. Syntax resets restore active background/word emphasis instead of erasing it.
- Changes over 256 KiB or 1,500 combined lines initially show summary counts. Press `v` to explicitly review a bounded preview or return to summary. Previews are capped at 100,000 combined lines per file. When exact LCS diff exceeds its existing CPU/memory budget, the full-review choice uses a clearly marked coarse replacement hunk that preserves common prefix/suffix and line order.
- Safe revert tracking remains capped at 1 MiB per file and 8 MiB of retained baselines. Binary, oversized, or otherwise untracked files cannot be reverted from this UI. The summary does not imply content beyond those safety caps is reviewable.

The implementation uses the pi-tui custom component and windowed split-frame renderer already used by pi-jar. OMP reference pinned to commit `b91db66e9b0b65a2c977e6a5bc74b0f4b1d58d1c`: [`packages/tui/src/apps/git/diff-pane.ts`](https://github.com/can1357/oh-my-pi/blob/b91db66e9b0b65a2c977e6a5bc74b0f4b1d58d1c/packages/tui/src/apps/git/diff-pane.ts), specifically `palette()`, `#renderSide`, and `#renderLine`. Its split default, wrap-off default, padded soft backgrounds and stronger word backgrounds are the visual reference—not its Git patching or minimap features. Additional MIT-licensed reference: [xRyul/pi-show-diffs README](https://github.com/xRyul/pi-show-diffs#diff-review-ux) for aligned split rows, rail markers, collapsed regions, context and wrapping. No upstream source was copied. Pre-apply approval and inline editing are not part of `/diff`, which reviews changes after they are applied.
