Skip to content

Conversation

@chuan2984
Copy link
Contributor

@chuan2984 chuan2984 commented Nov 30, 2025

Summary

Add PR-style diff review UI for opencode changes.

This is my rough draft based on some discussion here. I'll be honest and that the session_diff.lua was mostly AI coded, but was verified and checked for accuracy.

Please pull it if you are interested, its been working well for me so far

Screenshots

image

Key Points

  • SSE: Uses message.updated event (contains only current cycle diffs, unlike session.diff which
    accumulates everything) for capturing the before, and after for only files touched in the current cycle.
  • Diff display:
    • Simple vim.diff() unified view
    • A more complex pr review style enhanced diff view that works with hunk staging

note: DiffView.nvim sadly does not really support what we want, since it only works with git rev not local temp files(we are not using git, we dont get much from DiffView.nvim other than the nice UI

Screenshot of enhanced diff image

Files

  • lua/opencode/diff.lua - Core review logic
  • plugin/events/session_diff.lua - Event listener
  • DIFF_FEATURE.md - Full documentation

TODOs

  • better abstraction/file organization
  • better user command
  • the ability to see the most recent diff
  • slightly better-looking UI
  • the ability to set keymaps
  • plan mode should show diff but non-editable
  • What should happen to diff if files outside of current dir are modified
  • Add toggle file panel keymap
  • Delay the events until idle or that do it without setting focus?
  • MORE testing~~~

Bugs

  • The highlighting on the current file can be off in certain scenarios, treesitter problem. Incorrect timing, re-open fixes it
  • Shows only new addition for my lua files, no idea why, this is because of symlink, This is a opencode problem.

Nice to have?

  • any permission event dont automatically switch the focus back to nvim

@@ -0,0 +1,14 @@
-- Debug helper: Add this to your Neovim config temporarily to see ALL opencode events
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: ignore this file, only for debugging, will be removed

@NickvanDyke
Copy link
Owner

sometimes closing neovim would not close the manage opencode session

I didn't test this super extensively, especially with new providers. lmk if you find a cause or fix along the way!

@froats
Copy link

froats commented Jan 8, 2026

Hi, how is this going?

@chuan2984
Copy link
Contributor Author

chuan2984 commented Jan 9, 2026

@froats , still in testing mode, i havent had too much chance to work on this. Theres something wrong with opening the current version, treesitter sometimes is not correctly attached. Other than that and some QoL stuff, i have been using it without a problem. Although i dont really use the diff features(accept hunk/reject hunk)that often(hunk definition is not that accurate). Please give it a try if you are interested. It is 80% there.

I also just attached a screenshot as well.

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.

3 participants