opencode icon indicating copy to clipboard operation
opencode copied to clipboard

[FEATURE]: Session or Per-chat File Diff Viewer

Open NateAGeek opened this issue 1 month ago • 4 comments

Feature hasn't been suggested before.

  • [x] I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Feature

Add an integrated diff viewer mode to the terminal application that allows users to inspect code changes made during the current or previous LLM sessions, and interact with the model at a line or block level. This would reduce the need to scroll through long chat histories or manually run external git diff commands to understand and refine changes.

Motivation

Current workflow issues:

  • When the agent edits multiple files, I have to:
    • Scroll back through the chat history to reconstruct what changed, or
    • Approve all changes blindly and then use git diff to see what actually happened.
  • Sometimes I commit changes between iterations, so diffs span:
    • “Last assistant edit” vs working tree
    • Or “since last commit” vs working tree
  • Reviewing changes file-by-file via prompts is slow and noisy:
    • Approving each file individually is tedious.
    • Approving everything at once is risky if I can’t easily audit the combined diff.
  • I often want to refine specific lines or small code blocks:
    • Right now I have to copy/paste the relevant snippet into the chat and frame a new prompt.
    • This is error-prone and breaks flow.

A built-in diff viewer with chat integration would make the iteration loop much more controlled, auditable, and efficient.

1. Diff Viewer Mode

  • Trigger: A dedicated command, e.g. in the Ctrl+P menu (or similar), and add “Diff Viewer” mode/option. Presentation
  • Open a new window or side panel in the TUI (depending on how the project prefers handling split views).
    • Show diffs in a standard unified or side-by-side format, with:

3. Approval Mode? (Optional side idea)

Maybe implement a more iterative approval mode? Each file needs approval to write and review? I know the Plan functionality is kind of like this but this would be more pure code block by code block.

2. Line / Block-Level Chat Integration

Inside the diff viewer:

  • Ability to select a specific line or range of lines:
    • Via keyboard (e.g., moving cursor to a line and marking a range).
  • Once selected, user can:
    • Press a key (e.g., c) to “Chat about this selection”.
    • The selection is sent as rich context to the agent, and a new prompt is opened pre-populated with:
      • The selected snippet
      • Optional metadata (file path, line numbers, current diff context).
  • Typical use cases:
    • “Explain why you changed this logic.”
    • “Refactor this block for clarity/performance.”
    • “Can we roll back only this part of the change?”
    • “Generate tests for this specific function.”

The goal is to avoid manual copy/paste and keep discussions anchored to concrete code regions. I was thinking on implementing this feature myself, but wanted to follow the guide and see what the design team thinks?

NateAGeek avatar Dec 05 '25 05:12 NateAGeek

This issue might be a duplicate of existing issues. Please check:

  • #2265: A UI to view changes similar to cursor-cli - requests a dedicated UI for viewing changes similar to Cursor
  • #1815: Add unified diff view + configurable default - proposes improvements to diff viewing with unified format
  • #935: Add 'ask before editing files' mode - related to approval/review workflow before files are modified
  • #3858: EDIT PLAN mode or allow editing of only certain files in PLAN mode - related to iterative approval of changes

Feel free to ignore if your request addresses something specific not covered by these issues.

github-actions[bot] avatar Dec 05 '25 05:12 github-actions[bot]

Yes definitely on the list

rekram1-node avatar Dec 05 '25 05:12 rekram1-node

@rekram1-node Are there any current wip? I could offer some time coding if that would help. I was going to give it a shot anyways.

NateAGeek avatar Dec 05 '25 05:12 NateAGeek

I think we are going to have a design for this because we are gonna be somewhat opinionated, but if you have ideas or good references that'd be a good place to start a discussion here before any work is done

rekram1-node avatar Dec 08 '25 23:12 rekram1-node