MCPcopy Index your code
hub / github.com/anomalyco/opencode / waitReady

Function waitReady

packages/opencode/test/server/httpapi-experimental.test.ts:34–54  ·  view source on GitHub ↗
(input: { directory?: string; name?: string })

Source from the content-addressed store, hash-verified

32}
33
34function waitReady(input: { directory?: string; name?: string }) {
35 return Effect.gen(function* () {
36 const ready = yield* Deferred.make<void>()
37 const on = (event: GlobalEvent) => {
38 if (event.payload.type !== Worktree.Event.Ready.type) return
39 if (input.directory && event.directory !== input.directory) return
40 if (input.name && event.payload.properties.name !== input.name) return
41 Deferred.doneUnsafe(ready, Effect.void)
42 }
43
44 GlobalBus.on("event", on)
45 yield* Effect.addFinalizer(() => Effect.sync(() => GlobalBus.off("event", on)))
46
47 return yield* Deferred.await(ready).pipe(
48 Effect.timeoutOrElse({
49 duration: "10 seconds",
50 orElse: () => Effect.fail(new Error("timed out waiting for worktree.ready")),
51 }),
52 )
53 })
54}
55
56function insertAccount() {
57 return Effect.acquireRelease(

Callers 4

withCreatedWorktreeFunction · 0.85
worktree.test.tsFile · 0.85
createWorktreeScopedFunction · 0.85
withCreatedWorktreeFunction · 0.85

Calls 4

onMethod · 0.80
syncMethod · 0.80
offMethod · 0.80
makeMethod · 0.45

Tested by

no test coverage detected