Skip to content

Local code review in the session file-changes panel (code_review)#197

Draft
serxa wants to merge 2 commits into
mainfrom
serxa/code-review-panel
Draft

Local code review in the session file-changes panel (code_review)#197
serxa wants to merge 2 commits into
mainfrom
serxa/code-review-panel

Conversation

@serxa

@serxa serxa commented Jul 24, 2026

Copy link
Copy Markdown
Member

Local code review inside the session's file-changes panel (code_review)

Review code before it's committed or pushed, from inside a session's file-changes panel
(Chat → the Files button). A session can attach one or more git worktrees; their diffs
(vs a base ref) and line-anchored comment threads show in the panel. Off by default; enabled
per-install via config.

Why

Reviewing an agent's in-progress changes meant reading raw git diff in a terminal — no way to
point at a specific line and discuss it inside Nerve. This adds a two-way, line-anchored review
loop for local (uncommitted) code, organized around "this session ↔ these worktree(s)".

What it does

  • Attach a worktree to a session (many per session, including worktrees outside the workspace),
    then browse its working-tree diff vs a base ref + a full-file view.
  • Comment on a line → the comment is delivered into that session as a turn; the agent's reply
    posts back onto the thread (marking it answered). The agent can also originate threads to point
    the human at a line.
  • Data model: reviews (worktree + base_ref + target_session_id) → threads (file + line + side)
    → comments, persisted in the DB.

Config (off by default)

code_review:
  enabled: true
  repos:
    - ~/nerve
    - ~/project

Only files inside a configured repo root (or one of its git worktrees) are served, path-traversal
guarded. Every route requires the existing web-UI auth.

Changes

  • config: CodeReviewConfig (enabled + repo roots + max file size)
  • db: migration v040 + ReviewStore (reviews / threads / comments; reviews filterable by session)
  • gateway: gitreview.py (worktree enumeration, working-tree diffs, file-at-ref, path guard)
    reusing compute_file_diff; routes/reviews.py/api/review/* (repos/changed/diff/file) and
    /api/reviews/* CRUD (with ?session= filter), with the comment→session inject
  • web: the Chat file-changes panel gains a Worktrees section — attach picker, per-worktree
    git changed-files, a line-anchored diff renderer with inline comment threads (reply/resolve); the
    Files button is always available so a fresh session can attach a worktree
  • tests: test_reviews.py — store (incl. session filter), git helpers (incl. traversal guard), routes

Backend changes are additive (new tables/routes/config); the migration creates new tables only.

serxa and others added 2 commits July 24, 2026 15:54
A browser panel to review on-disk git worktrees before anything is committed
or pushed, with line-anchored comment threads that route into a Nerve session
and back. Gated by config (default off); repo roots are configurable.

- config: CodeReviewConfig (enabled + repo roots + max_file_bytes)
- db: migration v040 + ReviewStore (reviews / threads / comments)
- gateway: gitreview helpers (worktree enumeration, working-tree diffs,
  file-at-ref, path-traversal guard) reusing compute_file_diff; /api/review/*
  and /api/reviews/* routes. Human comments inject into the review's target
  session via a detached engine.run; agent replies mark the thread answered.
- web: /review page with a line-anchored diff renderer, inline comment threads
  (reply/resolve), worktree picker, changed-files list, full-file view, and a
  target-session selector.
- tests: ReviewStore, git helpers (incl. traversal guard), and routes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replace the standalone /review panel with a per-session model: a session can
attach one or more git worktrees, whose diffs (vs a base ref) and line-anchored
comment threads show in the Chat file-changes panel. Human comments route into
that session; the agent replies back on the thread.

- backend: list_reviews gains a target_session_id filter; GET /api/reviews?session=
- web: session-scoped reviewStore; FileChangesPanel gains an "Attached worktrees"
  section (attach picker + git changed-files + line-anchored ReviewDiff + threads);
  the Files button is always available; remove the /review route, NavRail entry, ReviewPage
- tests: session-filter coverage

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@serxa serxa changed the title Add a local code-review panel (code_review feature) Local code review in the session file-changes panel (code_review) Jul 25, 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