Skip to content

fix: scope OpenCode resume sessions by workspace#1007

Open
CharlieZhao95 wants to merge 1 commit into
zts212653:mainfrom
CharlieZhao95:fix/opencode-workspace-resume-1006
Open

fix: scope OpenCode resume sessions by workspace#1007
CharlieZhao95 wants to merge 1 commit into
zts212653:mainfrom
CharlieZhao95:fix/opencode-workspace-resume-1006

Conversation

@CharlieZhao95

Copy link
Copy Markdown
Contributor

Summary

  • Store the CLI session workingDirectory on SessionRecord for memory and Redis stores.
  • Gate OpenCode resume so --session is only passed when the active record matches both cliSessionId and normalized thread workspace.
  • Add regression coverage for missing, mismatched, and matching workspace resume paths plus store persistence.

Fixes #1006

Tests

  • pnpm --dir packages/api build
  • node --test --test-timeout=60000 test/invoke-single-cat.test.js test/session-chain-store.test.js
  • bash ./scripts/run-isolated-redis-tests.sh node --test --test-timeout=60000 test/redis-session-chain-store.test.js

[砚砚/gpt-5.5🐾]

Why: OpenCode --session can carry stale workspace/tool state across repositories, so resume must be gated by the current thread workspace.

Records the workingDirectory on SessionRecord and only passes an OpenCode session id when the active record matches both cliSessionId and normalized workspace.

Covers matching, missing, and mismatched workspace resume paths plus memory and Redis store persistence.

[砚砚/gpt-5.5🐾]
@CharlieZhao95 CharlieZhao95 requested a review from zts212653 as a code owner June 24, 2026 07:24
@zts212653

Copy link
Copy Markdown
Owner

Thanks for the PR. It is correctly linked to accepted issue #1006 and the high-level direction matches the accepted fix shape: OpenCode resume should be scoped by the current thread workspace instead of blindly passing a stale --session id.

I am routing this for independent maintainer review rather than opening a parallel implementation. A few review notes up front:

  • This is an absorbed-code path candidate if merged, because it changes shared API/runtime and shared session types.
  • CI is currently not green yet; for a first-time contributor fork it appears to need maintainer workflow handling before checks run.
  • The reviewer should pay special attention to the workspace fingerprint semantics, existing-session migration behavior, diagnostics when the guard discards a resume id, and Redis/memory store parity.

[砚砚/gpt-5.5🐾]

@zts212653

Copy link
Copy Markdown
Owner

Update: while routing this PR for review, I found that the maintainer-side source fix for #1006 had already landed in our upstream source tree. So this PR now overlaps with an already-reviewed internal fix, and we should not treat the two paths as independent competing implementations.

What this means for review:

  • We will compare this PR against the landed source fix before deciding whether to merge this branch, ask for changes, or close it with attribution.
  • This is still appreciated and useful: it independently confirms the issue shape and the right class of fix.
  • Current CI also needs attention before any merge decision: Lint is failing on formatting in invoke-single-cat.ts; Test (Public) is blocked by the expired concurrent-fault-drill exclusion in the public test resolver.

I will keep the PR open while we reconcile the overlap instead of asking you to churn on changes blindly.

[砚砚/gpt-5.5🐾]

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.

OpenCode sessions can resume with a stale workspace and analyze the wrong project

2 participants