From a195b50245bdb9d0b47b2d7a2f9157b3a52bb335 Mon Sep 17 00:00:00 2001
From: Tom Gringauz <17593920+tomgrin10@users.noreply.github.com>
Date: Mon, 12 Oct 2026 09:05:45 +0000
Subject: [PATCH] Keep manual OAuth sign-in available during reconnect errors
---
docs/features/oauth-authentication.md | 10 +++
frontend/src/components/ServerCard.vue | 5 ++
frontend/src/utils/oauthActions.ts | 14 ++++
frontend/src/views/ServerDetail.vue | 8 +-
.../tests/unit/oauth-manual-signin.spec.ts | 78 +++++++++++++++++++
5 files changed, 112 insertions(+), 3 deletions(-)
create mode 100644 frontend/src/utils/oauthActions.ts
create mode 100644 frontend/tests/unit/oauth-manual-signin.spec.ts
diff --git a/docs/features/oauth-authentication.md b/docs/features/oauth-authentication.md
index 03e84a95e..b838daf50 100644
--- a/docs/features/oauth-authentication.md
+++ b/docs/features/oauth-authentication.md
@@ -166,6 +166,16 @@ actionable **Sign-in** state:
is quarantined, but its tools stay blocked until you **Approve** the server.
The panel makes both gates explicit.
+### Switching accounts and retrying sign-in
+
+To switch accounts or recover an OAuth error, use **Sign in again** in the
+server card’s **More actions** menu or the detail page’s **Actions** menu.
+For an OAuth-capable upstream this remains available during reconnect attempts
+and generic timeout errors, even when the health panel does not suggest login.
+After logout it is labelled **Sign in**. Select the intended account/workspace
+at the provider; if the provider reuses its own browser session, switch that
+account before starting sign-in again.
+
## CLI Commands
### Start Authentication
diff --git a/frontend/src/components/ServerCard.vue b/frontend/src/components/ServerCard.vue
index a9cd9ebf9..5c8f735e5 100644
--- a/frontend/src/components/ServerCard.vue
+++ b/frontend/src/components/ServerCard.vue
@@ -110,6 +110,9 @@
Logout
+
+ {{ server.authenticated || server.connected ? 'Sign in again' : 'Sign in' }}
+
{
// the status line reads a calm amber "Sign-in required" instead of red
// "Disconnected"/"Unhealthy", matching the ServerDetail Sign-in CTA.
const signInState = computed(() => oauthSignInState(props.server))
+const canSignIn = computed(() => canStartOAuthLogin(props.server))
// Trust-mode badge (spec 088 FR-007 / FR-001). Display only — the mode is
// changed from the server detail Configuration tab.
diff --git a/frontend/src/utils/oauthActions.ts b/frontend/src/utils/oauthActions.ts
new file mode 100644
index 000000000..7cc8d1700
--- /dev/null
+++ b/frontend/src/utils/oauthActions.ts
@@ -0,0 +1,14 @@
+import type { Server } from '@/types'
+
+// Account switching and recovery must remain available even when a timeout
+// is classified as a reconnect error, or a background connection is running.
+export function canStartOAuthLogin(server: Server): boolean {
+ const protocol = String(server.protocol)
+ const remote = ['http', 'sse', 'streamable-http'].includes(protocol) ||
+ (protocol === 'auto' && !!server.url && !server.command)
+ return !!(server.enabled && remote && (
+ server.oauth || server.authenticated || server.health?.action === 'login' ||
+ server.health?.actions?.includes('login') || server.diagnostic?.code?.startsWith('MCPX_OAUTH_') ||
+ /oauth/i.test(server.last_error || '')
+ ))
+}
diff --git a/frontend/src/views/ServerDetail.vue b/frontend/src/views/ServerDetail.vue
index addc6361f..20a009ff0 100644
--- a/frontend/src/views/ServerDetail.vue
+++ b/frontend/src/views/ServerDetail.vue
@@ -76,10 +76,10 @@
{{ isHttpProtocol ? 'Reconnect' : 'Restart' }}
-
-
+
+
- Login
+ {{ server.authenticated || server.connected ? 'Sign in again' : 'Sign in' }}
@@ -1604,6 +1604,7 @@ import { refName } from '@/utils/secretRef'
import { isTerminalScanStatus, decideScanReconcile, finalizeToastKind } from '@/utils/scanState'
import { selectQuarantinedTools } from '@/utils/toolQuarantine'
import { oauthSignInState, healthStatusLabel, healthActionLabel, healthStatusText } from '@/utils/health'
+import { canStartOAuthLogin } from '@/utils/oauthActions'
import type { HealthStatusValue } from '@/types/contracts'
import { describeIsolation } from '@/utils/isolationState'
import { computeToolDiffSections } from '@/utils/toolDiff'
@@ -1824,6 +1825,7 @@ const logTail = ref(100)
const isHttpProtocol = computed(() => {
return server.value?.protocol === 'http' || server.value?.protocol === 'streamable-http'
})
+const canSignIn = computed(() => !!server.value && canStartOAuthLogin(server.value))
// Suggested action from unified health status
const healthAction = computed(() => {
diff --git a/frontend/tests/unit/oauth-manual-signin.spec.ts b/frontend/tests/unit/oauth-manual-signin.spec.ts
new file mode 100644
index 000000000..be30a6dae
--- /dev/null
+++ b/frontend/tests/unit/oauth-manual-signin.spec.ts
@@ -0,0 +1,78 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest'
+import { mount, flushPromises } from '@vue/test-utils'
+import { createPinia, setActivePinia } from 'pinia'
+import { createRouter, createWebHistory } from 'vue-router'
+import ServerCard from '@/components/ServerCard.vue'
+import ServerDetail from '@/views/ServerDetail.vue'
+import { useServersStore } from '@/stores/servers'
+import { canStartOAuthLogin } from '@/utils/oauthActions'
+import type { Server } from '@/types'
+
+let server: Server
+vi.mock('@/services/api', () => {
+ const ok = (data: unknown = {}) => Promise.resolve({ success: true, data })
+ return { default: {
+ getServers: vi.fn(() => ok({ servers: [server] })),
+ getToolApprovals: vi.fn(() => ok({ tools: [], count: 0 })),
+ getToolDiff: vi.fn(() => ok({})),
+ getServerTools: vi.fn(() => ok({ tools: [] })),
+ getSecurityOverview: vi.fn(() => ok({ scanners_enabled: 0, docker_available: true })),
+ listScanners: vi.fn(() => ok([])),
+ getScanReport: vi.fn(() => Promise.resolve({ success: false, error: 'no report' })),
+ getScanStatus: vi.fn(() => ok({ status: 'completed' })),
+ getServerLogs: vi.fn(() => ok({ logs: [] })),
+ } }
+})
+
+beforeEach(() => {
+ setActivePinia(createPinia())
+ server = {
+ name: 'notion', protocol: 'http', url: 'https://mcp.notion.com/mcp',
+ enabled: true, connected: false, connecting: true, authenticated: true,
+ tool_count: 0, oauth: { client_id: 'test' },
+ last_error: 'OAuth authorization during MCP init failed: context deadline exceeded',
+ health: { level: 'unhealthy', admin_state: 'enabled', summary: 'OAuth error', action: 'restart', actions: ['restart', 'view_logs'] },
+ } as Server
+})
+
+describe('manual OAuth sign-in', () => {
+ it('stays available while reconnecting and after a timeout or logout', () => {
+ expect(canStartOAuthLogin(server)).toBe(true)
+ expect(canStartOAuthLogin({ ...server, authenticated: false, user_logged_out: true })).toBe(true)
+ expect(canStartOAuthLogin({ ...server, connected: true, connecting: false, health: undefined, last_error: undefined })).toBe(true)
+ })
+ it('does not offer OAuth on disabled, stdio, or unauthenticated non-OAuth HTTP servers', () => {
+ expect(canStartOAuthLogin({ ...server, enabled: false })).toBe(false)
+ expect(canStartOAuthLogin({ ...server, protocol: 'stdio' })).toBe(false)
+ expect(canStartOAuthLogin({ ...server, oauth: undefined, authenticated: false, last_error: 'network timeout', health: undefined })).toBe(false)
+ })
+ it('recognizes auto-discovered OAuth without explicit config', () => {
+ expect(canStartOAuthLogin({ ...server, oauth: undefined, authenticated: false })).toBe(true)
+ })
+ it('starts a fresh OAuth flow from the card even when reconnect is the primary action', async () => {
+ const spy = vi.spyOn(useServersStore(), 'triggerOAuthLogin').mockResolvedValue(true)
+ const card = mount(ServerCard, { props: { server }, global: { stubs: { RouterLink: true } } })
+ const action = card.find('[data-test="server-card-menu-login"]')
+ expect(action.text()).toBe('Sign in again')
+ expect(action.attributes('disabled')).toBeUndefined()
+ await action.trigger('click'); await flushPromises()
+ expect(spy).toHaveBeenCalledWith('notion')
+ await card.setProps({ server: { ...server, authenticated: false } })
+ expect(card.find('[data-test="server-card-menu-login"]').text()).toBe('Sign in')
+ card.unmount()
+ })
+ it('offers sign-in again from the detail Actions menu during an OAuth reconnect error', async () => {
+ const router = createRouter({ history: createWebHistory(), routes: [{ path: '/servers/:serverName', component: { template: '
' } }] })
+ await router.push('/servers/notion'); await router.isReady()
+ const pinia = createPinia(); setActivePinia(pinia)
+ const spy = vi.spyOn(useServersStore(), 'triggerOAuthLogin').mockResolvedValue(true)
+ const detail = mount(ServerDetail, { props: { serverName: 'notion' }, global: { plugins: [pinia, router] } })
+ await flushPromises(); await flushPromises()
+ const action = detail.find('[data-test="server-detail-menu-login"]')
+ expect(action.text()).toBe('Sign in again')
+ expect(action.attributes('disabled')).toBeUndefined()
+ await action.trigger('click'); await flushPromises()
+ expect(spy).toHaveBeenCalledWith('notion')
+ detail.unmount()
+ })
+})