Skip to content

The agent that grows with you

Merge remote-tracking branch 'origin/main' into ethie/pm-clean

ethernet46840bdf82f8
diff --cc apps/desktop/src/app/settings/gateway-settings.test.tsx
index d3c86fc61f8,c51ad22afaf..f740a2e3336
--- a/apps/desktop/src/app/settings/gateway-settings.test.tsx
+++ b/apps/desktop/src/app/settings/gateway-settings.test.tsx
@@@ -1,8 -1,7 +1,9 @@@
+ import { GatewayReauthRequiredError } from '@hermes/shared'
-import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'
+import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { deferred } from '@/test/deferred'
+
// Collect the component graph before the behavioral test deadline starts.
import { GatewaySettings } from './gateway-settings'
diff --cc apps/desktop/src/app/settings/gateway-settings.tsx
index b332a43c04f,525301995a5..da789224da7
--- a/apps/desktop/src/app/settings/gateway-settings.tsx
+++ b/apps/desktop/src/app/settings/gateway-settings.tsx
@@@ -1,8 -1,7 +1,9 @@@
+ import { isGatewayReauthRequired } from '@hermes/shared'
import { useStore } from '@nanostores/react'
-import { useEffect, useMemo, useRef, useState } from 'react'
+import { useEffect, useRef, useState } from 'react'
+import { RemoteSetupFields } from '@/components/remote-setup/fields'
+import { useRemoteSetup } from '@/components/remote-setup/use-remote-setup'
import { Button } from '@/components/ui/button'
import { ConfirmDialog } from '@/components/ui/confirm-dialog'
import { Input } from '@/components/ui/input'
diff --cc apps/desktop/src/components/boot-failure-overlay.tsx
index 8040044b88c,a3a7eb10001..0e1642a587c
--- a/apps/desktop/src/components/boot-failure-overlay.tsx
+++ b/apps/desktop/src/components/boot-failure-overlay.tsx
@@@ -7,9 -7,9 +7,10 @@@ import { DialogPortalContainerContext
import { ErrorIcon } from '@/components/ui/error-state'
import { Loader } from '@/components/ui/loader'
import { LogView } from '@/components/ui/log-view'
--import type { DesktopConnectionConfig } from '@/global'
++import type { DesktopConnectionConfig, DesktopOauthLoginResult } from '@/global'
import { useI18n } from '@/i18n'
+ import { reestablishCloudAgentSession } from '@/lib/cloud-agent-session'
+import { DESKTOP_DOCS_URL } from '@/lib/docs'
import { openExternalLink } from '@/lib/external-link'
import { ChevronLeft, ExternalLink, FileText, Loader2, LogIn, RefreshCw, SlidersHorizontal, Wrench } from '@/lib/icons'
import { $desktopBoot } from '@/store/boot'
@@@ -255,37 -207,31 +258,37 @@@ export function BootFailureOverlay()
try {
const desktop = window.hermesDesktop
- await desktop?.oauthLogoutConnectionConfig?.(remoteReauth.url)
-
- // `error` matters here: the oauth arm (oauthLoginConnectionConfig) and
- // the cloud cascade can both fail with a reason, and the incomplete
- // sign-in notice below surfaces it. (DesktopCloudAgentSignInResult has
- // no error field; oauthLoginConnectionConfig does.)
- let result: { connected?: boolean; error?: string } | undefined
+ let connected: boolean
++ // Only the oauth arm reports a reason (DesktopOauthLoginResult.error);
++ // the incomplete sign-in notice below surfaces it. The cloud ladder
++ // reports an outcome, handled in its own branch.
++ let error: string | 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
- }
+ // The ladder drops this gateway's lapsed cookies itself — logging out
+ // here as well would fire the IPC twice for the cloud path.
+ const outcome = await reestablishCloudAgentSession(desktop, remoteReauth.url)
+
+ if (outcome === 'portal-incomplete') {
+ notify({
+ kind: 'warning',
+ title: t.boot.failure.signInIncompleteTitle,
+ message: t.boot.failure.signInIncompleteMessage
+ })
+
+ return
}
- result = await desktop.cloud.agentSignIn(remoteReauth.url)
+ connected = true
} else {
- result = await desktop?.oauthLoginConnectionConfig(remoteReauth.url)
+ await desktop?.oauthLogoutConnectionConfig?.(remoteReauth.url)
+
- connected = (await desktop?.oauthLoginConnectionConfig(remoteReauth.url))?.connected === true
++ const result: DesktopOauthLoginResult | undefined = await desktop?.oauthLoginConnectionConfig(remoteReauth.url)
++ connected = result?.connected === true
++ error = result?.error
}
- if (result?.connected) {
+ if (connected) {
if (connectionConfig?.mode === 'cloud') {
await desktop?.resetBootstrap().catch(() => undefined)
}
@@@ -299,9 -245,7 +302,9 @@@
notify({
kind: 'warning',
title: t.boot.failure.signInIncompleteTitle,
- message: result?.error
- ? `${t.boot.failure.signInIncompleteMessage}: ${result.error}`
- message: t.boot.failure.signInIncompleteMessage
++ message: error
++ ? `${t.boot.failure.signInIncompleteMessage}: ${error}`
+ : t.boot.failure.signInIncompleteMessage
})
} catch (err) {
notifyError(err, t.boot.failure.signInFailed)