Skip to content

Refactor OpenCode SDK handling to idiomatic Effect#4092

Draft
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/idiomatic-effect-patterns-6a46
Draft

Refactor OpenCode SDK handling to idiomatic Effect#4092
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/idiomatic-effect-patterns-6a46

Conversation

@cursor

@cursor cursor Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

What Changed

  • Route OpenCode text-generation SDK promises through the shared runOpenCodeSdk Effect boundary.
  • Define OpenCodeRuntimeError as a serializable Schema.TaggedErrorClass and use a schema-derived guard.
  • Replace the full OpenCode runtime test double with a partial Layer.mock and migrate assertions to @effect/vitest assert helpers.

Why

This removes duplicated Effect.tryPromise boundaries, keeps SDK tracing and structured error conversion consistent across OpenCode integrations, and makes tests explicit about the service methods they exercise while preserving original SDK causes.

Validation

  • vp check --fix (0 errors)
  • vp run typecheck
  • Targeted OpenCode tests: 3 files, 31 tests passed

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • UI screenshots are not applicable
  • UI video is not applicable
Open in Web View Automation 

Note

Refactor OpenCode SDK error handling to use Effect Schema idioms

  • Rewrites OpenCodeRuntimeError from TaggedError to Schema.TaggedErrorClass in opencodeRuntime.ts, replacing the static is predicate with an exported isOpenCodeRuntimeError predicate via Schema.is.
  • Replaces direct Effect.tryPromise calls around client.session.create and client.session.prompt in OpenCodeTextGeneration.ts with OpenCodeRuntime.runOpenCodeSdk, and sets the reported cause on downstream errors to the inner cause from the runtime error.
  • Updates tests in OpenCodeTextGeneration.test.ts to use Layer.mock for OpenCodeRuntime instead of a concrete test double, and switches assertions from expect to assert from @effect/vitest.

Macroscope summarized d6a5860.

cursoragent and others added 2 commits July 17, 2026 16:07
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant