fix: allow experimental flags to override umbrella (#29273)
This commit is contained in:
parent
d595e472b3
commit
633b5d6208
3 changed files with 24 additions and 3 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { Config, ConfigProvider, Context, Effect, Layer } from "effect"
|
||||
import { Config, ConfigProvider, Context, Effect, Layer, Option } from "effect"
|
||||
import { ConfigService } from "@/effect/config-service"
|
||||
|
||||
const bool = (name: string) => Config.boolean(name).pipe(Config.withDefault(false))
|
||||
|
|
@ -9,7 +9,9 @@ const positiveInteger = (name: string) =>
|
|||
)
|
||||
const experimental = bool("OPENCODE_EXPERIMENTAL")
|
||||
const enabledByExperimental = (name: string) =>
|
||||
Config.all({ experimental, enabled: bool(name) }).pipe(Config.map((flags) => flags.experimental || flags.enabled))
|
||||
Config.all({ experimental, enabled: Config.boolean(name).pipe(Config.option) }).pipe(
|
||||
Config.map((flags) => Option.getOrElse(flags.enabled, () => flags.experimental)),
|
||||
)
|
||||
|
||||
export class Service extends ConfigService.Service<Service>()("@opencode/RuntimeFlags", {
|
||||
autoShare: bool("OPENCODE_AUTO_SHARE"),
|
||||
|
|
|
|||
|
|
@ -213,6 +213,21 @@ describe("RuntimeFlags", () => {
|
|||
}),
|
||||
)
|
||||
|
||||
it.effect("specific experimental flags override OPENCODE_EXPERIMENTAL", () =>
|
||||
Effect.gen(function* () {
|
||||
const flags = yield* readFlags.pipe(
|
||||
Effect.provide(
|
||||
fromConfig({
|
||||
OPENCODE_EXPERIMENTAL: "true",
|
||||
OPENCODE_EXPERIMENTAL_ICON_DISCOVERY: "false",
|
||||
}),
|
||||
),
|
||||
)
|
||||
|
||||
expect(flags.experimentalIconDiscovery).toBe(false)
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("experimentalOxfmt defaults to false", () =>
|
||||
Effect.gen(function* () {
|
||||
const flags = yield* readFlags.pipe(Effect.provide(fromConfig({})))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue