fix(instance): restore InstanceBootstrap init parameter for non-Effec… (#25449)
Co-authored-by: Dax Raad <d@ironbay.co>
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
import { Instance } from "../project/instance"
|
import { Instance } from "../project/instance"
|
||||||
import { InstanceStore } from "../project/instance-store"
|
import { InstanceStore } from "../project/instance-store"
|
||||||
|
import { getBootstrapRunEffect } from "../effect/app-runtime"
|
||||||
|
|
||||||
export async function bootstrap<T>(directory: string, cb: () => Promise<T>) {
|
export async function bootstrap<T>(directory: string, cb: () => Promise<T>) {
|
||||||
return Instance.provide({
|
return Instance.provide({
|
||||||
directory,
|
directory,
|
||||||
|
init: await getBootstrapRunEffect(),
|
||||||
fn: async () => {
|
fn: async () => {
|
||||||
try {
|
try {
|
||||||
const result = await cb()
|
const result = await cb()
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { GlobalBus } from "@/bus/global"
|
|||||||
import { Flag } from "@opencode-ai/core/flag/flag"
|
import { Flag } from "@opencode-ai/core/flag/flag"
|
||||||
import { writeHeapSnapshot } from "node:v8"
|
import { writeHeapSnapshot } from "node:v8"
|
||||||
import { Heap } from "@/cli/heap"
|
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"
|
import { ensureProcessMetadata } from "@opencode-ai/core/util/opencode-process"
|
||||||
|
|
||||||
ensureProcessMetadata("worker")
|
ensureProcessMetadata("worker")
|
||||||
@@ -77,6 +77,7 @@ export const rpc = {
|
|||||||
async checkUpgrade(input: { directory: string }) {
|
async checkUpgrade(input: { directory: string }) {
|
||||||
await Instance.provide({
|
await Instance.provide({
|
||||||
directory: input.directory,
|
directory: input.directory,
|
||||||
|
init: await getBootstrapRunEffect(),
|
||||||
fn: async () => {
|
fn: async () => {
|
||||||
await upgrade().catch(() => {})
|
await upgrade().catch(() => {})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Layer, ManagedRuntime } from "effect"
|
import { Effect, Layer, ManagedRuntime } from "effect"
|
||||||
import { attach } from "./run-service"
|
import { attach } from "./run-service"
|
||||||
import * as Observability from "@opencode-ai/core/effect/observability"
|
import * as Observability from "@opencode-ai/core/effect/observability"
|
||||||
|
|
||||||
@@ -40,6 +40,7 @@ import { Command } from "@/command"
|
|||||||
import { Truncate } from "@/tool/truncate"
|
import { Truncate } from "@/tool/truncate"
|
||||||
import { ToolRegistry } from "@/tool/registry"
|
import { ToolRegistry } from "@/tool/registry"
|
||||||
import { Format } from "@/format"
|
import { Format } from "@/format"
|
||||||
|
import { InstanceBootstrap } from "@/project/bootstrap"
|
||||||
import { InstanceStore } from "@/project/instance-store"
|
import { InstanceStore } from "@/project/instance-store"
|
||||||
import { Project } from "@/project/project"
|
import { Project } from "@/project/project"
|
||||||
import { Vcs } from "@/project/vcs"
|
import { Vcs } from "@/project/vcs"
|
||||||
@@ -93,6 +94,7 @@ export const AppLayer = Layer.mergeAll(
|
|||||||
Truncate.defaultLayer,
|
Truncate.defaultLayer,
|
||||||
ToolRegistry.defaultLayer,
|
ToolRegistry.defaultLayer,
|
||||||
Format.defaultLayer,
|
Format.defaultLayer,
|
||||||
|
InstanceBootstrap.defaultLayer,
|
||||||
InstanceStore.defaultLayer,
|
InstanceStore.defaultLayer,
|
||||||
Project.defaultLayer,
|
Project.defaultLayer,
|
||||||
Vcs.defaultLayer,
|
Vcs.defaultLayer,
|
||||||
@@ -130,3 +132,15 @@ export const AppRuntime: Runtime = {
|
|||||||
},
|
},
|
||||||
dispose: () => rt.dispose(),
|
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 type { MiddlewareHandler } from "hono"
|
||||||
import { Instance } from "@/project/instance"
|
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 { AppFileSystem } from "@opencode-ai/core/filesystem"
|
||||||
import { WorkspaceContext } from "@/control-plane/workspace-context"
|
import { WorkspaceContext } from "@/control-plane/workspace-context"
|
||||||
import { WorkspaceID } from "@/control-plane/schema"
|
import { WorkspaceID } from "@/control-plane/schema"
|
||||||
@@ -23,6 +23,7 @@ export function InstanceMiddleware(workspaceID?: WorkspaceID): MiddlewareHandler
|
|||||||
async fn() {
|
async fn() {
|
||||||
return Instance.provide({
|
return Instance.provide({
|
||||||
directory,
|
directory,
|
||||||
|
init: await getBootstrapRunEffect(),
|
||||||
async fn() {
|
async fn() {
|
||||||
return next()
|
return next()
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import z from "zod"
|
|||||||
import { ProjectID } from "@/project/schema"
|
import { ProjectID } from "@/project/schema"
|
||||||
import { errors } from "../../error"
|
import { errors } from "../../error"
|
||||||
import { lazy } from "@/util/lazy"
|
import { lazy } from "@/util/lazy"
|
||||||
import { AppRuntime } from "@/effect/app-runtime"
|
import { getBootstrapRunEffect } from "@/effect/app-runtime"
|
||||||
import { jsonRequest, runRequest } from "./trace"
|
import { jsonRequest, runRequest } from "./trace"
|
||||||
|
|
||||||
export const ProjectRoutes = lazy(() =>
|
export const ProjectRoutes = lazy(() =>
|
||||||
@@ -82,7 +82,7 @@ export const ProjectRoutes = lazy(() =>
|
|||||||
Project.Service.use((svc) => svc.initGit({ directory: dir, project: prev })),
|
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)
|
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)
|
return c.json(next)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import { WorkspaceID } from "@/control-plane/schema"
|
|||||||
import { WorkspaceContext } from "@/control-plane/workspace-context"
|
import { WorkspaceContext } from "@/control-plane/workspace-context"
|
||||||
import { Workspace } from "@/control-plane/workspace"
|
import { Workspace } from "@/control-plane/workspace"
|
||||||
import { Flag } from "@opencode-ai/core/flag/flag"
|
import { Flag } from "@opencode-ai/core/flag/flag"
|
||||||
|
import { getBootstrapRunEffect, AppRuntime } from "@/effect/app-runtime"
|
||||||
import { Instance } from "@/project/instance"
|
import { Instance } from "@/project/instance"
|
||||||
import { Session } from "@/session/session"
|
import { Session } from "@/session/session"
|
||||||
import { SessionID } from "@/session/schema"
|
import { SessionID } from "@/session/schema"
|
||||||
import { AppRuntime } from "@/effect/app-runtime"
|
|
||||||
import { Effect } from "effect"
|
import { Effect } from "effect"
|
||||||
import * as Log from "@opencode-ai/core/util/log"
|
import * as Log from "@opencode-ai/core/util/log"
|
||||||
import { ServerProxy } from "./proxy"
|
import { ServerProxy } from "./proxy"
|
||||||
@@ -94,11 +94,13 @@ export function WorkspaceRouterMiddleware(upgrade: UpgradeWebSocket): Middleware
|
|||||||
const target = await adapter.target(workspace)
|
const target = await adapter.target(workspace)
|
||||||
|
|
||||||
if (target.type === "local") {
|
if (target.type === "local") {
|
||||||
|
const init = await getBootstrapRunEffect()
|
||||||
return WorkspaceContext.provide({
|
return WorkspaceContext.provide({
|
||||||
workspaceID: WorkspaceID.make(workspaceID),
|
workspaceID: WorkspaceID.make(workspaceID),
|
||||||
fn: () =>
|
fn: () =>
|
||||||
Instance.provide({
|
Instance.provide({
|
||||||
directory: target.directory,
|
directory: target.directory,
|
||||||
|
init,
|
||||||
async fn() {
|
async fn() {
|
||||||
return next()
|
return next()
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user