mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-04 18:59:50 +00:00
fix(reference): own legacy warmup before core fork
This commit is contained in:
parent
cfe8327e19
commit
330faabf9a
2 changed files with 8 additions and 2 deletions
|
|
@ -9,7 +9,7 @@ import { ProjectReference } from "@opencode-ai/core/project-reference"
|
|||
import { ConfigReference } from "@opencode-ai/core/config/reference"
|
||||
import { RepositoryCache } from "@opencode-ai/core/repository-cache"
|
||||
import { AbsolutePath } from "@opencode-ai/core/schema"
|
||||
import { Context, Effect, Layer, Schema } from "effect"
|
||||
import { Context, Effect, Layer, Schema, Scope } from "effect"
|
||||
|
||||
export type Resolved = ProjectReference.Resolved
|
||||
|
||||
|
|
@ -51,6 +51,7 @@ export const layer = Layer.effect(
|
|||
Service,
|
||||
Effect.gen(function* () {
|
||||
const config = yield* Config.Service
|
||||
const scope = yield* Scope.Scope
|
||||
const state = yield* InstanceState.make(
|
||||
Effect.fn("Reference.state")(function* (ctx) {
|
||||
const { Config: ConfigV2 } = yield* Effect.promise(() => import("@opencode-ai/core/config"))
|
||||
|
|
@ -93,6 +94,8 @@ export const layer = Layer.effect(
|
|||
return Service.of({
|
||||
init: Effect.fn("Reference.init")(function* () {
|
||||
yield* InstanceState.get(state)
|
||||
// Own the cached warmup from the long-lived legacy scope before the core layer's scheduled fork can claim it.
|
||||
yield* ensure().pipe(Effect.forkIn(scope, { startImmediately: true }), Effect.asVoid)
|
||||
}),
|
||||
list: Effect.fn("Reference.list")(function* () {
|
||||
return yield* InstanceState.useEffect(state, (service) => service.list())
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { afterEach, describe, expect } from "bun:test"
|
||||
import path from "path"
|
||||
import { pathToFileURL } from "url"
|
||||
import { Effect, Layer } from "effect"
|
||||
import { FSUtil } from "@opencode-ai/core/fs-util"
|
||||
import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner"
|
||||
|
|
@ -202,7 +203,9 @@ describe("reference", () => {
|
|||
const resolved = yield* reference.get("docs")
|
||||
expect(resolved?.kind).toBe("git")
|
||||
if (resolved?.kind === "git") {
|
||||
expect(resolved.reference.remote).toBe(`file://${remoteRoot}/opencode-reference-init/repo.git`)
|
||||
expect(resolved.reference.remote).toBe(
|
||||
new URL("opencode-reference-init/repo.git", pathToFileURL(remoteRoot + path.sep)).href,
|
||||
)
|
||||
}
|
||||
}),
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue