Skip to content
padenotPublic

About

No description, website, or topics provided.

Resources

Stars

10 stars

Watchers

0 watching

Forks

Repository files navigation

lrv

lrv is a local review UI for unified diffs. It reads a diff from stdin, --cmd, or --file, opens a browser UI backed by Monaco or the diffs library, and prints submitted comments to stdout as JSON or text. It can also show comments from a phabricator/github revision, or review comments generated by another tool.

Its purpose is to easily show the diff created by an AI agent to a human, that can comment on it. The comments are fed back to the agent.

Screenshot of a typical review, with a colorscheme matching phabricator, in stacked mode

Users

Install:

cargo binstall lrv
# or
cargo install lrv

lrv supports three review workflows:

  1. Review local code changes.
  2. Review existing Phabricator comments inline.
  3. Run a local LLM self-review first, then show those generated comments to the author.

Local changes:

git diff | lrv
git diff --staged | lrv
git show HEAD | lrv
lrv --cmd "jj diff --git"
lrv --file changes.patch

Phabricator review comments:

PHABRICATOR_API_KEY=... git show HEAD | lrv --phab-revision D123456

Local LLM self-review:

# The driving agent reviews the diff first and writes review-notes.json.
git diff > /tmp/lrv.diff
lrv --file /tmp/lrv.diff --review-notes-file review-notes.json

To review a commit series (all commits in a branch at once):

lrv --series "trunk()..@"          # jj revset
lrv --series "main..HEAD"          # git range
lrv --series "HEAD~5..HEAD"        # last 5 commits

The UI shows a commit strip for navigating between commits. Comments track which commit they belong to and are grouped per commit in the output.

Useful flags:

--series <RANGE>   Review a jj revset or git range as a commit series
--no-open          Don't auto-open a browser
--format text      Print comments as text instead of JSON
--title "..."      Show a custom title in the header
--review-notes-file notes.json
                  Render pre-existing review notes inline with the diff;
                  can be repeated
--phab-revision D123456
                  Render Phabricator review comments inline with the diff
--config-dir       Print the config directory path and exit
--list-reviews     List review sessions stored in the local comment database
--recover [<ID>]   Print a stored session's comments (default: the most recent)
--bind <ADDR>      Bind a specific address (default: 127.0.0.1)
--public           Bind on all interfaces
--tailscale        Also bind detected Tailscale IPv4 addresses

Network exposure:

  • By default, lrv binds to 127.0.0.1, so only your machine can reach it.
  • In practice, lrv --tailscale usually listens on both 127.0.0.1:<port> and your local Tailscale 100.x.y.z:<port>.
  • lrv --public --tailscale usually listens on 0.0.0.0:<port> plus any detected Tailscale 100.x.y.z:<port>.
  • --public, --bind 0.0.0.0, and --tailscale expose the review UI and diff contents over plain HTTP with no auth.
  • Only use those flags on trusted private networks or Tailscale peers you trust.

Notes:

  • Finish prints comments to stdout and ends lrv. When an agent runs lrv, that stdout is how the comments reach it, so the agent must not pipe, redirect, or background lrv's output.
  • Every comment is also recorded in a SQLite database as it is made, so a review survives losing the browser tab, the lrv process, or the terminal output. Use lrv --list-reviews and lrv --recover [<ID>] to get it back. The database lives next to the config (comments.db in the platform data directory); LRV_COMMENT_DB overrides its path.
  • Review notes are display-only annotations. They reserve space below the target line in the diff and are not included in submitted review output. --review-notes-file accepts a JSON array of objects with file, line, side, and body; optional fields include author, date, source_url, and commit_idx.
  • For a local LLM pre-review, the agent should review the diff before starting lrv, write its findings as review notes JSON, and pass that file with --review-notes-file. The author can then Address, Reply, or Ignore those local reviewer comments in the UI before finishing.
  • Edit accepts an agent note with replacement text for Finish, Publish and recovery; Undo discards the edit and restores the original.
  • Phabricator notes use PHABRICATOR_API_KEY or PHABRICATOR_TOKEN, falling back to the token in ~/.arcrc (written by moz-phab install-certificate); set PHABRICATOR_BASE_URL or pass --phab-base-url for non-Mozilla instances.
  • lrv --version prints the current version and can warn if a newer release exists.

Add notes to a review that is already open by running this from the repository:

lrv --add-notes review-notes.json
# Or: cat review-notes.json | lrv --add-notes -

The notes appear without a reload. Repeating the command skips duplicates and reports {"added":0,"skipped":N}.

Review notes JSON shape:

[
  {
    "file": "src/file.rs",
    "line": 42,
    "side": "new",
    "body": "Comment text shown inline.",
    "author": "Local LLM review"
  }
]

Discussing with an agent

Attach an agent with Connect Agent, or start lrv yourself and ask your agent to listen with lrv --listen from the same repository. The header shows the agent's status while its poll is open and for up to five minutes afterwards by default (LRV_AGENT_LEASE_SECS, default 300 seconds).

The Discuss button or Mod+Alt+Enter in either comment form sends the text straight to the agent. Its reply appears inline under the discussion; Reply continues the thread. Discussions are never drafted, submitted or published, and disappear when lrv exits. They are disabled in public mode (--public or --bind 0.0.0.0, HTTP 403), and allowed with --tailscale alone. The commit-message view doesn't offer Discuss yet.

Convert opens a review comment draft at the thread's location. Type a comment, or use Summarize while an agent is listening to fill the draft, then edit it. Save removes the thread and adds an ordinary review comment; Cancel keeps the thread unchanged. Summary requests (summarize: true on a follow-up) and replies (summary: true with discussion_id) stay hidden in the thread.

Delete removes a discussion thread and its agent replies; the agent receives a discussion_deleted event telling it to stop work on the thread and not reply.

Agent replies are notes with discussion_id naming the root discussion (use thread_id from a follow-up event). Send them with --add-notes, not --review-notes-file. Finish ends the review: comments go to the terminal that started lrv, and a pending listener reports ended. Attached agents handle review requests and discussions and never receive the final review.

When Phabricator is available, Publish D123 beside Finish follows the selected commit. It opens a dialog for that revision's verdict and overall comment. Publishing keeps the review open; the commit strip marks published revisions with ✓. Finish excludes published comments and includes the published URLs. Convert discussions to comments before Finish to keep them.

Connect Agent

Click Connect Agent beside Finish to start a local claude or codex CLI (installed and authenticated on the server machine). Choose a provider and optionally a model and effort; empty fields use the CLI defaults. Once the agent is attached, Request Review in the commit bar asks it to review the current commit. It posts findings only against that commit, then listens again. Your choices are remembered in this browser.

The button is replaced by a Connected badge whose dot is green while the agent listens and pulses amber while it reviews or answers a discussion; the text stays the same. Failed launches show an error when you reopen the popover, including the agent log path if the process exited. While it runs, the agent's progress (messages and tool calls) is echoed to lrv's stderr with an [agent] prefix. Only one agent can be launched at a time. The button is unavailable in public mode.

lrv supplies private temporary diff files for every commit and removes them on shutdown, after allowing the agent to exit and killing it if necessary. A launched agent stays in its listen loop until the review ends; long sessions may require its CLI's automatic context compaction.

Customization

Settings (theme, font, view mode) are saved to ~/.config/lrv/config.toml.

Custom themes

lrv ships with GitHub, Solarized, Firefox DevTools, and the built-in Monaco themes. To add your own, drop any VS Code theme JSON file into the themes/ subdirectory of your lrv config directory:

mkdir -p "$(lrv --config-dir)/themes"
cp my-theme.json "$(lrv --config-dir)/themes/"

lrv --config-dir prints the platform-correct path (~/.config/lrv on Linux, ~/Library/Application Support/lrv on macOS, %APPDATA%\lrv on Windows).

The theme appears in the Settings dialog under Custom on the next launch. VS Code themes are widely available:

  • VS Code Marketplace — themes ship as .vsix files (zip archives); the JSON is inside under themes/
  • monaco-themes npm package — 30+ themes already in Monaco format

Development

Prerequisites:

  • Rust toolchain
  • Node.js + npm
  • just
  • Playwright Firefox for e2e: just setup-e2e

Main workflows:

just build
just test-unit
just test-e2e
just ci

cargo build / cargo run will rebuild the embedded web bundle automatically when frontend inputs change. You can still run npm run build:web directly if you only want to rebuild the frontend bundle.

Frontend

The browser UI uses Monaco for the file-by-file diff editor. The stacked diff view and the sidebar file tree are intentionally delegated to Pierre's components:

  • @pierre/diffs renders the stacked diff. It is loaded lazily only when stacked mode is opened, and syntax highlighting runs through the library worker asset.
  • @pierre/trees renders the sidebar file tree.

Keep the Monaco path separate from the stacked path. Changes to file selection, review note placement, comment rendering, or theme variables may need updates in both modes.

License

Licensed under either of:

  • Apache License, Version 2.0
  • MIT license

See LICENSE-APACHE and LICENSE-MIT.

Releasing

Pushing a vVERSION tag publishes the crate to crates.io and builds GitHub release binaries. The tag must match the version in Cargo.toml. Maintainers can use just release VERSION (or major, minor, or patch) to bump the version and push the tag. Crates.io trusted publishing requires a trusted publisher for padenot/lrv, workflow publish-crates.yml, and the GitHub Actions environment crates-io. No local crates.io token is needed.

The Publish crates workflow can also be run manually with dry_run enabled to verify authentication and packaging. To retry an upload, enter the release tag in release_tag and disable dry_run; an already published version is skipped.

About

No description, website, or topics provided.

Resources

Stars

10 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages