fix: validate serverUrl port before tmux pane spawn (fixes #2729)

This commit is contained in:
YeonGyu-Kim
2026-03-23 18:09:31 +09:00
parent d886ac701f
commit 0810e37240
2 changed files with 33 additions and 2 deletions
+10 -2
View File
@@ -73,10 +73,18 @@ export class TmuxSessionManager {
this.tmuxConfig = tmuxConfig
this.deps = deps
const defaultPort = process.env.OPENCODE_PORT ?? "4096"
const fallbackUrl = `http://localhost:${defaultPort}`
try {
this.serverUrl = ctx.serverUrl?.toString() ?? `http://localhost:${defaultPort}`
const raw = ctx.serverUrl?.toString()
if (raw) {
const parsed = new URL(raw)
const port = parsed.port || (parsed.protocol === 'https:' ? '443' : '80')
this.serverUrl = port === '0' ? fallbackUrl : raw
} else {
this.serverUrl = fallbackUrl
}
} catch {
this.serverUrl = `http://localhost:${defaultPort}`
this.serverUrl = fallbackUrl
}
this.sourcePaneId = deps.getCurrentPaneId()
this.pollingManager = new TmuxPollingManager(