fix(switch-agent): detect HTTP error responses from SDK client on TUI navigation

The v1 SDK client does not throw on 4xx/5xx — it resolves with an
{ error } object. navigateTuiToSession was treating any resolved promise
as success, silently misreporting failed navigation.
This commit is contained in:
ismeth
2026-03-19 13:56:02 +01:00
committed by YeonGyu-Kim
parent 0b604c8d35
commit 9a39c423d4
+5 -1
View File
@@ -70,11 +70,15 @@ async function navigateTuiToSession(client: SessionClient, sessionID: string): P
return false
}
try {
await httpClient.post({
const result = await httpClient.post({
url: "/tui/select-session",
body: { sessionID },
headers: { "Content-Type": "application/json" },
})
if (typeof result === "object" && result !== null && "error" in result) {
log("[switch-agent] TUI navigation returned error for session:", { sessionID, error: result.error })
return false
}
return true
} catch (error) {
log("[switch-agent] TUI navigation failed for session:", { sessionID, error })