fix: allow experimental flags to override umbrella (#29273)

This commit is contained in:
Aiden Cline 2026-05-25 16:42:34 -05:00 committed by GitHub
commit 633b5d6208
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 3 deletions

View file

@ -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"),

View file

@ -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({})))