Skip to content

Commit ee4c774

Browse files
authored
fix(cli): avoid AppRuntime re-entry for network options (anomalyco#26052)
1 parent a61d560 commit ee4c774

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

packages/opencode/src/cli/cmd/acp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const AcpCommand = effectCmd({
2222
},
2323
handler: Effect.fn("Cli.acp")(function* (args) {
2424
process.env.OPENCODE_CLIENT = "acp"
25-
const opts = yield* Effect.promise(() => resolveNetworkOptions(args))
25+
const opts = yield* resolveNetworkOptions(args)
2626
const server = yield* Effect.promise(() => Server.listen(opts))
2727

2828
const sdk = createOpencodeClient({

packages/opencode/src/cli/cmd/serve.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const ServeCommand = effectCmd({
1515
if (!Flag.OPENCODE_SERVER_PASSWORD) {
1616
console.log("Warning: OPENCODE_SERVER_PASSWORD is not set; server is unsecured.")
1717
}
18-
const opts = yield* Effect.promise(() => resolveNetworkOptions(args))
18+
const opts = yield* resolveNetworkOptions(args)
1919
const server = yield* Effect.promise(() => Server.listen(opts))
2020
console.log(`opencode server listening on http://${server.hostname}:${server.port}`)
2121

packages/opencode/src/cli/cmd/web.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const WebCommand = effectCmd({
4040
if (!Flag.OPENCODE_SERVER_PASSWORD) {
4141
UI.println(UI.Style.TEXT_WARNING_BOLD + "! OPENCODE_SERVER_PASSWORD is not set; server is unsecured.")
4242
}
43-
const opts = yield* Effect.promise(() => resolveNetworkOptions(args))
43+
const opts = yield* resolveNetworkOptions(args)
4444
const server = yield* Effect.promise(() => Server.listen(opts))
4545
UI.empty()
4646
UI.println(UI.logo(" "))
@@ -72,7 +72,7 @@ export const WebCommand = effectCmd({
7272
}
7373

7474
// Open localhost in browser
75-
open(localhostUrl.toString()).catch(() => {})
75+
open(localhostUrl).catch(() => {})
7676
} else {
7777
const displayUrl = server.url.toString()
7878
UI.println(UI.Style.TEXT_INFO_BOLD + " Web interface: ", UI.Style.TEXT_NORMAL, displayUrl)

packages/opencode/src/cli/network.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Argv, InferredOptionTypes } from "yargs"
22
import { Config } from "@/config/config"
3-
import { AppRuntime } from "@/effect/app-runtime"
3+
import { Effect } from "effect"
44

55
const options = {
66
port: {
@@ -36,10 +36,10 @@ export type NetworkOptions = InferredOptionTypes<typeof options>
3636
export function withNetworkOptions<T>(yargs: Argv<T>) {
3737
return yargs.options(options)
3838
}
39-
export async function resolveNetworkOptions(args: NetworkOptions) {
40-
const config = await AppRuntime.runPromise(Config.Service.use((cfg) => cfg.getGlobal()))
39+
export const resolveNetworkOptions = Effect.fn("Cli.resolveNetworkOptions")(function* (args: NetworkOptions) {
40+
const config = yield* Config.Service.use((cfg) => cfg.getGlobal())
4141
return resolveNetworkOptionsNoConfig(args, config)
42-
}
42+
})
4343

4444
export function resolveNetworkOptionsNoConfig(args: NetworkOptions, config?: Config.Info) {
4545
const portExplicitlySet = process.argv.includes("--port")

0 commit comments

Comments
 (0)