summaryrefslogtreecommitdiffhomepage
path: root/packages/app/src/components
diff options
context:
space:
mode:
authorOpeOginni <[email protected]>2026-03-19 14:32:11 +0100
committerGitHub <[email protected]>2026-03-19 13:32:11 +0000
commitbd4527b4f28333a3c49faba43dc03d99e1e02ae2 (patch)
treefbbe7344885a0ab34f79b324e23cf48f23afdd9e /packages/app/src/components
parentf4a9fe29a3b9ef4050d5d4ec45c1da74fcd42a21 (diff)
downloadopencode-bd4527b4f28333a3c49faba43dc03d99e1e02ae2.tar.gz
opencode-bd4527b4f28333a3c49faba43dc03d99e1e02ae2.zip
fix(desktop): remote server switching (#17214)
Co-authored-by: Brendan Allan <[email protected]>
Diffstat (limited to 'packages/app/src/components')
-rw-r--r--packages/app/src/components/dialog-select-server.tsx2
-rw-r--r--packages/app/src/components/status-popover.tsx2
-rw-r--r--packages/app/src/components/terminal.tsx24
3 files changed, 17 insertions, 11 deletions
diff --git a/packages/app/src/components/dialog-select-server.tsx b/packages/app/src/components/dialog-select-server.tsx
index eb039c14d..f8d14cbb9 100644
--- a/packages/app/src/components/dialog-select-server.tsx
+++ b/packages/app/src/components/dialog-select-server.tsx
@@ -291,8 +291,8 @@ export function DialogSelectServer() {
navigate("/")
return
}
- server.setActive(ServerConnection.key(conn))
navigate("/")
+ queueMicrotask(() => server.setActive(ServerConnection.key(conn)))
}
const handleAddChange = (value: string) => {
diff --git a/packages/app/src/components/status-popover.tsx b/packages/app/src/components/status-popover.tsx
index 61facb84e..063205f0c 100644
--- a/packages/app/src/components/status-popover.tsx
+++ b/packages/app/src/components/status-popover.tsx
@@ -277,8 +277,8 @@ export function StatusPopover() {
aria-disabled={isBlocked()}
onClick={() => {
if (isBlocked()) return
- server.setActive(key)
navigate("/")
+ queueMicrotask(() => server.setActive(key))
}}
>
<ServerHealthIndicator health={health[key]} />
diff --git a/packages/app/src/components/terminal.tsx b/packages/app/src/components/terminal.tsx
index 9297d6626..aed46f126 100644
--- a/packages/app/src/components/terminal.tsx
+++ b/packages/app/src/components/terminal.tsx
@@ -165,6 +165,12 @@ export const Terminal = (props: TerminalProps) => {
const theme = useTheme()
const language = useLanguage()
const server = useServer()
+ const directory = sdk.directory
+ const client = sdk.client
+ const url = sdk.url
+ const auth = server.current?.http
+ const username = auth?.username ?? "opencode"
+ const password = auth?.password ?? ""
let container!: HTMLDivElement
const [local, others] = splitProps(props, ["pty", "class", "classList", "autoFocus", "onConnect", "onConnectError"])
const id = local.pty.id
@@ -215,7 +221,7 @@ export const Terminal = (props: TerminalProps) => {
}
const pushSize = (cols: number, rows: number) => {
- return sdk.client.pty
+ return client.pty
.update({
ptyID: id,
size: { cols, rows },
@@ -474,7 +480,7 @@ export const Terminal = (props: TerminalProps) => {
}
const gone = () =>
- sdk.client.pty
+ client.pty
.get({ ptyID: id })
.then(() => false)
.catch((err) => {
@@ -506,14 +512,14 @@ export const Terminal = (props: TerminalProps) => {
if (disposed) return
drop?.()
- const url = new URL(sdk.url + `/pty/${id}/connect`)
- url.searchParams.set("directory", sdk.directory)
- url.searchParams.set("cursor", String(seek))
- url.protocol = url.protocol === "https:" ? "wss:" : "ws:"
- url.username = server.current?.http.username ?? "opencode"
- url.password = server.current?.http.password ?? ""
+ const next = new URL(url + `/pty/${id}/connect`)
+ next.searchParams.set("directory", directory)
+ next.searchParams.set("cursor", String(seek))
+ next.protocol = next.protocol === "https:" ? "wss:" : "ws:"
+ next.username = username
+ next.password = password
- const socket = new WebSocket(url)
+ const socket = new WebSocket(next)
socket.binaryType = "arraybuffer"
ws = socket