The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): recover cloud auth through portal (#96170)
Gille46f091b93e8f
diff --git a/apps/desktop/src/components/boot-failure-overlay.test.tsx b/apps/desktop/src/components/boot-failure-overlay.test.tsxindex 6d5e8810dda..fedfdd2b57e 100644--- a/apps/desktop/src/components/boot-failure-overlay.test.tsx+++ b/apps/desktop/src/components/boot-failure-overlay.test.tsx@@ -146,6 +146,51 @@ describe('BootFailureOverlay', () => {}})+ it('recovers a cloud connection through the portal cascade instead of native OAuth', async () => {+ const gatewayUrl = 'https://agent-1.agents.nousresearch.com'+ const logout = vi.fn().mockResolvedValue({ ok: true, connected: false })+ const nativeLogin = vi.fn().mockResolvedValue({ ok: true, connected: false })+ const cloudStatus = vi.fn().mockResolvedValue({ portalBaseUrl: 'https://portal.nousresearch.com', signedIn: false })++ const cloudLogin = vi.fn().mockResolvedValue({+ ok: true,+ portalBaseUrl: 'https://portal.nousresearch.com',+ signedIn: true+ })++ const cloudAgentSignIn = vi.fn().mockResolvedValue({ baseUrl: gatewayUrl, connected: false })++ const restore = stubDesktop(+ {+ ...remoteToken,+ mode: 'cloud',+ remoteAuthMode: 'oauth',+ remoteOauthConnected: false,+ remoteTokenSet: false,+ remoteUrl: gatewayUrl+ },+ {+ cloud: { status: cloudStatus, login: cloudLogin, agentSignIn: cloudAgentSignIn },+ oauthLoginConnectionConfig: nativeLogin,+ oauthLogoutConnectionConfig: logout,+ probeConnectionConfig: vi.fn().mockResolvedValue({ providers: [{ id: 'nous', type: 'oauth' }] })+ }+ )++ try {+ render(<BootFailureOverlay />)+ fireEvent.click(await screen.findByRole('button', { name: /sign in/i }))++ await waitFor(() => expect(cloudAgentSignIn).toHaveBeenCalledWith(gatewayUrl))+ expect(logout).toHaveBeenCalledWith(gatewayUrl)+ expect(cloudStatus).toHaveBeenCalledTimes(1)+ expect(cloudLogin).toHaveBeenCalledTimes(1)+ expect(nativeLogin).not.toHaveBeenCalled()+ } finally {+ restore()+ }+ })+it('shows the Nous Cloud down recovery when the backend flags isCloudBackendDown', async () => {const restore = stubDesktop(remoteToken)$desktopBoot.set({diff --git a/apps/desktop/src/components/boot-failure-overlay.tsx b/apps/desktop/src/components/boot-failure-overlay.tsxindex 8c7e47f07d8..f001e50f291 100644--- a/apps/desktop/src/components/boot-failure-overlay.tsx+++ b/apps/desktop/src/components/boot-failure-overlay.tsx@@ -163,10 +163,10 @@ export function BootFailureOverlay() {setBusy(null)}- // Clear this gateway's stale auth first, then open its login window- // (username/password form or OAuth redirect — the desktop drives both). On a- // successful sign-in the cookie is re-established; reload so boot mints a fresh- // ticket against a live session without disturbing other saved gateways.+ // Clear this gateway's stale auth first, then re-establish it through the+ // connection's owning login flow. Hermes Cloud must reuse its portal session+ // and per-agent cascade; generic remote gateways use native/embedded OAuth.+ // Reload after success so boot mints a fresh ticket against the new session.const signInRemote = async () => {if (!remoteReauth) {return@@ -175,10 +175,39 @@ export function BootFailureOverlay() {setBusy('signin')try {- await window.hermesDesktop?.oauthLogoutConnectionConfig?.(remoteReauth.url)- const result = await window.hermesDesktop?.oauthLoginConnectionConfig(remoteReauth.url)+ const desktop = window.hermesDesktop++ await desktop?.oauthLogoutConnectionConfig?.(remoteReauth.url)++ let result: { connected?: boolean } | undefined++ if (connectionConfig?.mode === 'cloud' && desktop?.cloud) {+ const status = await desktop.cloud.status()++ if (!status.signedIn) {+ const login = await desktop.cloud.login()++ if (!login.signedIn) {+ notify({+ kind: 'warning',+ title: t.boot.failure.signInIncompleteTitle,+ message: t.boot.failure.signInIncompleteMessage+ })++ return+ }+ }++ result = await desktop.cloud.agentSignIn(remoteReauth.url)+ } else {+ result = await desktop?.oauthLoginConnectionConfig(remoteReauth.url)+ }if (result?.connected) {+ if (connectionConfig?.mode === 'cloud') {+ await desktop?.resetBootstrap().catch(() => undefined)+ }+notify({ kind: 'success', title: t.boot.failure.signedInTitle, message: t.boot.failure.signedInMessage })window.location.reload()