Skip to content

[Bug] All sessions are gone #2987

Closed as not planned
Closed as not planned

Description

@ddanielcruzz

I ran the command /compact, it seemed stuck so I proceeded to quit the app and when I re-opened and try to list my sessions I found out all of them were gone 🥲

Activity

  1. github-actions commented on Oct 6, 2025

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    The common pattern is that the /compact command can get stuck or cause unexpected behavior that results in loss of session data. Several users have reported similar issues where /compact appears to hang and requires force quitting the app, sometimes leading to session loss.

    Feel free to ignore if none of these address your specific case.

  2. rekram1-node commented on Oct 6, 2025

    @rekram1-node
    Collaborator

    @ddanielcruzz all your sessions, everywhere?

  3. rekram1-node commented on Oct 6, 2025

    @rekram1-node
    Collaborator

    is there any chance this was in a project that didnt have any commits yet and then you did an initial commit?

  4. ddanielcruzz commented on Oct 6, 2025

    @ddanielcruzz
    Author

    Hey @rekram1-node

    1. I used opencode for only one project, so all my sessions were related to that project.

    2. The repository had many commits. I initially started my session in a specific branch, but later switched to another branch to work on something else. I forgot to switch back and continued chatting. The responses were not accurate, which made me realize I was in the wrong branch. After switching back, I encountered a context window error, even though the TUI showed about 60% of the context in use, which was unusual. I decided to run /compact, but it got stuck, so I quit. After that, all my sessions were gone.

  5. rekram1-node commented on Oct 6, 2025

    @rekram1-node
    Collaborator

    @ddanielcruzz just wanna see the "damage" so to speak can you run a few commands and see if data is still there for me?

    id=$(git rev-list --max-parents=0 --all)
    ls ~/.local/share/opencode/storage/session/${id} # if this is empty then run next ls command and show output if possible
    ls ~/.local/share/opencode/storage/session

    git rev-list --max-parents=0 --all

    ^^ Run this in your project, it will give the project id, that can then be used to list sessions^^

  6. ddanielcruzz commented on Oct 8, 2025

    @ddanielcruzz
    Author

    Hi @rekram1-node the latest data if from 2 days ago, so sadly my data is gone.

    I encountered another issue where I closed a session as I added a new local MCP, once I re-opened I couldn't find the session in the list.

    Running the commands you shared I have two directories, is that normal?.

    I'm using git town to keep branches in sync as well as worktrees to have multiple instances of opencode in different branches. Not sure if it's related

  7. rekram1-node commented on Oct 9, 2025

    @rekram1-node
    Collaborator

    when u say running the commands shared which command and what was output?

  8. ddanielcruzz commented on Oct 9, 2025

    @ddanielcruzz
    Author

    Running ls ~/.local/share/opencode/storage/session gives me two directories

  9. rekram1-node commented on Oct 9, 2025

    @rekram1-node
    Collaborator

    what if u use the id one?

  10. ddanielcruzz commented on Oct 9, 2025

    @ddanielcruzz
    Author

    Running these two

    id=$(git rev-list --max-parents=0 --all)
    ls ~/.local/share/opencode/storage/session/${id}
    # output
    /.local/share/opencode/storage/session/7b9ebd75da850e8f2ce0013a13d973314c3c26c1\n97d5b7390b6695f5f8189e90aac11e97c707b93f\n15175d963f0ed863af3d3c0f6287ef8ab81db034\na8e844dad56388522ddbaa68a3285570d5cef7b3": No such file or directory (os error 2)
    ls ~/.local/share/opencode/storage/session
    # outputs two direcotries
  11. sjswerdloff commented on Oct 13, 2025

    @sjswerdloff

    I'm having a similar problem, but not related to compaction. I did compact, without interruption. I was able to continue, with no problem. Then I exited and restarted, and no sessions. started with dev (v.0.14.x?) yesterday, had this problem, updated to v.0.15.0 today, no joy. However a "new" session that I started is showing up as available. The old session ses_625e82ae4ffeJuaY06cCPYUQ3X.json was gone from the previous project subdirectory:
    ./session/4b0ea68d7af9a6031a7ffda7ad66e0cb83315750
    and was in ./session/global

  12. rekram1-node commented on Oct 13, 2025

    @rekram1-node
    Collaborator

    there is a known issue that if you have a git repo without any commits, have sessions (they will be in global storage) then once you make commits you kinda “lose them” since the repo has commits and is no longer tracked in global

    we ofc should handle this but does that sound like what may have happened for you?

  13. sjswerdloff commented on Oct 14, 2025

    @sjswerdloff

    there is a known issue that if you have a git repo without any commits, have sessions (they will be in global storage) then once you make commits you kinda “lose them” since the repo has commits and is no longer tracked in global

    we ofc should handle this but does that sound like what may have happened for you?

    #3123 fixed my problem.
    My first commit in the repo I was working in: Date: Mon Oct 13 16:44:45 2025 +1300
    Problem occurred after that, so I started working on a fix for it with first commit in opencode branch Date: Mon Oct 13 18:17:05 2025 +1300

    So, no, I don't think it had to do with a git repo without commits. It looks like a straight forward migration/backward compatibility issue. Not that at 0.x you owe anyone backward compatibility, but... for me, if I couldn't fix this quickly, I would have given up on opencode, which would have been a shame because it is exactly the kind of tool I have been looking for and really want to use (across a variety of LLMs, and support for Cerebras was a huge bonus, the qwen-code fork that supported Cerebras was not playing well with newer commits to qwen-code). Huge gratitude to the maintainers and contributors of opencode.
    I used a Gemini in gemini-cli to help me find and fix (#3123) and it threw in the "--continue" type behaviour as an automatic thing (which works for me, I have what is perhaps a different approach than some/many) but isn't really appropriate given that --continue is an option) so you probably want to remove that particular part of it.
    I'm using a Claude Sonnet 4.5 (the session that got lost), and I'm really happy with how opencode works compared to Claude Code (and the stability/lack of unasked for automatic updates), and look forward to using it for gemini and qwen (without the sticky release issues or visible tearing when trying to avoid that issue).

  14. ddanielcruzz commented on Oct 16, 2025

    @ddanielcruzz
    Author

    @rekram1-node I think multiple causes can trigger this bug. I got it again yesterday, in a repo with commits. What happened was that the agent started a dev server process and got stuck, my messages to tell it to stop got queued and trying to exit was not working. I kept hitting ctrl + c until it exited, after reopening opencode the session I just exited was gone.

  15. 9 remaining items

  16. rekram1-node commented on Dec 8, 2025

    @rekram1-node
    Collaborator

    I did some changes that should fix this, one of them lands in next release

  17. redtux commented on Dec 8, 2025

    @redtux

    I did some changes that should fix this, one of them lands in next release

    Wow, cool! Will this also fix disappearing subagent sessions (in the first place when being called by another subagent), or is this another issue? I often have the issue that I cannot find the window anymore (with ctrl-x left/right) after switching window (by accident or to search some text in the previous window), and the bot said it's related to "a bug with session handling for subagents" but I'm not sure whether this is correct or not (I learned not to trust them too much in such cases 😂).

  18. rekram1-node commented on Dec 13, 2025

    @rekram1-node
    Collaborator

    im unfamiliar with this bug can u reliably reproduce it?

  19. redtux commented on Dec 16, 2025

    @redtux

    Sorry, haven't seen this. I guess that this can be reproduced by undoing all commits, or by running into certain bugs when calling subagents, but I don't know if there are certain steps to consistently reproduce this. I experienced this several times and I observed certain patterns, but I am afraid I don't know enough about the reason why this happens to provide a reproducible workflow for consistent testing.

  20. yogeek commented on Feb 24, 2026

    @yogeek

    In my case, I had more than 30 sessions yesterday and today, I have only 5 in opencode...

    I saw that a fix was proposed in #3123 but this was closed and not merged apparently.
    Seems related to #14818 but also closed...
    Any update about this loss of sessions please ?

  21. somtooo commented on Feb 24, 2026

    @somtooo

    hey i can say this is the bug - #3123. If i open opencode in home folder i have way more sessions than if its open in another folder

  22. somtooo commented on Feb 24, 2026

    @somtooo

    im unfamiliar with this bug can u reliably reproduce it?

    #3123 - this fixes it please re open

  23. redtux commented on Mar 2, 2026

    @redtux

    im unfamiliar with this bug can u reliably reproduce it?

    #3123 - this fixes it please re open

    I asked so three months ago in PR #3123. Let's hope we have more luck this time 🤞

  24. tmdgjs2592 commented on Mar 30, 2026

    @tmdgjs2592

    Is there any update on this problem? Opencode 1.3.8 still has this issue.

  25. arunoruto commented on Apr 1, 2026

    @arunoruto

    This is related to the recent update v1.2.22 from Mar 8, 2026. I came back from vacation and noticed that all my sessiosn were gone. Upon looking in the ~/.local/share/opencode folder, I noticed a large database file opencode.db (~900MB) and a "small one" (~600kB). Seems like the migration didn't happen on my end, so I had to delete the new files and rename my old ones to match the new schema.
    In the end, this fixed my problem:

    mv opencode-stable.db opencode-stable.db.backup
    rm -f opencode-stable.db-shm opencode-stable.db-wal
    
    cp opencode.db opencode-stable.db
    cp opencode.db-wal opencode-stable.db-wal
    cp opencode.db-shm opencode-stable.db-shm

    I didn't mind losing my new data, since it was just one session.

  26. removed
    bugSomething isn't working
    on May 3, 2026
  27. redtux commented on May 23, 2026

    @redtux

    Hi @rekram1-node , wouldn't it be good to have a repair script at least to restore the lost sessions?

  28. wynadiis23 commented on May 28, 2026

    @wynadiis23

    also happen to me. in my case, i have 15+ session on a project. then today, its only show 5 session on the same project, the sessions almost gone. hope we can fix this in the future.

  29. uros-5 commented on Aug 9, 2026

    @uros-5

    Same issue. It does not appear in /session menu. But this helped me:

    grep -oP 'id=ses_\w+' ~/.local/share/opencode/log/opencode.log | sort -u
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions