Remove CLI from electron app (#17803)

Co-authored-by: LukeParkerDev <10430890+Hona@users.noreply.github.com>
This commit is contained in:
Brendan Allan
2026-04-09 13:18:46 +08:00
committed by GitHub
parent 9c1c061b84
commit ee23043d64
38 changed files with 284 additions and 521 deletions
+11 -8
View File
@@ -1,7 +1,6 @@
import type { Target } from "@/control-plane/types"
import { lazy } from "@/util/lazy"
import { Hono } from "hono"
import { upgradeWebSocket } from "hono/bun"
import type { UpgradeWebSocket } from "hono/ws"
const hop = new Set([
"connection",
@@ -53,10 +52,10 @@ function send(ws: { send(data: string | ArrayBuffer | Uint8Array): void }, data:
return ws.send(data)
}
const app = lazy(() =>
const app = (upgrade: UpgradeWebSocket) =>
new Hono().get(
"/__workspace_ws",
upgradeWebSocket((c) => {
upgrade((c) => {
const url = c.req.header("x-opencode-proxy-url")
const queue: Msg[] = []
let remote: WebSocket | undefined
@@ -96,8 +95,7 @@ const app = lazy(() =>
},
}
}),
),
)
)
export namespace ServerProxy {
export function http(target: Extract<Target, { type: "remote" }>, req: Request) {
@@ -112,13 +110,18 @@ export namespace ServerProxy {
)
}
export function websocket(target: Extract<Target, { type: "remote" }>, req: Request, env: unknown) {
export function websocket(
upgrade: UpgradeWebSocket,
target: Extract<Target, { type: "remote" }>,
req: Request,
env: unknown,
) {
const url = new URL(req.url)
url.pathname = "/__workspace_ws"
url.search = ""
const next = new Headers(req.headers)
next.set("x-opencode-proxy-url", socket(target.url))
return app().fetch(
return app(upgrade).fetch(
new Request(url, {
method: req.method,
headers: next,