mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-07 00:51:34 +00:00
fix(cli): avoid AppRuntime re-entry for network options (#26052)
Some checks are pending
deploy / deploy (push) Waiting to run
Some checks are pending
deploy / deploy (push) Waiting to run
This commit is contained in:
parent
889f979c0b
commit
63a175b50d
4 changed files with 8 additions and 8 deletions
|
|
@ -22,7 +22,7 @@ export const AcpCommand = effectCmd({
|
|||
},
|
||||
handler: Effect.fn("Cli.acp")(function* (args) {
|
||||
process.env.OPENCODE_CLIENT = "acp"
|
||||
const opts = yield* Effect.promise(() => resolveNetworkOptions(args))
|
||||
const opts = yield* resolveNetworkOptions(args)
|
||||
const server = yield* Effect.promise(() => Server.listen(opts))
|
||||
|
||||
const sdk = createOpencodeClient({
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export const ServeCommand = effectCmd({
|
|||
if (!Flag.OPENCODE_SERVER_PASSWORD) {
|
||||
console.log("Warning: OPENCODE_SERVER_PASSWORD is not set; server is unsecured.")
|
||||
}
|
||||
const opts = yield* Effect.promise(() => resolveNetworkOptions(args))
|
||||
const opts = yield* resolveNetworkOptions(args)
|
||||
const server = yield* Effect.promise(() => Server.listen(opts))
|
||||
console.log(`opencode server listening on http://${server.hostname}:${server.port}`)
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ export const WebCommand = effectCmd({
|
|||
if (!Flag.OPENCODE_SERVER_PASSWORD) {
|
||||
UI.println(UI.Style.TEXT_WARNING_BOLD + "! OPENCODE_SERVER_PASSWORD is not set; server is unsecured.")
|
||||
}
|
||||
const opts = yield* Effect.promise(() => resolveNetworkOptions(args))
|
||||
const opts = yield* resolveNetworkOptions(args)
|
||||
const server = yield* Effect.promise(() => Server.listen(opts))
|
||||
UI.empty()
|
||||
UI.println(UI.logo(" "))
|
||||
|
|
@ -72,7 +72,7 @@ export const WebCommand = effectCmd({
|
|||
}
|
||||
|
||||
// Open localhost in browser
|
||||
open(localhostUrl.toString()).catch(() => {})
|
||||
open(localhostUrl).catch(() => {})
|
||||
} else {
|
||||
const displayUrl = server.url.toString()
|
||||
UI.println(UI.Style.TEXT_INFO_BOLD + " Web interface: ", UI.Style.TEXT_NORMAL, displayUrl)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import type { Argv, InferredOptionTypes } from "yargs"
|
||||
import { Config } from "@/config/config"
|
||||
import { AppRuntime } from "@/effect/app-runtime"
|
||||
import { Effect } from "effect"
|
||||
|
||||
const options = {
|
||||
port: {
|
||||
|
|
@ -36,10 +36,10 @@ export type NetworkOptions = InferredOptionTypes<typeof options>
|
|||
export function withNetworkOptions<T>(yargs: Argv<T>) {
|
||||
return yargs.options(options)
|
||||
}
|
||||
export async function resolveNetworkOptions(args: NetworkOptions) {
|
||||
const config = await AppRuntime.runPromise(Config.Service.use((cfg) => cfg.getGlobal()))
|
||||
export const resolveNetworkOptions = Effect.fn("Cli.resolveNetworkOptions")(function* (args: NetworkOptions) {
|
||||
const config = yield* Config.Service.use((cfg) => cfg.getGlobal())
|
||||
return resolveNetworkOptionsNoConfig(args, config)
|
||||
}
|
||||
})
|
||||
|
||||
export function resolveNetworkOptionsNoConfig(args: NetworkOptions, config?: Config.Info) {
|
||||
const portExplicitlySet = process.argv.includes("--port")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue