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

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
  • Shows only new addition for my lua files, no idea why
  • [] Newly added files dont get highlight until closing again. My treesistter setup?

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!

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