Skip to content

Clear a server's OAuth state from a header icon (#3065) - #3091

Merged
cliffhall merged 3 commits into
v2/mainfrom
v2/feat/3065-quick-clear-oauth
Nov 30, 2026
Merged

cliffhall merged 3 commits into
v2/mainfrom
v2/feat/3065-quick-clear-oauth

Conversation

@cliffhall

@cliffhall cliffhall commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Closes #3065

What changed

You no longer have to open Settings → Authorization to clear a server's OAuth state. A Clear OAuth icon (TbBrandOauth, tooltip "Clear OAuth") now sits in the connected header's right-hand group, beside the Disconnect icon. Clicking it opens a Clear OAuth confirmation modal ("Are you sure? …"). Confirming runs the existing clear.

  • Same action as Connection Info. The header reuses handleClearConnectionOAuth, so it shares runClear's per-server in-flight guard, error toast and revoke-on-clear setting. What a clear does is unchanged, which the issue puts out of scope.
  • Shown only when the connected server has stored OAuth credentials. The gate is Connection Info's connectionInfoCanClearOAuth (connected, a live client, an HTTP transport), narrowed to a session whose stored OAuth state carries an access token. That is the same getOAuthState() read Connection Info displays. A server that never used OAuth shows no icon, and neither does a stdio session.
  • Confirmation first. The icon sits one slip away from Disconnect, so it asks first, which the Settings and Connection Info controls do not. The new ClearOAuthConfirmModal (in components/groups/) names the server. If the session ends while the prompt is open, the prompt is dropped. Its open state is reset during render, so a later session can't bring it back.
  • Docs: docs/mcp-server-configuration.md now mentions the header icon next to the Settings path.

Tests

  • ViewHeader.test.tsx covers:
    • the icon asks for confirmation before clearing
    • Cancel clears nothing
    • the icon sits beside Disconnect, in the same group
    • the icon is absent when no handler is passed
    • an open prompt is dropped when the clear stops being offered
  • ClearOAuthConfirmModal.test.tsx covers the closed and open states, confirm, and cancel.
  • New stories: ViewHeader/ConnectedWithOAuth, ClearOAuthConfirmModal/Open.
  • npm run local:gate passes.

Screenshots (1280×900, Chromium)

Connected to oauth-revocation-http.json after authorizing. The icon sits beside Disconnect:

oauth-header-clear-oauth-tooltip

Confirmation modal. Updated after #3100: the prompt now says the grant is also revoked at the authorization server before the session disconnects:

oauth-header-clear-oauth-confirm

After confirming, the session disconnects and the "OAuth state cleared" toast appears:

oauth-header-clear-oauth-cleared

Connected to a server with no OAuth (web-tabs-http.json). There is no icon:

no-oauth-header

🤖 Generated with Claude Code

Adds a Clear OAuth icon (TbBrandOauth, tooltip "Clear OAuth") to the
connected header's right-hand group, shown while connected over an HTTP
transport. It opens a "Clear OAuth" confirmation modal and, on confirm,
runs the same clear as Connection Info and Settings -> Authorization.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block approval of the OAuth-clearing shortcut.

No open issues 🎉

What changed in this PR

Adds a faster way to clear a server’s OAuth state from the web client’s connected header, addressing #3065 while reusing the existing clear behavior.

Changes:

  • Adds a Clear OAuth icon beside Disconnect for eligible HTTP connections.
  • Requires confirmation naming the server and dismisses the prompt when clearing is no longer available.
  • Adds component tests, Storybook examples, and documentation for the new shortcut.
File Description
docs/​mcp-server-configuration.md Documents the header shortcut and confirmation.
clients/​web/​src/​components/​views/​InspectorView/​types.ts Adds the optional clear-OAuth callback.
clients/​web/​src/​components/​views/​InspectorView/​InspectorView.tsx Passes the callback to the header.
clients/​web/​src/​components/​groups/​ViewHeader/​ViewHeader.tsx Adds the icon and confirmation lifecycle.
clients/​web/​src/​components/​groups/​ViewHeader/​ViewHeader.test.tsx Tests confirmation, cancellation, placement, and visibility.
clients/​web/​src/​components/​groups/​ViewHeader/​ViewHeader.stories.tsx Adds a connected-header example with OAuth clearing.
clients/​web/​src/​components/​groups/​ClearOAuthConfirmModal/​ClearOAuthConfirmModal.tsx Adds the server-specific confirmation modal.
clients/​web/​src/​components/​groups/​ClearOAuthConfirmModal/​ClearOAuthConfirmModal.test.tsx Tests modal rendering and callbacks.
clients/​web/​src/​components/​groups/​ClearOAuthConfirmModal/​ClearOAuthConfirmModal.stories.tsx Adds an open-modal example with rendering assertions.
clients/​web/​src/​App.tsx Connects the header action to the existing handler and eligibility condition.

Review effort: Balanced

…als (#3065)

Narrows the header icon's gate from "connected over HTTP" to a session
whose stored OAuth state (the same read Connection Info shows) carries an
access token, so a server that never used OAuth shows no icon.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 1 was clean: no inline comments, no headline finding, and no suppressed comments. Since then, 2b78426 narrows the header icon to sessions with stored OAuth credentials, as the maintainer asked. Requesting another round for that change.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Stale OAuth state persists across server switches, allowing Clear OAuth to incorrectly clear and disconnect a non-OAuth server while its state is still loading.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Prevent stale OAuth state from appearing during session changes

clients/​web/​src/​App.tsx:1907

After disconnecting from OAuth server A and connecting to non-OAuth HTTP server B, useOAuthRecovery exposes A's cached access token until B's asynchronous getOAuthState() finishes. This temporarily offers Clear OAuth for B, and confirming while that read is pending clears/disconnects B despite it having no stored credentials. Key the OAuth snapshot by client/session, return undefined until the current session's read completes, and add a regression test with B's read held pending.

Review effort: Balanced

The cached OAuth details outlived the session that read them, so a new
connection showed the previous session's access token until its own
getOAuthState() settled. With the header's Clear OAuth gated on that value,
the icon could be offered (and confirmed) for a server with nothing stored.
Key the snapshot by the client it was read through and read undefined
until the current client's read lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 2. It posted no inline comments and one finding in the body's previously missed block. That finding has no thread, so I'm answering it here.

  • Stale OAuth state across server switches (useOAuthRecovery / App.tsx). Fixed in f12a224. connectionInfoOAuth was cached without recording which session read it, so a new session showed the previous session's access token until its own getOAuthState() returned. The header icon is gated on that value, so this is a defect in what this PR added, not scope creep. The snapshot is now keyed by the InspectorClient it was read through, and it reads undefined until the current client's read lands. New regression test: hides the previous client's details until the new client's read settles. It holds the second client's read pending. local:gate passes.

Requesting another round.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed because existing tests bypass the OAuth-clear visibility gate and App callback wiring, leaving credential-dependent visibility and active-server clearing behavior unverified.

No open issues 🎉

Review effort: Balanced

@cliffhall

Copy link
Copy Markdown
Member Author

Copilot review loop closed after round 3. Round 3 posted no inline comments, no suppressed comments and no open issues. Its headline only notes that the App.tsx wiring isn't unit-tested. App.tsx is the composition root that AGENTS.md documents as outside the coverage gate. The gate there is two terms (connectionInfoCanClearOAuth && connectionInfoOAuth?.accessToken). Both halves are covered where they're computed: useOAuthRecovery.test.tsx for the per-client snapshot and ViewHeader.test.tsx for the icon and confirmation. The screenshots above show both cases end to end. So round 3 counts as the clean round and the loop stops.

Rounds: 1 clean. 2 had one in-scope finding, fixed in f12a224. 3 clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Issues and PRs for v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Faster way to clear a server's OAuth state (without digging into Settings → Authorization)

2 participants