Skip to content

Commit ad26579

Browse files
authored
refactor(share): remove session share async facade exports (anomalyco#22386)
1 parent b1312a3 commit ad26579

3 files changed

Lines changed: 18 additions & 14 deletions

File tree

packages/opencode/src/cli/cmd/github.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ export const GithubRunCommand = cmd({
564564
shareId = await (async () => {
565565
if (share === false) return
566566
if (!share && repoData.data.private) return
567-
await SessionShare.share(session.id)
567+
await AppRuntime.runPromise(SessionShare.Service.use((svc) => svc.share(session.id)))
568568
return session.id.slice(-8)
569569
})()
570570
console.log("opencode session", session.id)

packages/opencode/src/server/instance/session.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ export const SessionRoutes = lazy(() =>
212212
validator("json", Session.create.schema),
213213
async (c) => {
214214
const body = c.req.valid("json") ?? {}
215-
const session = await SessionShare.create(body)
215+
const session = await AppRuntime.runPromise(SessionShare.Service.use((svc) => svc.create(body)))
216216
return c.json(session)
217217
},
218218
)
@@ -437,8 +437,14 @@ export const SessionRoutes = lazy(() =>
437437
),
438438
async (c) => {
439439
const sessionID = c.req.valid("param").sessionID
440-
await SessionShare.share(sessionID)
441-
const session = await Session.get(sessionID)
440+
const session = await AppRuntime.runPromise(
441+
Effect.gen(function* () {
442+
const share = yield* SessionShare.Service
443+
const session = yield* Session.Service
444+
yield* share.share(sessionID)
445+
return yield* session.get(sessionID)
446+
}),
447+
)
442448
return c.json(session)
443449
},
444450
)
@@ -511,8 +517,14 @@ export const SessionRoutes = lazy(() =>
511517
),
512518
async (c) => {
513519
const sessionID = c.req.valid("param").sessionID
514-
await SessionShare.unshare(sessionID)
515-
const session = await Session.get(sessionID)
520+
const session = await AppRuntime.runPromise(
521+
Effect.gen(function* () {
522+
const share = yield* SessionShare.Service
523+
const session = yield* Session.Service
524+
yield* share.unshare(sessionID)
525+
return yield* session.get(sessionID)
526+
}),
527+
)
516528
return c.json(session)
517529
},
518530
)

packages/opencode/src/share/session.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import { makeRuntime } from "@/effect/run-service"
21
import { Session } from "@/session"
32
import { SessionID } from "@/session/schema"
43
import { SyncEvent } from "@/sync"
5-
import { fn } from "@/util/fn"
64
import { Effect, Layer, Scope, Context } from "effect"
75
import { Config } from "../config/config"
86
import { Flag } from "../flag/flag"
@@ -58,10 +56,4 @@ export namespace SessionShare {
5856
Layer.provide(Session.defaultLayer),
5957
Layer.provide(Config.defaultLayer),
6058
)
61-
62-
const { runPromise } = makeRuntime(Service, defaultLayer)
63-
64-
export const create = fn(Session.create.schema, (input) => runPromise((svc) => svc.create(input)))
65-
export const share = fn(SessionID.zod, (sessionID) => runPromise((svc) => svc.share(sessionID)))
66-
export const unshare = fn(SessionID.zod, (sessionID) => runPromise((svc) => svc.unshare(sessionID)))
6759
}

0 commit comments

Comments
 (0)