Compare commits

...
Author SHA1 Message Date
Kit Langton 37fb3dbf10 fix(core): honor OPENCODE_DISABLE_MODELS_FETCH in core 2026-09-02 16:38:31 -04:00
2 changed files with 24 additions and 1 deletions
+5 -1
View File
@@ -594,7 +594,11 @@ export const layer = (options?: Options) =>
)
const source = options?.url || defaultSource
const fetch = options?.fetch ?? true
// The CLI maps OPENCODE_DISABLE_MODELS_FETCH into options.fetch; the
// unconfigured default node (core tests, embedded hosts) reads it here so
// the env var disables the network fetch everywhere.
const disabled = process.env.OPENCODE_DISABLE_MODELS_FETCH
const fetch = options?.fetch ?? !(disabled === "1" || disabled?.toLowerCase() === "true")
const userAgent = App.useragent(app)
const key = cacheKey(source)
const ttl = Duration.minutes(5)
+19
View File
@@ -336,6 +336,25 @@ describe("ModelsDev Service", () => {
}),
)
// test/preload.ts sets OPENCODE_DISABLE_MODELS_FETCH=true for the whole run;
// the unconfigured default node must honor it so tests that boot the real
// Location graph never reach models.opencode.ai.
it.live("default node skips the background fetch when OPENCODE_DISABLE_MODELS_FETCH is set", () =>
Effect.gen(function* () {
expect(process.env.OPENCODE_DISABLE_MODELS_FETCH).toBe("true")
const cache = makeCache()
const state = yield* Ref.make(initialState)
const layer = Layer.fresh(
AppNodeBuilder.build(ModelsDev.node, [
LayerNodePlatform.httpClient.replace(Layer.succeed(HttpClient.HttpClient, makeMockClient(state))),
KV.node.replace(makeMockKV(cache)),
]),
)
yield* Effect.sleep("50 millis").pipe(Effect.provide(layer))
expect((yield* Ref.get(state)).calls).toEqual([])
}),
)
it.live("get() is single-flight under concurrent calls", () =>
Effect.gen(function* () {
const cache = makeCache()