# Review pane

The Review tab reads a set of changes and acts on it: four scopes, Revert and Stage on each block, line comments that wait and go out together, and a review by the conversation's own model. The layout follows the Codex app's review pane; where the change sets come from is in [the chat turn spec](https://fzkuji.github.io/OpenProgram/docs/reference/design/ui/chat/chat-turn-visual-spec.html#review-tab).

1. **Header** Scope menu with its totals; … menu with Review with agent and File type
2. **Block header** Revert, Stage (Unstage in Staged)
3. **Your comment** under its line, which ends in a dot; Edit, Delete
4. **Agent finding** under its line; Dismiss, Fix
5. **Bottom bar** N comments, Discard, Send to agent

## Header

| Item | Behaviour |
| --- | --- |
| Scope menu | The header's title: the scope's name and its +/− totals. The menu lists This turn, then Unstaged and Staged, then Branch, and ends with the source and the file count. |
| … menu | Review with agent (Stop review while one runs) and File type: All, Code, Tests, Docs, Large |
| Running review | ✦ Reviewing, the elapsed time and a stop button, between the scope menu and the … menu, only while it runs |
| File header | Stage (or Unstage) and Preview are icons that show while the header is hovered or focused; the n / N file switcher stays |

Why one row: the pane usually sits in a split window about 580 px wide, where the old title row, scope-tab row and a third row for Review with agent took a quarter of the height. The layout follows Codex's Changes pane.

| Peer | Header |
| --- | --- |
| Codex | One row: scope dropdown as title with totals, a … menu; buttons fold into it below 625 px; file actions on hover |
| Claude Code tab | One row: scope dropdown as title; options in the pane menu |
| OpenCode, Antigravity | Scope dropdown as title; display options behind icons or a ⋮ menu; Antigravity stages on hover |
| Agent review | None of these, nor Copilot, puts it in the diff header |

## Scopes

| Scope | Shows | Acts |
| --- | --- | --- |
| This turn | What one turn changed, from the mutation journal | Revert a block |
| Unstaged | Working tree against the index, untracked files included, `.gitignore` honoured | Revert a block; Stage a block or the file |
| Staged | Index against HEAD | Unstage a block or the file |
| Branch | What the conversation's branch changed, from the mutation journal | Revert a block |

- **Why Unstaged and Staged**: One "Workspace" diff mixed two segments a reader treats differently: what is about to be committed and what is not. Two scopes give each its own action (Stage, Unstage) and keep Revert on the side it writes, the working file.
- **Git chip**: "N uncommitted files" opens Unstaged: the changes not yet in a commit or the index are the ones a person usually checks first.
- **Snapshot**: Each scope is a pinned snapshot (HEAD, index blobs, working file identity). Stage, Unstage and Revert run only against the snapshot on screen; a newer one refuses and the pane reloads.

## Stage and Unstage

| Item | Behaviour |
| --- | --- |
| Block | `git apply --cached` with that one block; Unstage adds `--reverse`. Git checks the block's context against the index, so a block the index no longer matches is a conflict and nothing changes. |
| File | `git add --all` or `git restore --staged`, with the old path of a rename too |
| Only whole blocks | A block cut by a page edge or ending without a newline has no Stage; a new or deleted file stages as a file |
| Where | Only for a local Git project. Not a Git repository, or a conversation in an SSH environment: no Stage buttons, the same places the Git chip is absent, because the index there is not the one the agent works on. |
| During a turn | Waits, like Revert |
| After | The scope reloads and the Git chip refreshes |

Git does the patching. The same block that `git add -p` would stage is staged, with Git's own context checks, instead of a second patch engine.

## Line comments

| Item | Behaviour |
| --- | --- |
| Write | The comment button on the hovered line; ⌘Enter saves, Escape cancels |
| Pinned | A card under its line: "You", the text, Edit and Delete. The line ends in an accent dot. |
| Kept | Per conversation in a client store, so a tab switch or a remount keeps them while unsent. A comment belongs to its scope and file. |
| Bottom bar | Floats over the diff while any wait: "N comments", Discard, Send to agent |
| Send | One user message in that conversation, each comment as file and line, the quoted line, then the comment. It takes the send queue, so during a turn it waits its turn. The comments clear. |

Why a batch: comments on a change are read together. Sending each one as it is written starts a turn per line; dropping them into the composer mixed them with whatever was being typed. The Codex app collects inline comments the same way and sends them as one request.

## Review with agent

| Item | Behaviour |
| --- | --- |
| Start | The first item of the … menu. While it runs the header shows ✦ Reviewing, the time so far and a stop button, and the menu item reads Stop review. |
| Stop review | Ends the review at once: the server cancels the model request, the answer is ignored and the header loses its Reviewing time. A review is named by its `review_id`; `review_agent_cancel` with that id cancels it. |
| Input | The whole diff of the scope on screen (up to 60 files and 120,000 characters), each under its path |
| Call | One structured-output request on the conversation's own model at low reasoning effort, through the runtime that writes conversation titles. It writes nothing to the transcript. Low effort reviewed a 400-line change in 82 seconds with one request; the default effort took nine minutes over two and found no more real problems. |
| Findings | Path, line, severity (low, medium, high), body. Findings on files outside the scope or with another severity are dropped. |
| Shown | Cards under their lines: ✦ in accent purple, "Agent review · severity", the body, Dismiss and Fix. A finding on no shown line sits above the diff. A new review of a scope replaces that scope's findings. |
| Fix | Sends a message asking the agent to fix that finding, then removes the card |
| Waiting | A review of a large change takes minutes (a 400-line change takes over a minute), so the pane waits up to 30 minutes. The Worker keeps each answer for an hour under its `review_id`; when the socket drops while the model works, the pane waits for it to come back and asks again with `review_agent_wait`, which answers at once, or when the review finishes. |
| Failure | The Reviewing time goes and Review with agent can be chosen again; no error page, no banner. A Worker that restarted no longer knows the review and answers `UNKNOWN_REVIEW`. |
| Wire | `review_agent` runs beside the connection's ordered frames, so a long model call does not hold other requests |

Why the conversation's model: the review then reads with the same model and settings the person chose for this work, and no separate review model needs setting up. The Codex app's `/review` works the same way and puts its findings on the lines of the diff.

## Compared

| Part | Codex app | OpenProgram |
| --- | --- | --- |
| Scopes | Last turn, Unstaged, Staged, Branch, Commit | This turn, Unstaged, Staged, Branch; no Commit scope |
| Staging | Stage and unstage per hunk and file | Same, through Git |
| Inline comments | Collected, sent as one request | Same, per conversation |
| `/review` | Findings with priority on diff lines | Findings with severity, Dismiss and Fix |

**Implementation map**

| Part | Location |
| --- | --- |
| Scopes, Stage, Review with agent | `interfaces/server/ws_actions/turn_files/`: `diff.py` (Unstaged and Staged), `stage.py`, `agent_review.py`, `history.py` (actions) |
| Pane | `components/center-tabs/review/`: `review-tab-pane.tsx`, `review-diff.tsx`, `review-notes-store.ts`, `review-diff-rows.ts` |
| Sending | `sendFromTranscript` in `lib/chat/send/send-queue.ts` |
