Skip to content

fix(storage): add cwd parameter to OpenCodeStorageProvider.list_session_ids() - #98

Closed
Million-mo wants to merge 2 commits into
develop/agenticfrom
fix/opencode-list-session-ids-cwd-param
Closed

fix(storage): add cwd parameter to OpenCodeStorageProvider.list_session_ids()#98
Million-mo wants to merge 2 commits into
develop/agenticfrom
fix/opencode-list-session-ids-cwd-param

Conversation

@Million-mo

Copy link
Copy Markdown
Owner

Summary

  • Add missing cwd: str | None = None parameter to OpenCodeStorageProvider.list_session_ids(), matching the base class StorageProvider signature that all other providers (SQLModelProvider, MemoryProvider) already implement
  • Implement cwd filtering using compute_project_id(cwd) for efficient project-directory narrowing, then verify session's directory field matches
  • Add 4 regression tests covering: parameter acceptance, cwd filtering, cwd=None returns all, and signature compatibility with base class

Bug

When the OpenCode TUI calls GET /session?directory=<dir>, the call chain passes cwd through StorageManagerOpenCodeStorageProvider.list_session_ids(cwd=cwd), which raised TypeError: unexpected keyword argument 'cwd' because the override omitted the parameter. The TypeError was silently caught by NativeAgent.list_sessions(), returning [] and hiding all historical sessions.

Root cause: Commit dacfb7146 added cwd parameter to base class, StorageManager, MemoryProvider, and SQLModelProvider — but missed OpenCodeStorageProvider.

Production log evidence (opencode.log.1:2565-2587):

TypeError: OpenCodeStorageProvider.list_session_ids() got an unexpected keyword argument 'cwd'

Test plan

  • test_list_session_ids_accepts_cwd_parameter — verifies no TypeError when passing cwd
  • test_list_session_ids_cwd_filters_by_directory — verifies only matching sessions returned
  • test_list_session_ids_cwd_none_returns_all — verifies no filter when cwd=None
  • test_list_session_ids_signature_matches_base_class — static signature compatibility check
  • All 137 session tests pass
  • All 22 opencode-specific tests pass

备份迁移自 SRC-PR#29 · 作者 @Leoyzen · 创建于 2026-05-01T15:38:15Z · head=fix/opencode-list-session-ids-cwd-param base=develop/agentic
源状态: merged · merge_commit_sha=528164dbc2d569af0f13eaf254a43b744b81d731

Leoyzen and others added 2 commits May 1, 2026 23:37
…on_ids()

OpenCodeStorageProvider.list_session_ids() was missing the 'cwd' parameter that the base class and all other providers (SQLModelProvider, MemoryProvider) accept. When StorageManager.list_session_ids(cwd=cwd) forwarded the call, it raised TypeError which was silently caught by NativeAgent.list_sessions(), returning an empty list and hiding all historical sessions in the TUI.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
When read_session() returns None (corrupted JSON / I/O error), the cwd filter was bypassed and the session was incorrectly included. Changed the guard from 'if session is not None and session.directory != cwd' to 'if session is None or session.directory != cwd' so that unverifiable sessions are excluded when a cwd filter is active.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@Million-mo

Copy link
Copy Markdown
Owner Author

评论 by @Leoyzen 于 2026-05-01T16:09:00Z(备份迁移)

/gemini review

@Million-mo

Copy link
Copy Markdown
Owner Author

评论 by @Leoyzen 于 2026-05-01T16:09:01Z(备份迁移)

/gemini review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants