The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): ask a signed-out Webapp tab to sign in
emozilla101bff585e2a
diff --git a/apps/desktop/src/app/contrib/wiring-background-queue-drain.test.tsx b/apps/desktop/src/app/contrib/wiring-background-queue-drain.test.tsxindex b7a49376f31..ad0611eb96c 100644--- a/apps/desktop/src/app/contrib/wiring-background-queue-drain.test.tsx+++ b/apps/desktop/src/app/contrib/wiring-background-queue-drain.test.tsx@@ -75,7 +75,7 @@ vi.mock('../session/hooks/use-prompt-actions', () => ({return { submitText: fixture.submitText }}}))-vi.mock('@/components/boot-failure-overlay', () => ({ BootFailureOverlay: () => null }))+vi.mock('@/components/boot-failure-overlay', () => ({ StartupOverlay: () => null }))vi.mock('@/components/confirm-host', () => ({ ConfirmHost: () => null }))vi.mock('@/components/desktop-install-overlay', () => ({ DesktopInstallOverlay: () => null }))vi.mock('@/components/find-bar', () => ({ FindBar: () => null }))diff --git a/apps/desktop/src/app/contrib/wiring.tsx b/apps/desktop/src/app/contrib/wiring.tsxindex 21b6b4345b9..8cfa1c8beff 100644--- a/apps/desktop/src/app/contrib/wiring.tsx+++ b/apps/desktop/src/app/contrib/wiring.tsx@@ -14,7 +14,7 @@ import { type CSSProperties, lazy, type ReactNode, Suspense, useCallback, useEffimport { useLocation, useNavigate } from 'react-router'import { formatRefValue } from '@/components/assistant-ui/directive-text'-import { BootFailureOverlay } from '@/components/boot-failure-overlay'+import { StartupOverlay } from '@/components/boot-failure-overlay'import { ConfirmHost } from '@/components/confirm-host'import { DesktopInstallOverlay } from '@/components/desktop-install-overlay'import { ExternalOpenFailedDialog } from '@/components/external-open-failed-dialog'@@ -1346,7 +1346,7 @@ export function ContribWiring({ children }: { children: ReactNode }) {/><UpdatesOverlay /><GatewayConnectingOverlay />- <BootFailureOverlay />+ <StartupOverlay /><UpdateHoldOverlay /><CommandPalette /><PluginInstallModal />diff --git a/apps/desktop/src/components/boot-failure-overlay.test.tsx b/apps/desktop/src/components/boot-failure-overlay.test.tsxindex 4676b5744ee..16c09f268f0 100644--- a/apps/desktop/src/components/boot-failure-overlay.test.tsx+++ b/apps/desktop/src/components/boot-failure-overlay.test.tsx@@ -2,11 +2,12 @@ import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-libraimport { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import { en } from '@/i18n/en'+import { WEBAPP_LAUNCH_REQUIRED } from '@/lib/browser-launch-session'import { $desktopBoot } from '@/store/boot'import { $notifications } from '@/store/notifications'import { $desktopOnboarding } from '@/store/onboarding'-import { BootFailureOverlay } from './boot-failure-overlay'+import { BootFailureOverlay, StartupOverlay } from './boot-failure-overlay'// Remote-backend users hit a hard boot failure that isn't OAuth reauth (token// auth, wrong URL, unreachable host). The recovery screen must let them fix the@@ -291,6 +292,45 @@ describe('BootFailureOverlay', () => {}})+ it('asks a signed-out Webapp tab to sign in instead of offering recovery for a working service', async () => {+ const restore = stubDesktop({ mode: 'local' })+ $desktopBoot.set({+ error: WEBAPP_LAUNCH_REQUIRED,+ fakeMode: false,+ message: 'boot failed',+ phase: 'renderer.error',+ progress: 40,+ running: false,+ timestamp: Date.now(),+ visible: true+ })++ try {+ render(<StartupOverlay />)+ expect(await screen.findByText(en.boot.failure.webappTitle)).toBeTruthy()+ expect(screen.getByText(en.boot.failure.webappDescription)).toBeTruthy()+ expect(screen.queryByText(en.boot.failure.title)).toBeNull()+ expect(screen.queryByRole('button', { name: /retry/i })).toBeNull()+ expect(screen.queryByRole('button', { name: /repair/i })).toBeNull()+ expect(screen.queryByRole('button', { name: /logs/i })).toBeNull()+ expect(screen.queryByRole('button', { name: /close/i })).toBeNull()+ } finally {+ restore()+ }+ })++ it('shows the recovery steps for any other startup failure', async () => {+ const restore = stubDesktop({ mode: 'local' })++ try {+ render(<StartupOverlay />)+ expect(await screen.findByText(en.boot.failure.title)).toBeTruthy()+ expect(screen.queryByText(en.boot.failure.webappTitle)).toBeNull()+ } 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 eb04ba27fbf..2bd43672a51 100644--- a/apps/desktop/src/components/boot-failure-overlay.tsx+++ b/apps/desktop/src/components/boot-failure-overlay.tsx@@ -10,6 +10,7 @@ import { Loader } from '@/components/ui/loader'import { LogView } from '@/components/ui/log-view'import type { DesktopConnectionConfig, DesktopOauthLoginResult } from '@/global'import { useI18n } from '@/i18n'+import { WEBAPP_LAUNCH_REQUIRED } from '@/lib/browser-launch-session'import { reestablishCloudAgentSession } from '@/lib/cloud-agent-session'import { DESKTOP_DOCS_URL } from '@/lib/docs'import { openExternalLink } from '@/lib/external-link'@@ -88,6 +89,36 @@ function BootFailureModal({)}+/** What the app shows over a failed startup: sign-in instructions for a signed-out Webapp tab,+ * recovery steps for everything else. */+export function StartupOverlay() {+ const error = useStore($desktopBoot).error++ return error?.includes(WEBAPP_LAUNCH_REQUIRED) ? <WebappSignInOverlay /> : <BootFailureOverlay />+}++/** A Webapp tab without a valid sign-in. The service is running, so there is nothing to recover or+ * dismiss: only hermes webapp signs the tab in. */+function WebappSignInOverlay() {+ const copy = useI18n().t.boot.failure++ return (+ <BootFailureModal onDismiss={() => undefined}>+ <div className="relative w-full max-w-[40rem] overflow-hidden rounded-xl border border-(--stroke-nous) bg-(--ui-chat-bubble-background) shadow-nous">+ <div className="flex items-start gap-3 px-5 py-4">+ <LogIn className="mt-0.5 size-5" />+ <div>+ <DialogPrimitive.Title asChild>+ <h2 className="text-[0.9375rem] font-semibold tracking-tight">{copy.webappTitle}</h2>+ </DialogPrimitive.Title>+ <p className="mt-1 text-[0.8125rem] leading-5 text-(--ui-text-tertiary)">{copy.webappDescription}</p>+ </div>+ </div>+ </div>+ </BootFailureModal>+ )+}+export function BootFailureOverlay() {const boot = useStore($desktopBoot)const onboarding = useStore($desktopOnboarding)diff --git a/apps/desktop/src/i18n/en_boot.ts b/apps/desktop/src/i18n/en_boot.tsindex 1cf4b950bf9..3e61e21f245 100644--- a/apps/desktop/src/i18n/en_boot.ts+++ b/apps/desktop/src/i18n/en_boot.ts@@ -49,6 +49,8 @@ export const enBoot = {remoteTitle: 'Remote gateway sign-in required',remoteDescription:'Your remote gateway session has expired. Sign in again to reconnect. Nothing here deletes your chats or settings.',+ webappTitle: 'Sign in to Hermes',+ webappDescription: 'Run hermes webapp on this computer to sign this browser in.',retry: 'Retry',repairInstall: 'Repair install',useLocalGateway: 'Use local gateway',diff --git a/apps/desktop/src/i18n/overlay-gaps.json b/apps/desktop/src/i18n/overlay-gaps.jsonindex 9c3d5e06da1..5d8d77752ca 100644--- a/apps/desktop/src/i18n/overlay-gaps.json+++ b/apps/desktop/src/i18n/overlay-gaps.json@@ -193,6 +193,8 @@"boot.failure.gatewaySettings": ["ar"],"boot.failure.reinstallApp": ["ar","de","es","fr","ja","ru","zh-hant"],"boot.failure.remoteFailureHint": ["ar"],+ "boot.failure.webappDescription": ["ar","de","es","fr","ja","ru","zh","zh-hant"],+ "boot.failure.webappTitle": ["ar","de","es","fr","ja","ru","zh","zh-hant"],"boot.updateHold.checkAgain": ["ar","ja","ru","zh","zh-hant"],"boot.updateHold.confirmBody": ["ar","ja","ru","zh","zh-hant"],"boot.updateHold.confirmKeepWaiting": ["ar","ja","ru","zh","zh-hant"],diff --git a/apps/desktop/src/i18n/types_boot.ts b/apps/desktop/src/i18n/types_boot.tsindex aa21611a199..51d27f64ab5 100644--- a/apps/desktop/src/i18n/types_boot.ts+++ b/apps/desktop/src/i18n/types_boot.ts@@ -40,6 +40,8 @@ export interface BootTranslations {details: stringremoteTitle: stringremoteDescription: string+ webappTitle: string+ webappDescription: stringretry: stringrepairInstall: stringuseLocalGateway: stringdiff --git a/apps/desktop/src/lib/browser-launch-session.test.ts b/apps/desktop/src/lib/browser-launch-session.test.tsindex 6d0f4b5d4ae..26f8c580a92 100644--- a/apps/desktop/src/lib/browser-launch-session.test.ts+++ b/apps/desktop/src/lib/browser-launch-session.test.ts@@ -80,8 +80,8 @@ it('fails closed with actionable launch instructions in a fresh tab and ignoresconst fetchMock = vi.fn()vi.stubGlobal('fetch', fetchMock)expect(installBrowserDesktopBridge()).toBe(true)- await expect(window.hermesDesktop!.getConnection()).rejects.toThrow('private launch link')- await expect(window.hermesDesktop!.api({ path: '/api/fs/read-text' })).rejects.toThrow('private launch link')+ await expect(window.hermesDesktop!.getConnection()).rejects.toThrow('Run hermes webapp')+ await expect(window.hermesDesktop!.api({ path: '/api/fs/read-text' })).rejects.toThrow('Run hermes webapp')expect(fetchMock).not.toHaveBeenCalled()window.dispatchEvent(new Event('beforeunload'))Reflect.deleteProperty(window, 'hermesDesktop')diff --git a/apps/desktop/src/lib/browser-launch-session.ts b/apps/desktop/src/lib/browser-launch-session.tsindex fb634ea7b40..578f7f53422 100644--- a/apps/desktop/src/lib/browser-launch-session.ts+++ b/apps/desktop/src/lib/browser-launch-session.ts@@ -1,6 +1,6 @@const FRAGMENT_KEY = 'hermes-session'-export const WEBAPP_LAUNCH_REQUIRED = 'Open the private launch link printed by hermes webapp in this tab. If the gateway restarted or the link is lost, run hermes webapp again to get a new link. Keep the link private: it grants host access.'+export const WEBAPP_LAUNCH_REQUIRED = 'Run hermes webapp on this computer to sign this browser in.'/** Pasting the launch link over a bare URL is a same-document navigation. */export function watchWebappLaunchLink(reload: () => void): void {diff --git a/locales/_keys.desktop.json b/locales/_keys.desktop.jsonindex 59cd56830af..e59d499192c 100644--- a/locales/_keys.desktop.json+++ b/locales/_keys.desktop.json@@ -543,6 +543,8 @@"boot.failure.signedInTitle","boot.failure.title","boot.failure.useLocalGateway",+ "boot.failure.webappDescription",+ "boot.failure.webappTitle","boot.ready","boot.steps.connectingGateway","boot.steps.loadingSessions",