mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-08 10:10:58 +00:00
fix(instance): restore InstanceBootstrap init parameter for non-Effec… (#25449)
Co-authored-by: Dax Raad <d@ironbay.co>
This commit is contained in:
parent
05b82a6a30
commit
430bde9e9b
6 changed files with 26 additions and 6 deletions
|
|
@ -1,9 +1,11 @@
|
|||
import { Instance } from "../project/instance"
|
||||
import { InstanceStore } from "../project/instance-store"
|
||||
import { getBootstrapRunEffect } from "../effect/app-runtime"
|
||||
|
||||
export async function bootstrap<T>(directory: string, cb: () => Promise<T>) {
|
||||
return Instance.provide({
|
||||
directory,
|
||||
init: await getBootstrapRunEffect(),
|
||||
fn: async () => {
|
||||
try {
|
||||
const result = await cb()
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import { GlobalBus } from "@/bus/global"
|
|||
import { Flag } from "@opencode-ai/core/flag/flag"
|
||||
import { writeHeapSnapshot } from "node:v8"
|
||||
import { Heap } from "@/cli/heap"
|
||||
import { AppRuntime } from "@/effect/app-runtime"
|
||||
import { AppRuntime, getBootstrapRunEffect } from "@/effect/app-runtime"
|
||||
import { ensureProcessMetadata } from "@opencode-ai/core/util/opencode-process"
|
||||
|
||||
ensureProcessMetadata("worker")
|
||||
|
|
@ -77,6 +77,7 @@ export const rpc = {
|
|||
async checkUpgrade(input: { directory: string }) {
|
||||
await Instance.provide({
|
||||
directory: input.directory,
|
||||
init: await getBootstrapRunEffect(),
|
||||
fn: async () => {
|
||||
await upgrade().catch(() => {})
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Layer, ManagedRuntime } from "effect"
|
||||
import { Effect, Layer, ManagedRuntime } from "effect"
|
||||
import { attach } from "./run-service"
|
||||
import * as Observability from "@opencode-ai/core/effect/observability"
|
||||
|
||||
|
|
@ -40,6 +40,7 @@ import { Command } from "@/command"
|
|||
import { Truncate } from "@/tool/truncate"
|
||||
import { ToolRegistry } from "@/tool/registry"
|
||||
import { Format } from "@/format"
|
||||
import { InstanceBootstrap } from "@/project/bootstrap"
|
||||
import { InstanceStore } from "@/project/instance-store"
|
||||
import { Project } from "@/project/project"
|
||||
import { Vcs } from "@/project/vcs"
|
||||
|
|
@ -93,6 +94,7 @@ export const AppLayer = Layer.mergeAll(
|
|||
Truncate.defaultLayer,
|
||||
ToolRegistry.defaultLayer,
|
||||
Format.defaultLayer,
|
||||
InstanceBootstrap.defaultLayer,
|
||||
InstanceStore.defaultLayer,
|
||||
Project.defaultLayer,
|
||||
Vcs.defaultLayer,
|
||||
|
|
@ -130,3 +132,15 @@ export const AppRuntime: Runtime = {
|
|||
},
|
||||
dispose: () => rt.dispose(),
|
||||
}
|
||||
|
||||
let bootstrapRun: Promise<Effect.Effect<void>>
|
||||
export function getBootstrapRunEffect(): Promise<Effect.Effect<void>> {
|
||||
if (!bootstrapRun) {
|
||||
bootstrapRun = AppRuntime.runPromise(
|
||||
Effect.gen(function* () {
|
||||
return (yield* InstanceBootstrap.Service).run
|
||||
}),
|
||||
)
|
||||
}
|
||||
return bootstrapRun
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import type { MiddlewareHandler } from "hono"
|
||||
import { Instance } from "@/project/instance"
|
||||
import { AppRuntime } from "@/effect/app-runtime"
|
||||
import { getBootstrapRunEffect } from "@/effect/app-runtime"
|
||||
import { AppFileSystem } from "@opencode-ai/core/filesystem"
|
||||
import { WorkspaceContext } from "@/control-plane/workspace-context"
|
||||
import { WorkspaceID } from "@/control-plane/schema"
|
||||
|
|
@ -23,6 +23,7 @@ export function InstanceMiddleware(workspaceID?: WorkspaceID): MiddlewareHandler
|
|||
async fn() {
|
||||
return Instance.provide({
|
||||
directory,
|
||||
init: await getBootstrapRunEffect(),
|
||||
async fn() {
|
||||
return next()
|
||||
},
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import z from "zod"
|
|||
import { ProjectID } from "@/project/schema"
|
||||
import { errors } from "../../error"
|
||||
import { lazy } from "@/util/lazy"
|
||||
import { AppRuntime } from "@/effect/app-runtime"
|
||||
import { getBootstrapRunEffect } from "@/effect/app-runtime"
|
||||
import { jsonRequest, runRequest } from "./trace"
|
||||
|
||||
export const ProjectRoutes = lazy(() =>
|
||||
|
|
@ -82,7 +82,7 @@ export const ProjectRoutes = lazy(() =>
|
|||
Project.Service.use((svc) => svc.initGit({ directory: dir, project: prev })),
|
||||
)
|
||||
if (next.id === prev.id && next.vcs === prev.vcs && next.worktree === prev.worktree) return c.json(next)
|
||||
await InstanceStore.reloadInstance({ directory: dir, worktree: dir, project: next })
|
||||
await InstanceStore.reloadInstance({ directory: dir, worktree: dir, project: next, init: await getBootstrapRunEffect() })
|
||||
return c.json(next)
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ import { WorkspaceID } from "@/control-plane/schema"
|
|||
import { WorkspaceContext } from "@/control-plane/workspace-context"
|
||||
import { Workspace } from "@/control-plane/workspace"
|
||||
import { Flag } from "@opencode-ai/core/flag/flag"
|
||||
import { getBootstrapRunEffect, AppRuntime } from "@/effect/app-runtime"
|
||||
import { Instance } from "@/project/instance"
|
||||
import { Session } from "@/session/session"
|
||||
import { SessionID } from "@/session/schema"
|
||||
import { AppRuntime } from "@/effect/app-runtime"
|
||||
import { Effect } from "effect"
|
||||
import * as Log from "@opencode-ai/core/util/log"
|
||||
import { ServerProxy } from "./proxy"
|
||||
|
|
@ -94,11 +94,13 @@ export function WorkspaceRouterMiddleware(upgrade: UpgradeWebSocket): Middleware
|
|||
const target = await adapter.target(workspace)
|
||||
|
||||
if (target.type === "local") {
|
||||
const init = await getBootstrapRunEffect()
|
||||
return WorkspaceContext.provide({
|
||||
workspaceID: WorkspaceID.make(workspaceID),
|
||||
fn: () =>
|
||||
Instance.provide({
|
||||
directory: target.directory,
|
||||
init,
|
||||
async fn() {
|
||||
return next()
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue