From 9e7045eaec4a28aee20bd889981932f73b1edd79 Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Fri, 10 Apr 2026 22:03:06 -0400 Subject: [PATCH] refactor: destroy ShareNext facade (#21965) --- packages/opencode/specs/effect-migration.md | 3 ++- packages/opencode/src/cli/cmd/import.ts | 5 +++-- packages/opencode/src/project/bootstrap.ts | 3 ++- packages/opencode/src/share/share-next.ts | 23 --------------------- 4 files changed, 7 insertions(+), 27 deletions(-) diff --git a/packages/opencode/specs/effect-migration.md b/packages/opencode/specs/effect-migration.md index ab90d6a44c..7aa94d874d 100644 --- a/packages/opencode/specs/effect-migration.md +++ b/packages/opencode/specs/effect-migration.md @@ -219,11 +219,11 @@ Fully migrated (single namespace, InstanceState where needed, flattened facade): - [x] `Instruction` — `session/instruction.ts` - [x] `Provider` — `provider/provider.ts` - [x] `Storage` — `storage/storage.ts` +- [x] `ShareNext` — `share/share-next.ts` Still open: - [ ] `SessionTodo` — `session/todo.ts` -- [ ] `ShareNext` — `share/share-next.ts` - [ ] `SyncEvent` — `sync/index.ts` - [ ] `Workspace` — `control-plane/workspace.ts` @@ -336,4 +336,5 @@ For each service, the migration is roughly: ### Migration log +- `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. - `Storage` — migrated 2026-04-10. One production caller (`Session.diff`) and all storage.test.ts tests converted to effectful style. Facades and `makeRuntime` removed. diff --git a/packages/opencode/src/cli/cmd/import.ts b/packages/opencode/src/cli/cmd/import.ts index a0c0101fea..1232f07422 100644 --- a/packages/opencode/src/cli/cmd/import.ts +++ b/packages/opencode/src/cli/cmd/import.ts @@ -10,6 +10,7 @@ import { Instance } from "../../project/instance" import { ShareNext } from "../../share/share-next" import { EOL } from "os" import { Filesystem } from "../../util/filesystem" +import { AppRuntime } from "@/effect/app-runtime" /** Discriminated union returned by the ShareNext API (GET /api/shares/:id/data) */ export type ShareData = @@ -100,7 +101,7 @@ export const ImportCommand = cmd({ if (isUrl) { const slug = parseShareUrl(args.file) if (!slug) { - const baseUrl = await ShareNext.url() + const baseUrl = await AppRuntime.runPromise(ShareNext.Service.use((svc) => svc.url())) process.stdout.write(`Invalid URL format. Expected: ${baseUrl}/share/`) process.stdout.write(EOL) return @@ -108,7 +109,7 @@ export const ImportCommand = cmd({ const parsed = new URL(args.file) const baseUrl = parsed.origin - const req = await ShareNext.request() + const req = await AppRuntime.runPromise(ShareNext.Service.use((svc) => svc.request())) const headers = shouldAttachShareAuthHeaders(args.file, req.baseUrl) ? req.headers : {} const dataPath = req.api.data(slug) diff --git a/packages/opencode/src/project/bootstrap.ts b/packages/opencode/src/project/bootstrap.ts index a8ad84297a..9ddcca5569 100644 --- a/packages/opencode/src/project/bootstrap.ts +++ b/packages/opencode/src/project/bootstrap.ts @@ -10,12 +10,13 @@ import { Bus } from "../bus" import { Command } from "../command" import { Instance } from "./instance" import { Log } from "@/util/log" +import { AppRuntime } from "@/effect/app-runtime" import { ShareNext } from "@/share/share-next" export async function InstanceBootstrap() { Log.Default.info("bootstrapping", { directory: Instance.directory }) await Plugin.init() - ShareNext.init() + void AppRuntime.runPromise(ShareNext.Service.use((svc) => svc.init())) Format.init() await LSP.init() File.init() diff --git a/packages/opencode/src/share/share-next.ts b/packages/opencode/src/share/share-next.ts index 26b2d2570a..11fc08e24d 100644 --- a/packages/opencode/src/share/share-next.ts +++ b/packages/opencode/src/share/share-next.ts @@ -4,7 +4,6 @@ import { FetchHttpClient, HttpClient, HttpClientRequest, HttpClientResponse } fr import { Account } from "@/account" import { Bus } from "@/bus" import { InstanceState } from "@/effect/instance-state" -import { makeRuntime } from "@/effect/run-service" import { Provider } from "@/provider/provider" import { ModelID, ProviderID } from "@/provider/schema" import { Session } from "@/session" @@ -348,26 +347,4 @@ export namespace ShareNext { Layer.provide(Provider.defaultLayer), Layer.provide(Session.defaultLayer), ) - - const { runPromise } = makeRuntime(Service, defaultLayer) - - export async function init() { - return runPromise((svc) => svc.init()) - } - - export async function url() { - return runPromise((svc) => svc.url()) - } - - export async function request(): Promise { - return runPromise((svc) => svc.request()) - } - - export async function create(sessionID: SessionID) { - return runPromise((svc) => svc.create(sessionID)) - } - - export async function remove(sessionID: SessionID) { - return runPromise((svc) => svc.remove(sessionID)) - } }