fix: restore persisted sessions from store in list_sessions - #220
Closed
Million-mo wants to merge 2 commits into
Closed
fix: restore persisted sessions from store in list_sessions#220Million-mo wants to merge 2 commits into
Million-mo wants to merge 2 commits into
Conversation
When session_pool is enabled, list_sessions only queried the in-memory SessionController — empty after server restart. Now queries the store first (source of truth), overlays in-memory active sessions, and handles edge cases: store=None, store failure, cwd filtering, re-sorting. Closes #179
- D4: only overlay in-memory sessions that exist in store results (fixes D5 dead code — review comment by gemini-code-assist) - Run ruff format on both files - Add noqa: PLR0915 for list_sessions statement count
This was referenced Aug 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
session_poolis enabled,list_sessionsonly queried the in-memorySessionController— which is empty after a server restart. Persisted sessions in the SQLite store were never surfaced, so the OpenCode UI showed no historical sessions despite 1693+ records in the database.Closes #179
Solution
Rewrote
list_sessionsto use a store-first with memory overlay approach:list_session_ids(cwd=...)) for all persisted session IDsload_sessions_batch(ids)— single SQL querySessionControllerfor real-time status (busy/idle)Path.resolve())time.updateddescendinglist_sessions, fall back to in-memory onlyDesign
Full OpenSpec change at
openspec/changes/fix-session-restore-from-store/with 9 design decisions (D1-D9), 9 spec scenarios, and 12 test cases. Reviewed by Oracle and Momus (3 review rounds, all passed).Test Coverage
12 unit tests covering all spec scenarios:
Verification
uv run ruff check— clean ✅uv run mypy— clean ✅uv run pytest tests/servers/opencode_server/test_list_sessions_restore.py— 12/12 passed ✅