Repository navigation
Closed
Description
Summary
PR #525 implements session tab persistence, but the current model conflates tabs and sessions. This issue proposes a design where tabs are containers and sessions are content, similar to Neovim's window/buffer relationship.
Design Proposal
Core principle: Persist the tab (container), not the session (content).
| Neovim | opencode.nvim | Role |
|---|---|---|
| window | session tab | Container, persists independently |
| buffer | agent session | Content, can be created/deleted |
Operation Semantics
| Operation | Container Effect | Content Effect |
|---|---|---|
<M-c> (new tab) |
New container created | New session created and filled |
<C-a> (select session) |
Container unchanged | Swap to existing session |
<C-n> (new session) |
Container unchanged | Replace with new session |
Key: <M-c> creates container + fills it so user can chat immediately. <C-a>/<C-n> only change what the container holds.
Bugs Found in Current Implementation
Bug 1: Tabs created before panel open are lost
- Open Neovim, do NOT open panel
- Press
<M-c>3 times, send messages :q, reopen — only 1 tab restored
Cause: M.save() iterates groups, but groups is empty unless M.restore() was called (panel opened).
Bug 2: Empty tabs not persisted
- Open panel, press
<M-c>, do NOT send message :q, reopen — tab missing
Cause: save_group() skips tabs where active_session == nil.
Bug 3: <C-a> session switch not persisted
- Tab 2 shows Session A
- Press
<C-a>, switch to Session B :q, reopen — Tab 2 shows Session A again
Cause: M.set_active() updates global store but not the tab's active_session field.
Proposed Behavior
| Scenario | Current | Proposed |
|---|---|---|
| Empty tab after restart | Lost | Restored as empty container |
| Session deleted server-side | Tab shows "N/A" | Tab becomes empty container |
<C-a> switch |
Ephemeral | Persisted |
Questions
- Agree with "tab as container, session as content" model?
- Should empty tabs be persistent?
- Should
<C-a>switching be durable across restarts? - Should
<M-c>auto-fill with new session (so user can chat immediately)? - Deleted session: show "N/A" or empty container?
Environment
- OS: Windows 11
- Neovim: 0.12.5
- opencode.nvim: latest main (commit 494e474)
- opencode executable: opencode2 (v2 protocol)
Metadata
Metadata
Assignees
Labels
No labels
Activity
wzj-zz commentedon Oct 17, 2026
@sudo-tee Thanks for merging PR #525! The project-scoped tab groups work great. These are follow-up refinements I discovered during deeper testing, not criticisms of the original implementation. I appreciate your quick iterations on this feature.
sudo-tee commentedon Oct 20, 2026
I think this MR can help with this workflow
#543
It will not persist tabs with a session and no prompt sent.
sudo-tee commentedon Oct 20, 2026
For the container, you can already reuse a tab to see another session
leader oIdoes that and the session picker also use the current tab.leader oNcreate a new tab (with a new session for the moment) but the PR I sent in my other message is fixing this . It will be a draft sessionNot sure what is missing
wzj-zz commentedon Oct 20, 2026
Thanks for clarifying the
<leader>oIand session picker behaviors. However, I realize my use case with<C-a>is different from both:My
<C-a>workflow:<C-a>to open the session pickerThis differs from:
<leader>oI: Stays in current tab, but creates a new sessionThe bug I encountered:
<C-a>, Tab 1 correctly shows Session BQuestions:
For context, I have
<C-a>mapped toselect_sessionwhich callssession_runtime.select_session.sudo-tee commentedon Oct 20, 2026
sudo-tee commentedon Oct 21, 2026
@wzj-zz
I am not able to reproduce the issue if I use the session picker on a tab it properly switch and is restored with the new session.
Can you give it a try with latest changes or record a video if you are still able to reproduce ?
wzj-zz commentedon Oct 21, 2026
@sudo-tee Here is the video demonstrating the
<C-a>session switch persistence issue.Video:
issue541_compressed.mp4
What the video shows:
<C-a>, select "Test message 222" (Session B)Environment:
The session switch works in the current instance, but is not persisted across restarts.
fix(session): fix snapshot write failure on Windows
fix(session): fix snapshot write failure on Windows
fix(session): fix snapshot write failure on Windows
fix(session): fix snapshot write failure on Windows (sudo-tee#548)