fix(app): provide pty socket auth if available from desktop (#8210)

This commit is contained in:
Brendan Allan
2026-01-13 21:08:19 +08:00
committed by GitHub
parent f3b7d2f786
commit 35cb06e0e4
3 changed files with 8 additions and 5 deletions

View File

@@ -33,7 +33,7 @@ const Loading = () => <div class="size-full flex items-center justify-center tex
declare global {
interface Window {
__OPENCODE__?: { updaterEnabled?: boolean }
__OPENCODE__?: { updaterEnabled?: boolean; serverPassword?: string }
}
}

View File

@@ -100,9 +100,12 @@ export const Terminal = (props: TerminalProps) => {
const mod = await import("ghostty-web")
ghostty = await mod.Ghostty.load()
const socket = new WebSocket(
sdk.url + `/pty/${local.pty.id}/connect?directory=${encodeURIComponent(sdk.directory)}`,
)
const url = new URL(sdk.url + `/pty/${local.pty.id}/connect?directory=${encodeURIComponent(sdk.directory)}`)
if (window.__OPENCODE__?.serverPassword) {
url.username = "opencode"
url.password = window.__OPENCODE__?.serverPassword
}
const socket = new WebSocket(url)
ws = socket
const t = new mod.Terminal({