fix(desktop): latch unsigned OAuth boots so the Sign in overlay stays put

No token and no cookie cannot self-heal. Tag that throw with
isReauthRequired so boot stops retrying and Sign in stays clickable.
Leave needsOauthLogin-only ticket 401s retryable for AT/RT rotation.
This commit is contained in:
HexLab98
2026-08-23 08:09:08 +07:00
committed by brooklyn!
parent 175054c14b
commit 48f2ccb65c
2 changed files with 24 additions and 8 deletions
+17
View File
@@ -38,6 +38,10 @@ export interface HermesReadyOptions {
export const REMOTE_SESSION_EXPIRED_MESSAGE =
'Your remote gateway session has expired. Open Settings → Gateway and click "Sign in" again.'
export const REMOTE_UNSIGNED_OAUTH_MESSAGE =
'Remote Hermes gateway uses OAuth, but you are not signed in. ' +
'Open Settings → Gateway and click "Sign in", or switch back to Local.'
/**
* True for HTTP 502/503/504 from the backend — a server-side fault, not a
* connectivity or auth issue. These keep polling in the readiness loop but,
@@ -200,6 +204,19 @@ export function makeReauthRequiredError(detail?: string): Error {
return error
}
/**
* No native token and no live cookie: boot cannot self-heal. Must carry
* `isReauthRequired` so startHermes latches; `needsOauthLogin` alone only
* drives Sign in copy and would retry after #88070, hiding the overlay.
*/
export function makeUnsignedOauthError(): Error {
const error = new Error(REMOTE_UNSIGNED_OAUTH_MESSAGE) as any
error.needsOauthLogin = true
error.isReauthRequired = true
return error
}
export function isReauthRequiredError(error: unknown): boolean {
return Boolean((error as any)?.isReauthRequired)
}
+7 -8
View File
@@ -35,7 +35,12 @@ import { stopBackendChild as stopBackendChildImpl, stopBackendTreesForUpdate } f
import { dashboardFallbackArgs, sourceDeclaresServe } from './backend-command'
import { createBackendConnectionState } from './backend-connection-state'
import { buildDesktopBackendEnv, hermesManagedNodePathEntries, normalizeHermesHomeRoot } from './backend-env'
import { isReauthRequiredError, makeNousCloudBackendDownError, waitForHermesReady } from './backend-health'
import {
isReauthRequiredError,
makeNousCloudBackendDownError,
makeUnsignedOauthError,
waitForHermesReady
} from './backend-health'
import { backendCommandMatches, createBackendOwnership, createBackendShutdownCoordinator } from './backend-ownership'
import {
canImportHermesCli,
@@ -9008,13 +9013,7 @@ async function buildRemoteConnection(
!oauthSessionIsLive(hasNativeSession(baseUrl), await hasLiveOauthSession(baseUrl)) &&
oauthGuardMayHardFail(await gatewayAuthProviders(baseUrl, remoteHeaders))
) {
const err = new Error(
'Remote Hermes gateway uses OAuth, but you are not signed in. ' +
'Open Settings → Gateway and click "Sign in", or switch back to Local.'
) as any
err.needsOauthLogin = true
throw err
throw makeUnsignedOauthError()
}
let ticket