refactor(instance): remove remaining bind call sites (#27731)

This commit is contained in:
Shoubhit Dash
2026-05-15 20:04:42 +05:30
committed by GitHub
parent 2d90f325fc
commit fa9a2cb24d
4 changed files with 38 additions and 17 deletions

View File

@@ -11,7 +11,7 @@ import path from "path"
import { readFileSync, readdirSync, existsSync } from "fs"
import { Flag } from "@opencode-ai/core/flag/flag"
import { InstallationChannel } from "@opencode-ai/core/installation/version"
import { InstanceState } from "@/effect/instance-state"
import { EffectBridge } from "@/effect/bridge"
import { init } from "#db"
import { Effect, Schema } from "effect"
@@ -167,7 +167,7 @@ export function use<T>(callback: (trx: TxOrDb) => T): T {
}
export function effect(fn: () => any | Promise<any>) {
const bound = InstanceState.bind(fn)
const bound = EffectBridge.bind(fn)
try {
ctx.use().effects.push(bound)
} catch {
@@ -188,7 +188,7 @@ export function transaction<T>(
} catch (err) {
if (err instanceof LocalContext.NotFound) {
const effects: (() => void | Promise<void>)[] = []
const txCallback = InstanceState.bind((tx: TxOrDb) => ctx.provide({ tx, effects }, () => callback(tx)))
const txCallback = EffectBridge.bind((tx: TxOrDb) => ctx.provide({ tx, effects }, () => callback(tx)))
const result = Client().transaction(txCallback, { behavior: options?.behavior })
for (const effect of effects) effect()
return result as NotPromise<T>