refactor(project): yield instance context in bootstrap (#25204)
This commit is contained in:
@@ -7,7 +7,7 @@ import * as Project from "./project"
|
|||||||
import * as Vcs from "./vcs"
|
import * as Vcs from "./vcs"
|
||||||
import { Bus } from "../bus"
|
import { Bus } from "../bus"
|
||||||
import { Command } from "../command"
|
import { Command } from "../command"
|
||||||
import { Instance } from "./instance"
|
import { InstanceState } from "@/effect/instance-state"
|
||||||
import * as Log from "@opencode-ai/core/util/log"
|
import * as Log from "@opencode-ai/core/util/log"
|
||||||
import { FileWatcher } from "@/file/watcher"
|
import { FileWatcher } from "@/file/watcher"
|
||||||
import { ShareNext } from "@/share/share-next"
|
import { ShareNext } from "@/share/share-next"
|
||||||
@@ -15,7 +15,8 @@ import * as Effect from "effect/Effect"
|
|||||||
import { Config } from "@/config/config"
|
import { Config } from "@/config/config"
|
||||||
|
|
||||||
export const InstanceBootstrap = Effect.gen(function* () {
|
export const InstanceBootstrap = Effect.gen(function* () {
|
||||||
Log.Default.info("bootstrapping", { directory: Instance.directory })
|
const ctx = yield* InstanceState.context
|
||||||
|
Log.Default.info("bootstrapping", { directory: ctx.directory })
|
||||||
// everything depends on config so eager load it for nice traces
|
// everything depends on config so eager load it for nice traces
|
||||||
yield* Config.Service.use((svc) => svc.get())
|
yield* Config.Service.use((svc) => svc.get())
|
||||||
// Plugin can mutate config so it has to be initialized before anything else.
|
// Plugin can mutate config so it has to be initialized before anything else.
|
||||||
@@ -32,10 +33,11 @@ export const InstanceBootstrap = Effect.gen(function* () {
|
|||||||
].map((s) => Effect.forkDetach(s.use((i) => i.init()))),
|
].map((s) => Effect.forkDetach(s.use((i) => i.init()))),
|
||||||
).pipe(Effect.withSpan("InstanceBootstrap.init"))
|
).pipe(Effect.withSpan("InstanceBootstrap.init"))
|
||||||
|
|
||||||
|
const projectID = ctx.project.id
|
||||||
yield* Bus.Service.use((svc) =>
|
yield* Bus.Service.use((svc) =>
|
||||||
svc.subscribeCallback(Command.Event.Executed, async (payload) => {
|
svc.subscribeCallback(Command.Event.Executed, async (payload) => {
|
||||||
if (payload.properties.name === Command.Default.INIT) {
|
if (payload.properties.name === Command.Default.INIT) {
|
||||||
Project.setInitialized(Instance.project.id)
|
Project.setInitialized(projectID)
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user