Skip to content

Latest commit

 

History

History
116 lines (85 loc) · 4.78 KB

review.md

File metadata and controls

116 lines (85 loc) · 4.78 KB

Reviewing changes

Documentation / Reviewing changes

Session diffs show what the agent changed, file by file. You can leave comments on lines and send them back with your next prompt. This needs OpenCode V2; on V1, see snapshots.

Open a session diff

After the agent edits files, press <leader>od or run :Opencode diff open. A new Neovim tab opens with the changed files on the left and a before/after view of the selected file.

Changed-file tree and side-by-side revisions

In the file list, <CR> opens a file or folds a directory. <Tab> and <S-Tab> go to the next and previous file from either the list or the preview. Press p to switch between side by side and a unified patch.

Unified patch preview

Both sides come from snapshots OpenCode recorded during the session. If you have edited a file since, the diff does not show those edits.

Choose a range of messages

By default the diff covers your last prompt. To see the changes from several prompts:

  1. Press r to list your prompts.
  2. Press f on the first prompt and t on the last.
  3. Press <CR> to show the changes across that range.

K previews a prompt, and r, q, or <Esc> go back to the file list without changing the range. g? shows the keys in any review pane.

Message-range picker with start and end markers

Leave inline feedback

In the preview, press c on a line or a visual selection. Write the comment and save with <C-s>, :w, or <CR> in normal mode. q or <Esc> cancels.

Review comment editor

Saved review comment beside its changed line

Saved comments show as signs in the preview and are marked in the file list. ]r / [r jump between them; c on a comment edits it and dc deletes it. You can comment on either side, including on a deleted file.

Press q in the list or preview to close the review. If you left comments, the prompt opens with them attached. Write the follow-up, for example "Fix these, keep the public API the same", and send it.

Each saved comment immediately inserts a @review-comment-<id> mention into the input draft. Its attached context carries the same reference, so the agent can match your prompt to that comment. Comments still attach automatically by default; a mentioned comment is included even when automatic review-comment context is disabled.

The context bar shows how many comments are attached. Use # to detach all of them or remove one. To never attach them automatically, set context.review_comments.enabled = false.

Comment line numbers refer to the snapshot you reviewed. If the file has changed since, including unsaved edits, the plugin also sends the current code around each comment so the agent can find the right place.

The session review recipe has the same steps as a checklist.

Jump to the working file

gf opens the real file in another tab and leaves the review open. From the preview, the cursor lands on the matching line of the new version; on a deleted line, it goes to the next line that still exists. If the file has changed since the snapshot, the line may be off.

From the conversation, press D on an edit or patch tool block to open the diff for that prompt with the file selected. Press D on the same block again to close it.

Customize review keys

Review keys are set under keymap.session_diff, one table per pane. Set the old key to false when you move an action:

require('opencode').setup({
  keymap = {
    session_diff = {
      list = { ['p'] = false, ['v'] = { 'toggle_view' } },
      preview = {
        ['p'] = false,
        ['v'] = { 'toggle_view' },
        [']f'] = { 'next_file', desc = 'Next file' },
        ['[f'] = { 'prev_file', desc = 'Previous file' },
      },
    },
  },
})

An action can be a review action (the names in the defaults), any :Opencode command name, or a Lua function. Entries take mode, desc, and nowait like other keymaps.

For your own FileType autocmds, the panes use these filetypes: opencode_diff_list, opencode_diff_messages, opencode_diff_comment, and opencode_diff_help. Previews combine the file's language with a suffix, such as lua.opencode_diff_preview, so match *.opencode_diff_preview or *.opencode_diff_message_preview. The plugin's mappings are already set when your autocmd runs.