Skip to content

Commit 9e7045e

Browse files
authored
refactor: destroy ShareNext facade (#21965)
1 parent a17ac02 commit 9e7045e

4 files changed

Lines changed: 7 additions & 27 deletions

File tree

packages/opencode/specs/effect-migration.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,11 @@ Fully migrated (single namespace, InstanceState where needed, flattened facade):
219219
- [x] `Instruction``session/instruction.ts`
220220
- [x] `Provider``provider/provider.ts`
221221
- [x] `Storage``storage/storage.ts`
222+
- [x] `ShareNext``share/share-next.ts`
222223

223224
Still open:
224225

225226
- [ ] `SessionTodo``session/todo.ts`
226-
- [ ] `ShareNext``share/share-next.ts`
227227
- [ ] `SyncEvent``sync/index.ts`
228228
- [ ] `Workspace``control-plane/workspace.ts`
229229

@@ -336,4 +336,5 @@ For each service, the migration is roughly:
336336

337337
### Migration log
338338

339+
- `ShareNext` — migrated 2026-04-11. Swapped remaining async callers to `AppRuntime.runPromise(ShareNext.Service.use(...))`, removed the `makeRuntime(...)` facade, and kept instance bootstrap on the shared app runtime.
339340
- `Storage` — migrated 2026-04-10. One production caller (`Session.diff`) and all storage.test.ts tests converted to effectful style. Facades and `makeRuntime` removed.

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Instance } from "../../project/instance"
1010
import { ShareNext } from "../../share/share-next"
1111
import { EOL } from "os"
1212
import { Filesystem } from "../../util/filesystem"
13+
import { AppRuntime } from "@/effect/app-runtime"
1314

1415
/** Discriminated union returned by the ShareNext API (GET /api/shares/:id/data) */
1516
export type ShareData =
@@ -100,15 +101,15 @@ export const ImportCommand = cmd({
100101
if (isUrl) {
101102
const slug = parseShareUrl(args.file)
102103
if (!slug) {
103-
const baseUrl = await ShareNext.url()
104+
const baseUrl = await AppRuntime.runPromise(ShareNext.Service.use((svc) => svc.url()))
104105
process.stdout.write(`Invalid URL format. Expected: ${baseUrl}/share/<slug>`)
105106
process.stdout.write(EOL)
106107
return
107108
}
108109

109110
const parsed = new URL(args.file)
110111
const baseUrl = parsed.origin
111-
const req = await ShareNext.request()
112+
const req = await AppRuntime.runPromise(ShareNext.Service.use((svc) => svc.request()))
112113
const headers = shouldAttachShareAuthHeaders(args.file, req.baseUrl) ? req.headers : {}
113114

114115
const dataPath = req.api.data(slug)

packages/opencode/src/project/bootstrap.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ import { Bus } from "../bus"
1010
import { Command } from "../command"
1111
import { Instance } from "./instance"
1212
import { Log } from "@/util/log"
13+
import { AppRuntime } from "@/effect/app-runtime"
1314
import { ShareNext } from "@/share/share-next"
1415

1516
export async function InstanceBootstrap() {
1617
Log.Default.info("bootstrapping", { directory: Instance.directory })
1718
await Plugin.init()
18-
ShareNext.init()
19+
void AppRuntime.runPromise(ShareNext.Service.use((svc) => svc.init()))
1920
Format.init()
2021
await LSP.init()
2122
File.init()

packages/opencode/src/share/share-next.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { FetchHttpClient, HttpClient, HttpClientRequest, HttpClientResponse } fr
44
import { Account } from "@/account"
55
import { Bus } from "@/bus"
66
import { InstanceState } from "@/effect/instance-state"
7-
import { makeRuntime } from "@/effect/run-service"
87
import { Provider } from "@/provider/provider"
98
import { ModelID, ProviderID } from "@/provider/schema"
109
import { Session } from "@/session"
@@ -348,26 +347,4 @@ export namespace ShareNext {
348347
Layer.provide(Provider.defaultLayer),
349348
Layer.provide(Session.defaultLayer),
350349
)
351-
352-
const { runPromise } = makeRuntime(Service, defaultLayer)
353-
354-
export async function init() {
355-
return runPromise((svc) => svc.init())
356-
}
357-
358-
export async function url() {
359-
return runPromise((svc) => svc.url())
360-
}
361-
362-
export async function request(): Promise<Req> {
363-
return runPromise((svc) => svc.request())
364-
}
365-
366-
export async function create(sessionID: SessionID) {
367-
return runPromise((svc) => svc.create(sessionID))
368-
}
369-
370-
export async function remove(sessionID: SessionID) {
371-
return runPromise((svc) => svc.remove(sessionID))
372-
}
373350
}

0 commit comments

Comments
 (0)