Skip to content

Commit 7e4939e

Browse files
committed
perf(opencode): make vcs init non-blocking by forking branch resolution
Vcs.init now forks the InstanceState resolution into the layer scope instead of awaiting it, so startup no longer blocks on git branch introspection (rev-parse, branch lookups). The state still resolves lazily on first read. Cherry-picked from anomalyco/opencode 3f7df08 (anomalyco#22771); adapted to fork's effect import style (ServiceMap rather than Context). Verified: typecheck clean, vcs.test.ts 10/10 pass. Note: companion snapshot perf patch (a992d8b) was evaluated but skipped — fork's snapshot/index.ts uses a different staging path (git add --sparse .) and never invokes check-ignore on the candidate list, so the ENAMETOOLONG bug and the stdin-pathspec speedup do not apply.
1 parent 441188c commit 7e4939e

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • packages/opencode/src/project

packages/opencode/src/project/vcs.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Effect, Layer, ServiceMap } from "effect"
1+
import { Effect, Layer, ServiceMap, Scope } from "effect"
22
import path from "path"
33
import { Bus } from "@/bus"
44
import { BusEvent } from "@/bus/bus-event"
@@ -210,6 +210,7 @@ export namespace Vcs {
210210
Effect.gen(function* () {
211211
const fs = yield* AppFileSystem.Service
212212
const git = yield* Git.Service
213+
const scope = yield* Scope.Scope
213214
const state = yield* InstanceState.make<State>(
214215
Effect.fn("Vcs.state")((ctx) =>
215216
Effect.gen(function* () {
@@ -248,7 +249,7 @@ export namespace Vcs {
248249

249250
return Service.of({
250251
init: Effect.fn("Vcs.init")(function* () {
251-
yield* InstanceState.get(state)
252+
yield* InstanceState.get(state).pipe(Effect.forkIn(scope))
252253
}),
253254
branch: Effect.fn("Vcs.branch")(function* () {
254255
return yield* InstanceState.use(state, (x) => x.current)

0 commit comments

Comments
 (0)