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:
@@ -70,11 +70,15 @@ async function navigateTuiToSession(client: SessionClient, sessionID: string): P
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await httpClient.post({
|
const result = await httpClient.post({
|
||||||
url: "/tui/select-session",
|
url: "/tui/select-session",
|
||||||
body: { sessionID },
|
body: { sessionID },
|
||||||
headers: { "Content-Type": "application/json" },
|
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
|
return true
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log("[switch-agent] TUI navigation failed for session:", { sessionID, error })
|
log("[switch-agent] TUI navigation failed for session:", { sessionID, error })
|
||||||
|
|||||||
Reference in New Issue
Block a user