Skip to content

Bug: Tabs created after restore are not persisted #545

Closed

Description

@wzj-zz

Summary

Tabs created after restoring existing tabs are not persisted across restarts.

Steps to Reproduce

  1. Open Neovim, create Tab 1 and Tab 2, send a message in each
  2. Close Neovim
  3. Reopen — Tab 1 and Tab 2 restore correctly
  4. Create Tab 3, send a message
  5. Close Neovim
  6. Reopen — only Tab 1 and Tab 2 are restored, Tab 3 is missing

Root Cause

M.restore() returns early when existing tabs are detected:

local current = tabs.list()
if not untouched(current, background) then
  return  -- early return here
end

But group.restoring was set to true during the first restore():

group.restoring = true
restore_snapshot(...):await()
group.restoring = false

On the second open, restore() returns early, leaving group.restoring = true.

M.save() checks:

if group.attempted and not group.failed and not group.restoring then

Since group.restoring == true, the group is skipped and tabs are not saved.

Verification

  • After restore: 2 tabs
  • After creating Tab 3: 3 tabs
  • M.save() returns false
  • Snapshot file contains only 2 tabs (missing Tab 3)

Suggested Fix

Reset group.restoring = false when restore() returns early, or ensure the state is consistent before M.save() runs.

Environment

  • OS: Windows 11
  • Neovim: 0.12.5
  • opencode.nvim: latest main (commit 494e474)
  • opencode executable: opencode2 (v2 protocol)

Activity

  1. wzj-zz commented on Oct 21, 2026

    @wzj-zz
    ContributorAuthor

    I can confirm this bug is more severe than initially reported.

    Test case:

    1. Open project with no existing snapshot
    2. Create Tab 1, send message "Hello Tab 1"
    3. Create Tab 2 with <M-c>, send message "Hello Tab 2"
    4. Close Neovim
    5. Reopen — only 1 tab restored (should be 2)

    Video demonstration:

    issue545_compressed.mp4

    This shows that ANY additional tab beyond the first is not persisted, not just "tabs created after restore".

    Environment:

    • OS: Windows 11
    • Neovim: 0.12.5
    • opencode.nvim: latest main (97566da)
    • opencode executable: opencode2 (v2 protocol)
  2. wzj-zz commented on Oct 21, 2026

    @wzj-zz
    ContributorAuthor

    Update: The bug is more severe than initially reported.

    Original scenario (cannot test due to this bug):

    • Restore existing tabs → create new tab → tab lost

    Current scenario (confirmed):

    • Fresh start → create Tab 1 + Tab 2 → only 1 tab restored

    This suggests PR #542 may have introduced a regression where ANY additional tab beyond the first is not persisted.

    Steps:

    1. Clean state (no snapshot, no sessions)
    2. Open Neovim, create Tab 1, send message
    3. Create Tab 2 with <M-c>, send message
    4. Close Neovim
    5. Reopen — only 1 tab restored

    Video: issue545_compressed.mp4

    Environment: latest main (97566da)

    cc @sudo-tee @jensenojs

  3. added 4 commits that reference this issue on Oct 21, 2026
    18e3cb4
    9388647
    2478990
    665d1b9
  4. added a commit that references this issue on Oct 23, 2026
    b842eca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions