The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): an env-pinned remote can sign in again from Gateway settings
finn763c28a0f74bb67
diff --git a/apps/desktop/src/app/settings/gateway-settings.test.tsx b/apps/desktop/src/app/settings/gateway-settings.test.tsxindex 87811b30cc3..c997ecc5c03 100644--- a/apps/desktop/src/app/settings/gateway-settings.test.tsx+++ b/apps/desktop/src/app/settings/gateway-settings.test.tsx@@ -173,6 +173,91 @@ describe('GatewaySettings', () => {expect(agentSignIn).toHaveBeenCalledExactlyOnceWith('https://new-a.example')expect(applyConnectionConfig).toHaveBeenCalledTimes(1)})+ // #114856: an env-pinned remote (HERMES_DESKTOP_REMOTE_URL) whose session+ // lapsed could not be re-authenticated from Settings → Gateway at all — the+ // whole remote block (URL + probe + Authentication) was hidden behind+ // `!state.envOverride`, so the recovery card's "Gateway settings" escape led+ // to a read-only banner with no sign-in, leaving "Use local gateway" as the+ // only way back in. The env override pins the URL, not the browser session+ // (docs: "you still sign in from the Gateway settings panel"), so the+ // Authentication row must stay reachable — its controls are not env-owned.+ describe('env-override remote', () => {+ const envUrl = 'http://100.116.104.53:9191'++ const envRemote = {+ ...localConnection,+ envOverride: true,+ mode: 'remote',+ remoteAuthMode: 'token',+ remoteUrl: envUrl+ }++ const oauthProbe = {+ authMode: 'oauth',+ providers: [{ displayName: 'Nous Research', name: 'nous', supportsPassword: false }],+ reachable: true+ }++ it('reaches sign-in for a lapsed session instead of a dead env banner', async () => {+ const oauthLoginConnectionConfig = vi.fn().mockResolvedValue({ connected: true })+ const probeConnectionConfig = vi.fn().mockResolvedValue(oauthProbe)++ getConnectionConfig.mockResolvedValue({ ...envRemote, remoteOauthConnected: false })+ // Sign-in persists the URL + oauth mode before opening the login window;+ // the saved echo must stay remote or the signing sequence resets.+ saveConnectionConfig.mockResolvedValue({ ...envRemote, remoteAuthMode: 'oauth' })+ Object.assign(window.hermesDesktop, { oauthLoginConnectionConfig, probeConnectionConfig })++ render(<GatewaySettings embedded />)++ // The env override still owns the URL: the editor stays read-only.+ expect((await screen.findByDisplayValue(envUrl) as HTMLInputElement).disabled).toBe(true)++ fireEvent.click(await screen.findByRole('button', { name: 'Sign in with Nous Research' }))++ await waitFor(() => expect(oauthLoginConnectionConfig).toHaveBeenCalledWith(envUrl))+ })++ it('lets a stale-but-connected env session sign out, then back in', async () => {+ const oauthLogoutConnectionConfig = vi.fn().mockResolvedValue({ connected: false })+ const oauthLoginConnectionConfig = vi.fn().mockResolvedValue({ connected: true })++ getConnectionConfig+ .mockResolvedValueOnce({ ...envRemote, remoteOauthConnected: true })+ .mockResolvedValue({ ...envRemote, remoteOauthConnected: false })+ Object.assign(window.hermesDesktop, {+ oauthLoginConnectionConfig,+ oauthLogoutConnectionConfig,+ probeConnectionConfig: vi.fn().mockResolvedValue(oauthProbe)+ })++ render(<GatewaySettings embedded />)++ fireEvent.click(await screen.findByRole('button', { name: 'Sign out' }))+ await waitFor(() => expect(oauthLogoutConnectionConfig).toHaveBeenCalledWith(envUrl))++ // The refreshed (lapsed) config paints the sign-in control.+ fireEvent.click(await screen.findByRole('button', { name: 'Sign in with Nous Research' }))+ await waitFor(() => expect(oauthLoginConnectionConfig).toHaveBeenCalledWith(envUrl))+ })++ it('leaves a saved (non-env) remote session editable and unchanged', async () => {+ const oauthLoginConnectionConfig = vi.fn()++ getConnectionConfig.mockResolvedValue({ ...envRemote, envOverride: false, remoteOauthConnected: false })+ Object.assign(window.hermesDesktop, {+ oauthLoginConnectionConfig,+ probeConnectionConfig: vi.fn().mockResolvedValue(oauthProbe)+ })++ render(<GatewaySettings embedded />)++ expect((await screen.findByDisplayValue(envUrl) as HTMLInputElement).disabled).toBe(false)+ expect(await screen.findByRole('button', { name: 'Sign in with Nous Research' })).toBeTruthy()+ expect(oauthLoginConnectionConfig).not.toHaveBeenCalled()+ })+ })+it('loads the machine-level connection config (no profile scoping)', async () => {render(<GatewaySettings />)expect(await screen.findByText('Local gateway')).toBeTruthy()diff --git a/apps/desktop/src/app/settings/gateway-settings.tsx b/apps/desktop/src/app/settings/gateway-settings.tsxindex 5bbb76a39d3..c555b5f118c 100644--- a/apps/desktop/src/app/settings/gateway-settings.tsx+++ b/apps/desktop/src/app/settings/gateway-settings.tsx@@ -1474,7 +1474,14 @@ function GatewayConnectionSettings({ embedded, standalone }: { embedded: boolean</div>) : null}- {state.mode === 'remote' && !state.envOverride ? (+ {/* An env-pinned remote (HERMES_DESKTOP_REMOTE_URL) still renders this+ block: the override pins the URL/mode, but the browser SESSION is not+ env-owned — docs promise "you still sign in from the Gateway settings+ panel" (user-guide/desktop.md). Hiding it left a lapsed session with+ no sign-in anywhere in Settings, and the boot-recovery card routes+ every remote failure here, so "Use local gateway" became the only way+ back in (#114856). The URL input and Save/Test stay env-gated above. */}+ {state.mode === 'remote' ? (<div className="mt-5 grid gap-1"><ListRowaction={@@ -1513,13 +1520,16 @@ function GatewayConnectionSettings({ embedded, standalone }: { embedded: boolean<Pill tone="primary"><Check className="size-3" /> {g.signedIn}</Pill>- <Button disabled={signingIn || state.envOverride} onClick={() => void signOut()} variant="outline">+ {/* Sign-in/out are session actions, not connection edits: an+ env-pinned URL must still be able to refresh its lapsed+ session from here (#114856). */}+ <Button disabled={signingIn} onClick={() => void signOut()} variant="outline">{signingIn ? <Loader2 className="animate-spin" /> : null}{g.signOut}</Button></div>) : (- <Button disabled={signingIn || state.envOverride || !trimmedUrl} onClick={() => void signIn()}>+ <Button disabled={signingIn || !trimmedUrl} onClick={() => void signIn()}>{signingIn ? <Loader2 className="animate-spin" /> : <LogIn />}{isPasswordProvider ? g.signIn : g.signInWith(providerLabel)}</Button>