refactor(flags): move auto share to runtime flags (#27611)

This commit is contained in:
Shoubhit Dash
2026-05-15 03:58:26 +05:30
committed by GitHub
parent d34a0194ec
commit cb4f5cdea9
6 changed files with 21 additions and 5 deletions

View File

@@ -3,7 +3,7 @@ import { SessionID } from "@/session/schema"
import { SyncEvent } from "@/sync"
import { Effect, Layer, Scope, Context } from "effect"
import { Config } from "@/config/config"
import { Flag } from "@opencode-ai/core/flag/flag"
import { RuntimeFlags } from "@/effect/runtime-flags"
import * as ShareNext from "./share-next"
export interface Interface {
@@ -22,6 +22,7 @@ export const layer = Layer.effect(
const shareNext = yield* ShareNext.Service
const scope = yield* Scope.Scope
const sync = yield* SyncEvent.Service
const flags = yield* RuntimeFlags.Service
const share = Effect.fn("SessionShare.share")(function* (sessionID: SessionID) {
const conf = yield* cfg.get()
@@ -40,7 +41,7 @@ export const layer = Layer.effect(
const result = yield* session.create(input)
if (result.parentID) return result
const conf = yield* cfg.get()
if (!(Flag.OPENCODE_AUTO_SHARE || conf.share === "auto")) return result
if (!(flags.autoShare || conf.share === "auto")) return result
yield* share(result.id).pipe(Effect.ignore, Effect.forkIn(scope))
return result
})
@@ -54,6 +55,7 @@ export const defaultLayer = layer.pipe(
Layer.provide(Session.defaultLayer),
Layer.provide(Config.defaultLayer),
Layer.provide(SyncEvent.defaultLayer),
Layer.provide(RuntimeFlags.defaultLayer),
)
export * as SessionShare from "./session"