fix: allow experimental flags to override umbrella (#29273)
This commit is contained in:
@@ -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({})))
|
||||
|
||||
Reference in New Issue
Block a user