refactor(cli): convert web + account to effectCmd (instance: false) (#25512)

This commit is contained in:
Kit Langton
2026-05-02 21:59:35 -04:00
committed by GitHub
parent e98c291866
commit 1409a0715c
2 changed files with 37 additions and 29 deletions

View File

@@ -1,6 +1,7 @@
import { Effect } from "effect"
import { Server } from "../../server/server"
import { UI } from "../ui"
import { cmd } from "./cmd"
import { effectCmd } from "../effect-cmd"
import { withNetworkOptions, resolveNetworkOptions } from "../network"
import { Flag } from "@opencode-ai/core/flag/flag"
import open from "open"
@@ -28,16 +29,19 @@ function getNetworkIPs() {
return results
}
export const WebCommand = cmd({
export const WebCommand = effectCmd({
command: "web",
builder: (yargs) => withNetworkOptions(yargs),
describe: "start opencode server and open web interface",
handler: async (args) => {
// Server loads instances per-request via x-opencode-directory header — no
// ambient project InstanceContext needed at startup.
instance: false,
handler: Effect.fn("Cli.web")(function* (args) {
if (!Flag.OPENCODE_SERVER_PASSWORD) {
UI.println(UI.Style.TEXT_WARNING_BOLD + "! OPENCODE_SERVER_PASSWORD is not set; server is unsecured.")
}
const opts = await resolveNetworkOptions(args)
const server = await Server.listen(opts)
const opts = yield* Effect.promise(() => resolveNetworkOptions(args))
const server = yield* Effect.promise(() => Server.listen(opts))
UI.empty()
UI.println(UI.logo(" "))
UI.empty()
@@ -75,7 +79,6 @@ export const WebCommand = cmd({
open(displayUrl).catch(() => {})
}
await new Promise(() => {})
await server.stop()
},
yield* Effect.never
}),
})