Skip to content

Chat with the agent about a review, beside the diff - #210

Closed
NikhilVerma wants to merge 1 commit into
nkzw-tech:mainfrom
NikhilVerma:review-chat
Closed

NikhilVerma wants to merge 1 commit into
nkzw-tech:mainfrom
NikhilVerma:review-chat

Conversation

@NikhilVerma

Copy link
Copy Markdown
Contributor

What this does

Today you can ask the agent about a line by writing a note and pressing Ask. The answer appears under that one note, and the agent remembers nothing from one note to the next.

This PR turns that into one chat per review, in a pane beside the diff. You can type a question there, or press Ask on a note as before. Either way the question joins the same conversation, the reply streams in, and the agent sees your earlier questions and the walkthrough stop you are reading.

Replies link to code. Clicking a link to a changed file takes you to its walkthrough stop or to the file in the diff. A link to any other file opens it in your editor.

codiff-review-chat.mp4
Before After
The reply sits under one note A note's question joins the chat, with a chip for its line
The reply sits under the note. Each note is its own one-off question. Ask on a note moves the question into the chat, with a chip for the line it points at.
A reply with a Mermaid diagram and file links
A typed follow-up. File links are chips, and links that leave the review carry an arrow.

How it works

The principle is that Codiff owns the conversation, not the agent CLI. Agent runs stay stateless, as they are for walkthroughs, and Codiff sends the earlier turns again with each question. That keeps the chat out of each CLI's own saved history, and it works the same way for every backend.

  1. A chat store (core/app/hooks/useReviewChat.ts) keeps the turns in memory, one conversation per repository and review source. Nothing is written to disk. The store lives outside React state, so a streaming reply redraws the pane and not the diff.

  2. Each request carries the question, the finished turns, the code it points at, and the walkthrough stop on screen. electron/review-chat.cjs (renamed from review-assist.cjs) builds the prompt. For a question on a line it marks the exact lines with > and adds six lines of context each side, so "this" means the right code.

  3. Streaming reuses the onPartialText option Pi already had. Codex, Claude Code and OpenCode now call it too. The reply is still one JSON object, so readPartialReply reads the growing reply string out of the cut-off JSON. The main process sends the text so far to the window with the turn's id.

  4. The pane (core/app/components/ReviewChatPane.tsx) renders replies with the existing ReadOnlyMarkdownView, and resizes with the existing useResizableSidebar.

  5. File links are handled in core/lib/review-chat-links.ts. The Markdown view only keeps web addresses as link targets. So before a reply is drawn, each link to a repository file is rewritten to an address on the reserved .invalid domain, and a click reads it back. A file link then can't be opened as a web page.

The inline reply under a note is removed, so there is one way to ask.

Reading beyond the diff

Before this change the chat prompt told the agent to use only the diff. Now a chat turn may read and search the repository, and never write.

  • Codex already ran in a read-only sandbox, and Pi already had its read tools. Nothing changes for them.
  • Claude Code gets Read, Grep and Glob. No allow rule is added, so in dontAsk mode it reads inside the repository and refuses paths outside it. I checked this with the claude command: a repository file was read, and /etc/hosts was refused.
  • OpenCode gets allow rules for read, grep, glob and list after its deny-all rule.
  • Antigravity is unchanged and answers from the diff only.

Testing

  • vp check passes and vp test run passes (1466 tests).
  • New tests cover the marked lines in the prompt, history carried between turns, the stop on screen, reading a cut-off reply, streaming, read access per agent, the store, and file links.
  • Used in the running app with Codex: the video above. Earlier in development I also ran the prompt against the real Claude Code CLI from a script, and it streamed its reply.
  • Not tested: OpenCode, Pi and Antigravity, which I don't have set up. In particular the OpenCode permission rules are untested.

Known limits

  • A link to a changed file goes to its stop or file, not to the exact line.
  • The pane's width is not saved between launches.
  • An agent's raw error text is shown in the chat when a turn fails.

AI assistance

This PR was written primarily with Claude Code, including the code, the tests and this description. I directed the design and tested it in the app.

banana banana banana

🤖 Generated with Claude Code

Asking the agent about a note used to put a one-off reply under that
note. Now each review has one conversation in a pane beside the diff.
A question typed there, or asked from a note, joins it, and the agent
sees the earlier turns and the walkthrough stop on screen.

Codiff keeps the turns in memory and sends them again with each
question, so agent runs stay stateless. Replies stream in, and their
links to files open the walkthrough stop, the diff or the editor.

Chat turns may read the repository but never write to it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@NikhilVerma
NikhilVerma marked this pull request as ready for review December 4, 2026 12:08
@cpojer

cpojer commented Dec 6, 2026

Copy link
Copy Markdown
Member

This is awesome, very nice work. But to be honest, I wanna kind of go the other direction - rip out AI besides the walkthroughs from Codiff and simplify. It's still best to ask directly in the chat with the context, instead of a new one each time.

I'm going to close this for now as I don't think this is the direction I want to take Codiff in, but I will consider it. It's open source, so feel free to maintain your own fork!

@cpojer cpojer closed this Dec 6, 2026
@NikhilVerma

Copy link
Copy Markdown
Contributor Author

Thank you! yes I totally get it. This change was inspired by the need to review a lot of PRs (because of agents doing all the production). So I needed a way to quickly chat with lots of prs without needing to check out their branches. I'll keep it as a fork for now! 👍

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.

2 participants