Skip to content

The agent that grows with you

fix(desktop): reject missing Cloud dashboard URL

Carl Tayloreb9ee9cacc1a
diff --git a/apps/desktop/src/app/settings/gateway-settings.test.tsx b/apps/desktop/src/app/settings/gateway-settings.test.tsx
index 948c6344817..c51ad22afaf 100644
--- a/apps/desktop/src/app/settings/gateway-settings.test.tsx
+++ b/apps/desktop/src/app/settings/gateway-settings.test.tsx
@@ -306,6 +306,38 @@ describe('GatewaySettings', () => {
registry.value = null
})
+ it('fails closed instead of cascading against an empty saved dashboard URL', async () => {
+ const savedWithoutUrl = {
+ id: 'saved-without-url',
+ kind: 'cloud',
+ label: 'Incomplete',
+ authMode: 'oauth'
+ }
+
+ getConnectionConfig.mockResolvedValue({ ...localConnection, mode: 'cloud', remoteUrl: '' })
+ registry.value = { connections: [savedWithoutUrl] }
+ const agentSignIn = vi.fn()
+ const oauthLogoutConnectionConfig = vi.fn()
+ Object.assign(window.hermesDesktop, {
+ oauthLogoutConnectionConfig,
+ cloud: {
+ status: vi.fn().mockResolvedValue({ signedIn: true }),
+ login: vi.fn(),
+ agentSignIn
+ }
+ })
+ selectConnection.mockRejectedValueOnce(reauthError)
+
+ render(<GatewaySettings embedded />)
+ const row = (await screen.findByText('Incomplete')).closest('[data-slot]') as HTMLElement
+ fireEvent.click(within(row).getByRole('button', { name: 'Use gateway' }))
+
+ await waitFor(() => expect(selectConnection).toHaveBeenCalledTimes(1))
+ expect(oauthLogoutConnectionConfig).not.toHaveBeenCalled()
+ expect(agentSignIn).not.toHaveBeenCalled()
+ registry.value = null
+ })
+
it('does not cascade for a non-reauth switch failure', async () => {
mountCloudPanelWith({
status: vi.fn().mockResolvedValue({ signedIn: true }),
diff --git a/apps/desktop/src/app/settings/gateway-settings.tsx b/apps/desktop/src/app/settings/gateway-settings.tsx
index c64acc3331f..525301995a5 100644
--- a/apps/desktop/src/app/settings/gateway-settings.tsx
+++ b/apps/desktop/src/app/settings/gateway-settings.tsx
@@ -426,7 +426,7 @@ function GatewayConnectionSettings({ embedded, standalone }: { embedded: boolean
// the one recovery that exists for this state — drop the lapsed cookies,
// ensure the portal session, silent-cascade the agent — then retry the
// switch once. Everything else stays a plain failed switch.
- const selectSavedCloudWithReauth = async (id: string, url: string) => {
+ const selectSavedCloudWithReauth = async (id: string, dashboardUrl?: string) => {
try {
await selectConnection(id)
} catch (error) {
@@ -436,11 +436,13 @@ function GatewayConnectionSettings({ embedded, standalone }: { embedded: boolean
const desktop = window.hermesDesktop
- if (!desktop?.cloud) {
+ // Cloud registry URLs are the persisted agent dashboardUrl. Keep saved
+ // rows usable without discovery, but never run the cascade against ''.
+ if (!desktop?.cloud || !dashboardUrl) {
throw error
}
- const outcome = await reestablishCloudAgentSession(desktop, url)
+ const outcome = await reestablishCloudAgentSession(desktop, dashboardUrl)
if (outcome !== 'connected') {
notify({
@@ -456,11 +458,11 @@ function GatewayConnectionSettings({ embedded, standalone }: { embedded: boolean
}
}
- const activateSavedCloud = async (id: string, url: string) => {
+ const activateSavedCloud = async (id: string, dashboardUrl?: string) => {
setCloudConnectingId(id)
try {
- await selectSavedCloudWithReauth(id, url)
+ await selectSavedCloudWithReauth(id, dashboardUrl)
} catch (err) {
notifyError(err, g.cloudConnectFailed)
} finally {
@@ -1359,7 +1361,7 @@ function GatewayConnectionSettings({ embedded, standalone }: { embedded: boolean
) : (
<Button
disabled={cloudConnectingId !== null}
- onClick={() => void activateSavedCloud(connection.id, connection.url || '')}
+ onClick={() => void activateSavedCloud(connection.id, connection.url)}
size="sm"
variant="outline"
>