fix(ui-tui): surface RPC errors and guard invalid gateway responses

This commit is contained in:
Brooklyn Nicholson 2026-04-13 14:17:52 -05:00
parent 0642b6cc53
commit cac1b1b724
4 changed files with 328 additions and 55 deletions

21
ui-tui/src/lib/rpc.ts Normal file
View file

@ -0,0 +1,21 @@
export type RpcResult = Record<string, any>
export const asRpcResult = (value: unknown): RpcResult | null => {
if (!value || typeof value !== 'object' || Array.isArray(value)) {
return null
}
return value as RpcResult
}
export const rpcErrorMessage = (err: unknown) => {
if (err instanceof Error && err.message) {
return err.message
}
if (typeof err === 'string' && err.trim()) {
return err
}
return 'request failed'
}