Description
After updating opencode.nvim from 5e89ef9 to 6071fe7, the output-window message navigation actions (prev_message, next_message, prev_user_message, next_user_message) intermittently jump to the wrong place — the cursor lands on a wrong line/message instead of the message adjacent to the current position. Before the update navigation was always accurate.
I bisected by pinning: the problem is gone when pinned to b629972 (the commit immediately before #490) and present at 6071fe7 (#490 "Wip/session tabs"), so the session-tabs rework is the likely culprit.
Suspected cause
From reading the diff of #490, renderer.on_session_changed gained an early return:
function M.on_session_changed(_, new, old)
if state.active_session_tab ~= rendered_session_tab then
return
end
...
If state.active_session_tab and the renderer-local rendered_session_tab get out of sync (e.g. session_tabs clears the active tab via store.set_raw('active_session_tab', nil), which does not fire the store subscription), the renderer skips re-rendering on session change. The output buffer and render_state line numbers then still describe the previous session while state.messages holds the new one, so navigation targets computed from render_state:get_message(id).line_start land on stale/wrong lines.
Possibly also related to the renderer context snapshot/restore (ctx:snapshot() / ctx:restore()) added in the same PR.
Steps to reproduce
Intermittent ("sometimes"). In my usage it shows up in longer sessions, seemingly more often after switching sessions via the session tree and scrolling up into older messages:
- Open the opencode windows with a long session (enough messages to trigger lazy rendering)
- Switch between sessions and/or scroll up into older messages
- Trigger
prev_user_message / prev_message repeatedly
- Occasionally the cursor lands on a wrong line instead of the previous message
Environment
- Neovim version: 0.12.2
- OpenCode version: 1.18.29
- opencode.nvim version or commit: broken at
6071fe7; works at b629972 and 5e89ef9
- OS: Windows 11
Configuration
opencode.nvim configuration
Relevant keymaps (the behavior is also reproducible with the default [[ / [u mappings):
require('opencode').setup({
keymap = {
output_window = {
['<C-p>'] = { 'prev_message', desc = 'Prev message' },
['<M-p>'] = { 'prev_user_message', desc = 'Prev user message' },
},
},
})
Logs and screenshots
Happy to capture debug logs if you tell me what to enable.
Checklist
Description
After updating opencode.nvim from
5e89ef9to6071fe7, the output-window message navigation actions (prev_message,next_message,prev_user_message,next_user_message) intermittently jump to the wrong place — the cursor lands on a wrong line/message instead of the message adjacent to the current position. Before the update navigation was always accurate.I bisected by pinning: the problem is gone when pinned to
b629972(the commit immediately before #490) and present at6071fe7(#490 "Wip/session tabs"), so the session-tabs rework is the likely culprit.Suspected cause
From reading the diff of #490,
renderer.on_session_changedgained an early return:If
state.active_session_taband the renderer-localrendered_session_tabget out of sync (e.g.session_tabsclears the active tab viastore.set_raw('active_session_tab', nil), which does not fire the store subscription), the renderer skips re-rendering on session change. The output buffer andrender_stateline numbers then still describe the previous session whilestate.messagesholds the new one, so navigation targets computed fromrender_state:get_message(id).line_startland on stale/wrong lines.Possibly also related to the renderer context snapshot/restore (
ctx:snapshot()/ctx:restore()) added in the same PR.Steps to reproduce
Intermittent ("sometimes"). In my usage it shows up in longer sessions, seemingly more often after switching sessions via the session tree and scrolling up into older messages:
prev_user_message/prev_messagerepeatedlyEnvironment
6071fe7; works atb629972and5e89ef9Configuration
opencode.nvim configuration
Relevant keymaps (the behavior is also reproducible with the default
[[/[umappings):Logs and screenshots
Happy to capture debug logs if you tell me what to enable.
Checklist