fix: preserve runtime option defaults (#38118)

This commit is contained in:
Dax 2026-07-21 10:30:18 -04:00 committed by GitHub
commit 7243bd9e12
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 27 additions and 5 deletions

View file

@ -552,7 +552,7 @@ export const layer = (options?: Options) => Layer.effect(
),
)
const source = options?.url ?? "https://models.dev"
const source = options?.url || "https://models.dev"
const fetch = options?.fetch ?? true
const userAgent = `opencode/${InstallationChannel}/${InstallationVersion}/${options?.client ?? "cli"}`
const filepath = path.join(

View file

@ -236,6 +236,16 @@ describe("ModelsDev Service", () => {
}),
)
it.live("uses the default models URL when the configured URL is empty", () =>
Effect.gen(function* () {
const state = yield* Ref.make(initialState)
yield* ModelsDev.Service.use((service) => service.get()).pipe(
Effect.provide(buildLayer(state, { url: "", fetch: true })),
)
expect((yield* Ref.get(state)).calls[0]?.url).toBe("https://models.dev/api.json")
}),
)
it.live("get() is single-flight under concurrent calls", () =>
Effect.gen(function* () {
yield* writeCache(fixture)