You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The keymap.session_diff scopes (list, preview, messages, help) are resolved in map_actions() (lua/opencode/ui/session_diff.lua) against a hardcoded table of 13 action names. This makes two common requests impossible through official configuration:
Cycling files from inside the diff view.M.select(direction) already implements next/prev-file navigation (it backs the global diff_next/diff_prev editor keymaps), but it is not registered in the map_actions table, so there is no way to bind buffer-local keys like <Tab>/<S-Tab> for it inside the diff view. Global keys are not an option here - <Tab> must stay buffer-local, otherwise it hijacks <C-i>/the jump list in every buffer.
Plain window-focus keys. Users coming from diffview/codediff are used to a key that moves focus from the file list to the diff pane (e.g. <M-e> -> 2wincmd l). This is a generic Vim operation, not plugin logic, so it can never be one of the 13 named actions.
User-side workarounds don't work either (compare codediff.nvim, which fires User CodeDiffOpen and sets dedicated filetypes like codediff-explorer): the session-diff view emits no User autocmd on open, the list buffer has filetype = '', and the preview buffers reuse the diffed file's real filetype - so a FileType autocmd cannot identify them safely.
Allow function values as the rhs in keymap.session_diff entries (like diffview.nvim does), keeping the action-table lookup for strings.
Optionally: set a dedicated filetype on the session-diff buffers and/or fire a User OpencodeSessionDiffOpen autocmd on open, so user configs can attach extra buffer-local mappings themselves.
Additional finding: the list window is missing wrap = false, causing j/k to need multiple presses per file entry.
M.open() sets number, signcolumn, cursorline, winfixwidth, etc. on the list window, but not wrap = false - while the help float (session_diff.lua:225) and the turn float (session_diff.lua:242) both set it explicitly. So the list window looks like an oversight.
The resulting chain:
The list window is narrow (24-42 columns), and file entries ("status + icon + path + diffstats") easily exceed its width.
With the user's global wrap = true, entries wrap onto multiple screen lines.
With the common j/k -> gj/gk mapping (e.g. AstroNvim's default j -> v:count == 0 ? 'gj' : 'j', which moves by screen line without a count), passing one wrapped file entry takes several j/k presses.
For the keymaps, since there is a lot of them I might change them to the same mechanism as the panel, it would be more flexible this way.
For the wrap you are right I will fix it.
These are valuable comments as the diff view was added lately to replace the custom snapshots in v1 that are not available anymore, but it's still barebones it need more refining.
My pre-existing <M-q>\ close bindings in all scopes still work alongside the new defaults
Also ran the full unit suite against this branch vs. main: identical failure sets (15 pre-existing Windows env failures), no regressions, and all the new session_diff/keymap tests pass.
Activity
wzj-zz commentedon Oct 3, 2026
Additional finding: the list window is missing
wrap = false, causing j/k to need multiple presses per file entry.M.open()setsnumber,signcolumn,cursorline,winfixwidth, etc. on the list window, but notwrap = false- while the help float (session_diff.lua:225) and the turn float (session_diff.lua:242) both set it explicitly. So the list window looks like an oversight.The resulting chain:
wrap = true, entries wrap onto multiple screen lines.j/k->gj/gkmapping (e.g. AstroNvim's defaultj->v:count == 0 ? 'gj' : 'j', which moves by screen line without a count), passing one wrapped file entry takes several j/k presses.One-line fix:
vim.wo[list_win].wrap = false.sudo-tee commentedon Oct 6, 2026
Thanks for the comments.
For the keymaps, since there is a lot of them I might change them to the same mechanism as the panel, it would be more flexible this way.
For the wrap you are right I will fix it.
These are valuable comments as the diff view was added lately to replace the custom snapshots in v1 that are not available anymore, but it's still barebones it need more refining.
sudo-tee commentedon Oct 7, 2026
@wzj-zz
I did some improvements to the sdession diff from your comments
#515
can you let me know if it works for you ?
wzj-zz commentedon Oct 7, 2026
Tested #515 on Windows 11 / Neovim 0.11 — everything works:
\\lua
keymap = {
session_diff = {
list = { [''] = { function() vim.cmd('2wincmd l') end, desc = 'Focus diff pane' } },
preview = { ['e'] = { function() vim.cmd('99wincmd h') end, desc = 'Focus file list' } },
},
}
\\
Also ran the full unit suite against this branch vs. main: identical failure sets (15 pre-existing Windows env failures), no regressions, and all the new session_diff/keymap tests pass.
LGTM — thanks for the quick turnaround!