Skip to content

The agent that grows with you

style(desktop): satisfy perfectionist lint on the 503 electron files

Axl Ibiza, MBA175565785a30
diff --git a/apps/desktop/electron/backend-health.test.ts b/apps/desktop/electron/backend-health.test.ts
index 128bd7f502a..21691bf3a0d 100644
--- a/apps/desktop/electron/backend-health.test.ts
+++ b/apps/desktop/electron/backend-health.test.ts
@@ -421,6 +421,7 @@ test('waitForHermesReady surfaces actionable error for cloud agent 503', async (
test('waitForHermesReady does not cloud-wrap non-cloud 503 errors', async () => {
const currentTime = { value: 0 }
+
try {
await waitForHermesReady('http://127.0.0.1:9000', {
fetchPublicJson: async () => {
@@ -509,6 +510,7 @@ test('makeNousCloudBackendDownError preserves legacy string-prefix compatibility
'https://ares-3009.agents.nousresearch.com',
new Error('503: Service Unavailable')
)
+
assert.ok(result)
assert.equal((result as any).isCloudBackendDown, true)
assert.equal((result as any).statusCode, 503)
diff --git a/apps/desktop/electron/backend-health.ts b/apps/desktop/electron/backend-health.ts
index ca3ae49520a..ff380f1390a 100644
--- a/apps/desktop/electron/backend-health.ts
+++ b/apps/desktop/electron/backend-health.ts
@@ -64,6 +64,7 @@ export function isServerSideHttpError(error: unknown): {
if (Number.isInteger(structured) && (structured === 502 || structured === 503 || structured === 504)) {
const detail = error.message
+
return { statusCode: structured, detail }
}
}
diff --git a/apps/desktop/electron/connection-config.test.ts b/apps/desktop/electron/connection-config.test.ts
index 55886761f86..b5478897973 100644
--- a/apps/desktop/electron/connection-config.test.ts
+++ b/apps/desktop/electron/connection-config.test.ts
@@ -15,7 +15,6 @@ import assert from 'node:assert/strict'
import { test } from 'vitest'
import { makeNousCloudBackendDownError } from './backend-health'
-
import {
apiRequestRegistryConnectionId,
AT_COOKIE_VARIANTS,
@@ -1173,11 +1172,13 @@ test('resolveTestWsUrl (oauth) requires a mintTicket function', async () => {
test('gatewayTicketFailure preserves a structured 503 statusCode as a transport failure', () => {
const source = new Error('upstream unavailable') as any
source.statusCode = 503
+
const wrapped = gatewayTicketFailure(
source,
'auth message',
'transport message'
)
+
assert.equal(wrapped.message, 'transport message')
assert.equal((wrapped as any).statusCode, 503)
assert.equal((wrapped as any).needsOauthLogin, undefined)
@@ -1188,11 +1189,13 @@ test('gatewayTicketFailure keeps 401 and 403 as reauth with needsOauthLogin', ()
for (const code of [401, 403]) {
const source = new Error(`HTTP ${code}`) as any
source.statusCode = code
+
const wrapped = gatewayTicketFailure(
source,
'auth message',
'transport message'
)
+
assert.equal(wrapped.message, 'auth message')
assert.equal((wrapped as any).needsOauthLogin, true)
assert.equal((wrapped as any).statusCode, code)
@@ -1205,11 +1208,13 @@ test('gatewayTicketFailure only copies an integer statusCode, not a message pref
// classifier (makeNousCloudBackendDownError) handles the prefix at the mint
// boundary. The wrapper must not invent an integer from the message.
const source = new Error('503: Service Unavailable') as any
+
const wrapped = gatewayTicketFailure(
source,
'auth message',
'transport message'
)
+
assert.equal((wrapped as any).statusCode, undefined)
assert.equal((wrapped as any).needsOauthLogin, undefined)
})
@@ -1227,10 +1232,12 @@ test('OAuth ticket-mint 503 surfaces the Cloud-down error (startup boundary)', (
// The exact production sequence from main.ts.
const cloudError = makeNousCloudBackendDownError(baseUrl, ticketErr)
+
if (cloudError !== null) {
assert.equal((cloudError as any).isCloudBackendDown, true)
assert.equal((cloudError as any).statusCode, 503)
assert.ok(cloudError.message.includes('Nous Cloud agent ares-3009.agents.nousresearch.com is down'))
+
return
}
@@ -1239,6 +1246,7 @@ test('OAuth ticket-mint 503 surfaces the Cloud-down error (startup boundary)', (
'auth',
'transport'
)
+
assert.fail(`expected Cloud-down classification, got wrapper: ${wrapped.message}`)
})
@@ -1255,6 +1263,7 @@ test('OAuth ticket-mint 401 stays on the reauth path (never Cloud-down)', () =>
'auth message',
'transport message'
)
+
assert.equal(wrapped.message, 'auth message')
assert.equal((wrapped as any).needsOauthLogin, true)
assert.equal((wrapped as any).statusCode, 401)
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index e5f94479e91..c7b3025bf68 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -10913,6 +10913,7 @@ async function startHermes() {
// only consumes the structured result (#85335).
const isCloudBackendDown =
Boolean(error && typeof error === 'object' && (error as any).isCloudBackendDown === true)
+
const statusCode = Number(
error && typeof error === 'object' && Number.isInteger((error as any).statusCode)
? (error as any).statusCode