Skip to content

The agent that grows with you

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

HexLab9848f2ccb65c64
diff --git a/apps/desktop/electron/backend-health.ts b/apps/desktop/electron/backend-health.ts
index ff380f1390a..5b08fecefb4 100644
--- a/apps/desktop/electron/backend-health.ts
+++ b/apps/desktop/electron/backend-health.ts
@@ -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)
}
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index 04b1db74094..591569b9870 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -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