Problem
The Desktop Hub REST client does not match Hub Server's response envelope.
Relevant paths:
hub-server/internal/handler/response.go: successful responses are returned as { "code": "ok", "data": ... }, while failures are returned as { "code": ..., "message": ... }.
app/desktop/src/api/hubClient.ts: request<T> returns res.json() directly for successful responses, so callers receive the envelope instead of the typed data payload.
app/desktop/src/api/hubClient.ts: the error path only checks body.error.message, but Hub failures use top-level code and message fields.
app/desktop/src/__tests__/hubClient.test.ts: tests mock bare endpoint payloads such as mockAuthResponse, mockUser, and session arrays, so they do not exercise the real Hub envelope.
Impact
Desktop calls such as login, me, session listing, contact listing, and device registration can receive { code, data } where the UI expects fields like access_token, id, or array items directly. Error messages from Hub can also be reduced to generic HTTP status text because the client does not parse the actual { code, message } failure shape.
Expected behavior
hubClient.request<T> should unwrap successful Hub responses and return body.data to callers. It should also parse top-level Hub error responses before falling back to any legacy { error: ... } shape or status text.
Suggested fix
Update request<T> to detect the Hub envelope and return data on success, preserving compatibility only if a route intentionally returns a bare payload. Update error parsing to prefer top-level code and message. Then change hubClient tests to mock the real { code: "ok", data: ... } and { code, message } response shapes.
Problem
The Desktop Hub REST client does not match Hub Server's response envelope.
Relevant paths:
hub-server/internal/handler/response.go: successful responses are returned as{ "code": "ok", "data": ... }, while failures are returned as{ "code": ..., "message": ... }.app/desktop/src/api/hubClient.ts:request<T>returnsres.json()directly for successful responses, so callers receive the envelope instead of the typeddatapayload.app/desktop/src/api/hubClient.ts: the error path only checksbody.error.message, but Hub failures use top-levelcodeandmessagefields.app/desktop/src/__tests__/hubClient.test.ts: tests mock bare endpoint payloads such asmockAuthResponse,mockUser, and session arrays, so they do not exercise the real Hub envelope.Impact
Desktop calls such as login,
me, session listing, contact listing, and device registration can receive{ code, data }where the UI expects fields likeaccess_token,id, or array items directly. Error messages from Hub can also be reduced to generic HTTP status text because the client does not parse the actual{ code, message }failure shape.Expected behavior
hubClient.request<T>should unwrap successful Hub responses and returnbody.datato callers. It should also parse top-level Hub error responses before falling back to any legacy{ error: ... }shape or status text.Suggested fix
Update
request<T>to detect the Hub envelope and returndataon success, preserving compatibility only if a route intentionally returns a bare payload. Update error parsing to prefer top-levelcodeandmessage. Then changehubClienttests to mock the real{ code: "ok", data: ... }and{ code, message }response shapes.