refactor: destroy ShareNext facade (#21965)
This commit is contained in:
@@ -219,11 +219,11 @@ Fully migrated (single namespace, InstanceState where needed, flattened facade):
|
|||||||
- [x] `Instruction` — `session/instruction.ts`
|
- [x] `Instruction` — `session/instruction.ts`
|
||||||
- [x] `Provider` — `provider/provider.ts`
|
- [x] `Provider` — `provider/provider.ts`
|
||||||
- [x] `Storage` — `storage/storage.ts`
|
- [x] `Storage` — `storage/storage.ts`
|
||||||
|
- [x] `ShareNext` — `share/share-next.ts`
|
||||||
|
|
||||||
Still open:
|
Still open:
|
||||||
|
|
||||||
- [ ] `SessionTodo` — `session/todo.ts`
|
- [ ] `SessionTodo` — `session/todo.ts`
|
||||||
- [ ] `ShareNext` — `share/share-next.ts`
|
|
||||||
- [ ] `SyncEvent` — `sync/index.ts`
|
- [ ] `SyncEvent` — `sync/index.ts`
|
||||||
- [ ] `Workspace` — `control-plane/workspace.ts`
|
- [ ] `Workspace` — `control-plane/workspace.ts`
|
||||||
|
|
||||||
@@ -336,4 +336,5 @@ For each service, the migration is roughly:
|
|||||||
|
|
||||||
### Migration log
|
### 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.
|
- `Storage` — migrated 2026-04-10. One production caller (`Session.diff`) and all storage.test.ts tests converted to effectful style. Facades and `makeRuntime` removed.
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { Instance } from "../../project/instance"
|
|||||||
import { ShareNext } from "../../share/share-next"
|
import { ShareNext } from "../../share/share-next"
|
||||||
import { EOL } from "os"
|
import { EOL } from "os"
|
||||||
import { Filesystem } from "../../util/filesystem"
|
import { Filesystem } from "../../util/filesystem"
|
||||||
|
import { AppRuntime } from "@/effect/app-runtime"
|
||||||
|
|
||||||
/** Discriminated union returned by the ShareNext API (GET /api/shares/:id/data) */
|
/** Discriminated union returned by the ShareNext API (GET /api/shares/:id/data) */
|
||||||
export type ShareData =
|
export type ShareData =
|
||||||
@@ -100,7 +101,7 @@ export const ImportCommand = cmd({
|
|||||||
if (isUrl) {
|
if (isUrl) {
|
||||||
const slug = parseShareUrl(args.file)
|
const slug = parseShareUrl(args.file)
|
||||||
if (!slug) {
|
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/<slug>`)
|
process.stdout.write(`Invalid URL format. Expected: ${baseUrl}/share/<slug>`)
|
||||||
process.stdout.write(EOL)
|
process.stdout.write(EOL)
|
||||||
return
|
return
|
||||||
@@ -108,7 +109,7 @@ export const ImportCommand = cmd({
|
|||||||
|
|
||||||
const parsed = new URL(args.file)
|
const parsed = new URL(args.file)
|
||||||
const baseUrl = parsed.origin
|
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 headers = shouldAttachShareAuthHeaders(args.file, req.baseUrl) ? req.headers : {}
|
||||||
|
|
||||||
const dataPath = req.api.data(slug)
|
const dataPath = req.api.data(slug)
|
||||||
|
|||||||
@@ -10,12 +10,13 @@ import { Bus } from "../bus"
|
|||||||
import { Command } from "../command"
|
import { Command } from "../command"
|
||||||
import { Instance } from "./instance"
|
import { Instance } from "./instance"
|
||||||
import { Log } from "@/util/log"
|
import { Log } from "@/util/log"
|
||||||
|
import { AppRuntime } from "@/effect/app-runtime"
|
||||||
import { ShareNext } from "@/share/share-next"
|
import { ShareNext } from "@/share/share-next"
|
||||||
|
|
||||||
export async function InstanceBootstrap() {
|
export async function InstanceBootstrap() {
|
||||||
Log.Default.info("bootstrapping", { directory: Instance.directory })
|
Log.Default.info("bootstrapping", { directory: Instance.directory })
|
||||||
await Plugin.init()
|
await Plugin.init()
|
||||||
ShareNext.init()
|
void AppRuntime.runPromise(ShareNext.Service.use((svc) => svc.init()))
|
||||||
Format.init()
|
Format.init()
|
||||||
await LSP.init()
|
await LSP.init()
|
||||||
File.init()
|
File.init()
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { FetchHttpClient, HttpClient, HttpClientRequest, HttpClientResponse } fr
|
|||||||
import { Account } from "@/account"
|
import { Account } from "@/account"
|
||||||
import { Bus } from "@/bus"
|
import { Bus } from "@/bus"
|
||||||
import { InstanceState } from "@/effect/instance-state"
|
import { InstanceState } from "@/effect/instance-state"
|
||||||
import { makeRuntime } from "@/effect/run-service"
|
|
||||||
import { Provider } from "@/provider/provider"
|
import { Provider } from "@/provider/provider"
|
||||||
import { ModelID, ProviderID } from "@/provider/schema"
|
import { ModelID, ProviderID } from "@/provider/schema"
|
||||||
import { Session } from "@/session"
|
import { Session } from "@/session"
|
||||||
@@ -348,26 +347,4 @@ export namespace ShareNext {
|
|||||||
Layer.provide(Provider.defaultLayer),
|
Layer.provide(Provider.defaultLayer),
|
||||||
Layer.provide(Session.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<Req> {
|
|
||||||
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))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user