Skip to content

[codex] Route OpenCode missing-session errors through Effect#3608

Open
StiensWout wants to merge 1 commit into
pingdotgg:mainfrom
StiensWout:codex/upstream-opencode-typed-session-errors
Open

[codex] Route OpenCode missing-session errors through Effect#3608
StiensWout wants to merge 1 commit into
pingdotgg:mainfrom
StiensWout:codex/upstream-opencode-typed-session-errors

Conversation

@StiensWout

@StiensWout StiensWout commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Root cause

OpenCodeAdapter used a synchronous session helper from Effect bodies, so missing or closed sessions threw defects instead of returning typed provider adapter failures.

Impact

Missing and already-stopped OpenCode session operations now fail predictably through the typed provider adapter error channel. Existing stop cleanup behavior is preserved for known sessions.

Validation

  • PATH="$HOME/.vite-plus/bin:$PATH" vp test apps/server/src/provider/Layers/OpenCodeAdapter.test.ts
  • PATH="$HOME/.vite-plus/bin:$PATH" vp check
  • PATH="$HOME/.vite-plus/bin:$PATH" vp run typecheck

vp check reports the repository's existing unrelated warnings and no errors.

Note

Route OpenCode missing-session errors through the typed Effect error channel

  • Refactors ensureSessionContext in OpenCodeAdapter.ts from a synchronous throwing function into an Effect.fn generator that yields typed ProviderAdapterSessionNotFoundError or ProviderAdapterSessionClosedError failures.
  • All handlers (sendTurn, interruptTurn, stopSession, respondToRequest, respondToUserInput, readThread, rollbackThread) now call yield* ensureSessionContext(...) and surface missing/closed session errors via the typed error channel instead of throwing.
  • Adds tests verifying that sendTurn and stopSession fail through the typed error channel for non-existent sessions.
  • Behavioral Change: callers that previously caught thrown exceptions for missing sessions must now handle typed Effect failures.

Macroscope summarized 658754d.


Note

Medium Risk
Changes error propagation on core OpenCode session operations; behavior is more predictable for Effect callers but differs from prior synchronous throws (defects).

Overview
OpenCode adapter session guards no longer throw from inside Effect bodies. ensureSessionContext is now an Effect.fn that yields ProviderAdapterSessionNotFoundError or ProviderAdapterSessionClosedError (using Ref.get for the stopped flag instead of Ref.getUnsafe).

Call sites (sendTurn, interruptTurn, respondToRequest, respondToUserInput, readThread, rollbackThread) use yield* ensureSessionContext(...). stopSession returns the same not-found error via yield* when the thread is absent, instead of throwing.

Tests assert that sendTurn and stopSession on unknown threads fail with ProviderAdapterSessionNotFoundError through Effect.result, not as defects.

Reviewed by Cursor Bugbot for commit 658754d. Bugbot is set up for automated code reviews on this repo. Configure here.

Co-authored-by: Codex <codex@openai.com>
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 375d304f-7bbc-48ee-9ef4-460225e985e7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Jun 30, 2026
@StiensWout StiensWout marked this pull request as ready for review June 30, 2026 05:44
@macroscopeapp

macroscopeapp Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

This is a mechanical refactor converting thrown exceptions to Effect's typed error channel in ensureSessionContext. The same errors are raised under identical conditions, with new tests verifying the behavior. No runtime behavior changes beyond error routing internals.

You can customize Macroscope's approvability policy. Learn more.

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

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant