Skip to content

fix(mcp): retire an Authorize card once its sign-in attempt ends - #22907

Closed
kyleseaman wants to merge 2 commits into
mainfrom
fix/mcp-sign-in-card-expiry
Closed

kyleseaman wants to merge 2 commits into
mainfrom
fix/mcp-sign-in-card-expiry

Conversation

@kyleseaman

@kyleseaman kyleseaman commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: An MCP Authorize card stops offering its link once the sign-in attempt behind it has timed out, so clicking Authorize never ends on a refused localhost callback.

On the KAS backend the engine keeps the OAuth callback listener open for one connect attempt only (the server's connect timeout, 60 s by default). The Authorize card stays clickable after that. A user who finishes the provider's consent page lands on localhost:<port>/oauth/callback?code=… with ERR_CONNECTION_REFUSED, and the sign-in is lost. The 60 s starts when the link is minted, not when it is clicked, and with several unauthenticated servers the rotating offers (one minute each) make a dead card the common case.

Why it matters

Remote OAuth MCP servers (lennysdata, Notion, Figma) on KAS cannot be signed in to reliably from chat: the visible button is usually dead, nothing says so, and a user who acts quickly still fails if the card had been sitting for more than a minute.

Not a goal

  • Lengthening the engine's connect timeout. It is the engine's per-server setting (timeout in mcp.json, at most 600 s), not something Crew's reset request controls.
  • Changing how sign-in offers rotate between servers.
  • The kiro-cli backend, which mints its own links and does not use the runtime's sign-in slot.

What changed (motivation → approach → change)

A chat now shows at most one Authorize card per server, and only while its link still works. A card whose sign-in attempt ended, or that a newer request replaced, disappears instead of turning grey.

Symptom A card's Authorize link outlives the listener it points at.
Root cause _run_mcp_sign_in frees the slot when the engine answers the startOAuth reset, but tells no one. Cards were only retired by a newer request or a dead child process.
Change The ended attempt is reported to the chat whether or not a turn is running. The dashboard withdraws that server's open links, and the client draws nothing for a retired card.

When the reset is answered or its slot times out without success: true, and the process is still alive, the runtime calls the owning session's sign-in-ended hook before freeing the slot, so the next sign-in's link always arrives after it. The hook works for a busy chat and an idle one. The dashboard installs it before each link it draws, mid-turn or from the pre-turn drain, and the session provider re-installs it after a session reset and after an MCP config re-injection (session_provider_mcp_reinject.py), which unregisters the session. A link that waited in the queue past its attempt's end is checked at draw time (mcp_sign_in_live, answered by the runtime's sign-in slot) and retired at once. A dead process or a cancelled attempt calls nothing and leaves the card to the dead-child gate.

Each sign-in gets an attempt number, stamped on its _kiro.dev/mcp/oauth_request frame as signInAttempt. The session handle drops a stamped frame whose attempt no longer owns the slot before the OAuth dedupe set, so a stale link can neither show live under a replacement attempt nor swallow the replacement's own link. Unstamped frames (kiro-cli's own requests) behave as before.

The retired row keeps the expired state every terminal gate already reads, with expired_reason: "attempt_ended". McpOAuthBanner.tsx renders nothing for that row or for a superseded one; a completion that lands afterwards still flips the row to authenticated, and it shows. The dead-process expired card still renders, because nothing else offers that user a way back in. The superseded and attempt_ended strings are removed from locales/en.json, locales/en-XA.json and the eleven translated catalogs. The superseded capture runner goes with its state, the banner capture harness and capture-mcp-oauth-expired.mjs drop the superseded row, and the acp-client.md spec describes the hidden states.

Where it lives: hook and attempt number in acp/runtime_host_requests.py, acp/runtime_class.py, acp/runtime_session_registry.py; stale-attempt filter in acp/session_handle_mcp.py; session-side install in acp/session_provider.py; provider hook in providers/base.py and providers/acp.py; cards in chat_turn/mcp_session.py, reached through main's _on_mcp_oauth_request.

Backwards compatibility

Compatible: two new provider members (set_mcp_sign_in_ended_hook, mcp_sign_in_live, both inert on LLMProvider) and an optional expired_reason meta key. A client that does not know the key renders the existing expired state, and the link is withdrawn either way. The kiro-cli start path is unchanged.

Reader: website/src/pages/chat/McpOAuthBanner.tsx:renderMcpOAuthMessage -- chat -- returns null for superseded and attempt_ended rows; test renders nothing for a replaced card, even one still carrying a url
Reader: website/src/app-sdk/messageRenderers.tsx:mcp_oauth renderer -- chat, app -- already drops a null banner; test keeps the one live card beside hidden retired ones
Reader: src/kiro_crew/dashboard/chat_utils_display.py:_expire_dead_child_oauth_meta -- crew page -- skips rows without oauth_url, which every retired row lacks; test test_the_read_gate_keeps_the_timeout_reason
Reader: src/kiro_crew/dashboard/chat_turn/mcp_session.py:_mark_mcp_oauth_completed -- chat -- still targets the newest open card, and lets a late success revive an attempt_ended row; test test_a_completion_that_lands_after_the_timeout_still_signs_in
Reader: website/src/i18n/locales/*.json:pages.chat.mcpOAuthBanner.superseded and .attempt_ended -- release -- no remaining caller (git grep finds none); npm run i18n:check and lint:i18n pass

Tests

Cases covered:

Case Tests
Attempt ends while the chat is idle test_showing_a_link_installs_a_hook_that_retires_it_while_idle, test_an_unconnected_end_calls_the_sessions_hook_while_the_slot_is_held
Attempt ends mid-turn test_a_link_whose_attempt_already_ended_is_drawn_expired, test_an_attempt_that_ends_during_the_endpoint_check_is_shown_expired, test_the_turn_handler_draws_through_the_hooked_path
Link buffered between turns test_a_link_drained_at_turn_start_is_judged_and_hooked
Replacement attempt, same server test_an_ended_attempt_request_cannot_deduplicate_its_replacement, test_a_fresh_banner_after_the_timeout_is_live, vitest keeps the one live card beside hidden retired ones
Success just after expiry test_a_completion_that_lands_after_the_timeout_still_signs_in, vitest shows a late success on a card whose attempt had ended
Several servers test_another_servers_banner_keeps_its_link, test_a_queued_request_after_a_reinstalled_hook_is_still_judged, test_another_sessions_hook_is_not_called
kiro-cli backend unchanged test_a_live_or_untagged_oauth_request_is_yielded, test_a_provider_without_crew_sign_ins_leaves_the_link_live, test_a_host_without_crew_sign_ins_answers_none
  • test/test_kas_mcp_sign_in.py: the hook fires (slot still held) for a timeout or an unsuccessful answer, never for success: true, another session, or an unregistered or departed session; a raising hook still frees the slot; a dead process or cancelled attempt leaves the card to the dead-child gate; stale stamped frames are dropped before dedupe.
  • test/test_mcp_oauth_banner_timeout.py: expiry withdraws the link and broadcasts oauth_url: "" by mid; a late failure does not reopen the row; the read gate keeps the reason.
  • test/test_kas_mcp_live_reinject.py: the chat's hook is re-installed on the reloaded session.
  • test/test_acp_bindings.py, test/test_runtime_bindings.py: inventories pin the new members.
  • test/test_mcp_oauth_banner.py, test/test_mcp_oauth_discovery.py: their drain fakes take the two LLMProvider defaults, so they keep testing a provider with no Crew-started sign-ins.
  • website/src/test/McpOAuthBanner.test.tsx: replaced and ended rows render nothing, even with a URL still on the row; a late success renders; the dead-process copy still renders.
  • Determinism: the three backend modules passed 5 consecutive runs and a full reversed-order run (82 tests).
  • Run here on Python 3.12: those modules, the bindings modules and every module that drives the drain or the turn handler (1441 passed), 10 related vitest files, tsc -p tsconfig.app.json, isort, flake8, mypy, the flake-pattern ratchet, i18n:check, lint:i18n. Semgrep is not installed here; CI's SAST lane runs it.

Proof: not provable -- other: reverting every production hunk removes names the tests import, so the mutated run errors at collection (INCONCLUSIVE), and the per-hunk run exceeded 30 minutes on this host

Manual verification

Rendered the built SPA at this head against three fixture transcripts (website/scripts/capture-22897-oauth-timeout.mjs) in light and dark. Before each frame the script asserts from the DOM: one live Authorize link and no retired card when an ended and a replaced card sit before a live one; no link and no retired card when the only attempt ended; and, for a late success, the authenticated card plus the still-rendered dead-process card. The real-gateway click-through is still to do.

Screenshots / video

The frames are committed under temp-screenshots/22897-oauth-card-expiry/ (description attachments returned 404 to the review lanes' fetch).

An ended card and a replaced card sit in the transcript before the live one; only the live card shows:

replaced, light

replaced, dark

The only attempt ended and nothing has been offered since; no card shows, and the next message's offer mints a fresh one:

ended, light

ended, dark

A success that lands after the attempt ended shows as authenticated; another server's card whose session died keeps its grey "send a message" card:

late success, light

late success, dark

Related Issues

Closes #22897

Sibling sweep

Sibling: src/kiro_crew/dashboard/handlers/connections.py -- not affected -- the Connections card reads its approval URL from the same mcp_oauth rows, and a retired row carries no oauth_url
Sibling: src/kiro_crew/dashboard/chat_utils_display.py -- not affected -- the dead-process card is the user's only way back in, so it keeps rendering

Pattern harvest

Rule candidate: review-prompt
Pattern: a slot or lease freed on completion without notifying the UI that shows the leased resource

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@kyleseaman
kyleseaman requested review from a team and KiroCrewCaptain as code owners October 21, 2026 21:08
@kyleseaman
kyleseaman requested a review from buluoray October 21, 2026 21:08
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 21, 2026
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — 🔴 BLOCK

Premise-level review of 74398e83252700d2dde6d572320cc8aa4a3d8077 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: BLOCK

The goal only needs the dead link withdrawn. Hiding replaced and ended cards outright reverses the #7580/#7654 pin, which held that a banner which vanishes reads as success, and nothing in the change shows that pin was wrong.

What this change ships

Inventory (8 items) — 6 justified

Intent: stop an MCP Authorize card from offering a link after its KAS sign-in attempt has ended. This is a FIX.

  1. An Authorize link is withdrawn when its attempt ends unconnected, even in an idle chat — justified
  2. A link drawn after its attempt already ended is retired at draw time — justified
  3. A stale queued link from an ended attempt can no longer block the replacement attempt's link — justified
  4. The ended-attempt hook is re-installed after a session reset or an MCP re-injection — justified
  5. A late success on an ended card still shows as signed in — justified
  6. An ended-attempt card now disappears instead of showing a "no longer active" notice — rides along; reverses the MCP OAuth banner keeps offering a dead Authorize link after a gateway restart or session reset #7654 pin
  7. A replaced (superseded) card now disappears instead of telling the user to use the latest button — rides along; reverses the MCP OAuth loopback callback fails on a stale ephemeral port; interactive re-auth via /mcp panel was the only way through #7580 pin
  8. The superseded copy, its 13 catalog strings and capture-mcp-oauth-superseded.mjs are deleted — rides along with 7

Blockers

Hiding retired cards reverses the "a vanished banner reads as success" pin — rides along
Trigger: the diff deletes // A vanished banner is the worse failure: it is indistinguishable from the sign-in having succeeded. and the test that says Falling through to null here would make the dead flow vanish silently instead of telling the user what to do (issue #7580). It replaces them with if (m.meta?.superseded) return null and if (expired && m.meta?.expired_reason === 'attempt_ended') return null. The description says only "disappears instead of turning grey". It gives no evidence the pin was wrong. The Goal ("stops offering its link") is already met by items 1–3, because a superseded row already had no link.
Outcome: a user whose sign-in ended sees no card at all, which looks like success. That is the confusion #7580 and #7654 were fixed to remove.
Subtraction: delete the two return null branches, keep the superseded render, its strings and its capture runner, and let an attempt_ended row take the existing terminal render.
Clears when: the two branches are removed, or the PR links evidence (an issue or decision) that the #7580/#7654 pin was wrong.

[FIRST-PRINCIPLES-REVIEWED] 74398e8

Description read

[DESCRIPTION-READ] ad90b3ef21aaf5d93683d1479f593cbb59c530c4be02ce3ebb52e3de6a9480d3

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 74398e83252700d2dde6d572320cc8aa4a3d8077 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. The removed strings and the deleted capture script have no readers left, and the change says outright that it reverses the old "superseded" pin rather than calling it a gap.

Notes

[DESIGN-REVIEWED] 74398e8

Description read

[DESCRIPTION-READ] 33f0b3630cec5e7ff771e51ba12b8a34572481f74a22413b32391aa81510549b

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 74398e83252700d2dde6d572320cc8aa4a3d8077 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing blocks. Screenshots and the blind read cover all three states. Removing a card is not a lens-13 swap.

Notes

  • Showing nothing for an attempt_ended card (McpOAuthBanner.tsx, if (expired && m.meta?.expired_reason === 'attempt_ended') return null) brings back the failure the deleted comment warned about: "A vanished banner … is indistinguishable from the sign-in having succeeded." In the ended shots (shot-01/02) the reader saw no hint that a server still needs sign-in. Either confirm that a fresh card always arrives without the user doing anything, or keep a one-line muted row ("figma sign-in timed out — a new link will appear") until the next offer replaces it.
  • The expired copy is unchanged, but this PR now relies on it. The blind reader tripped on it twice: "It doesn't say what message to send" and "'session' here seems to mean something other than my chats". A clearer string would be "figma sign-in stopped because Kiro Crew restarted. Send any message to get a new Authorize button."
  • The ended and replaced cards now disappear with no exit animation. A short fade-out would show the user that the card was retired, not lost.

[UX-REVIEWED] 74398e8

Description read

[DESCRIPTION-READ] 42fe4e2ced76c1ba1d5767f367f3f3d8fff00ecc3e5a889c5e67d913cc124830

That sha256 names everything this verdict read: the PR description, plus the 9 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 21, 2026
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 74398e83252700d2dde6d572320cc8aa4a3d8077 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 74398e8

Verdict parsed from the review's SHA-scoped output markers for commit 74398e83252700d2dde6d572320cc8aa4a3d8077.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 74398e83252700d2dde6d572320cc8aa4a3d8077 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 74398e83252700d2dde6d572320cc8aa4a3d8077 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 74398e8

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 74398e83252700d2dde6d572320cc8aa4a3d8077 false-positive: <reason, 20 to 500 characters>

@kyleseaman
kyleseaman force-pushed the fix/mcp-sign-in-card-expiry branch from 55d6709 to ca0e03e Compare October 21, 2026 23:18
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 21, 2026
@kyleseaman

Copy link
Copy Markdown
Contributor Author

self-added: no
mechanism: per-session ended-attempt hook on AcpRuntime, installed by the dashboard before it shows a link

  • span=ac50b0f97c0b Ended sign-in links remain clickable while chat is idle

fixed in ca0e03e. The runtime now reports an ended attempt through a per-session hook as well as the queue frame, so an idle chat retires its link without a turn.
The dashboard installs the hook before the endpoint check awaits and records any end heard meanwhile, so an attempt that ends before the banner exists still shows it expired.
The hook is skipped for a successful answer and for a dead or cancelled attempt; those leave the banner to completion and to the dead-child gate.
Tests: test_an_unconnected_end_calls_the_sessions_hook_while_the_slot_is_held, test_an_attempt_that_ends_during_the_endpoint_check_is_shown_expired (red with the old ordering).

@kyleseaman

Copy link
Copy Markdown
Contributor Author
  • span=bf3105d6ef14 The ended-attempt copy points users away from the working Authorize button

fixed in ca0e03e. The ended card now reads "sign-in ended before it was completed. Use the latest Authorize button and finish signing in within a minute, or send any message if no Authorize button is showing."
It points at the live card below it first, keeps "send any message" only as the fallback, and names the time limit, which covers both notes.
Refreshed light and dark screenshots of the ended card above a live one are attached to the description.

@kyleseaman
kyleseaman force-pushed the fix/mcp-sign-in-card-expiry branch from ca0e03e to eed18da Compare October 21, 2026 23:30
@kyleseaman

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in files this PR's tests touch since ca0e03e went green; also applied black to test/test_kas_mcp_sign_in.py (the one failing Backend Lint step). New head eed18da; CI re-running.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Oct 21, 2026
@kyleseaman

Copy link
Copy Markdown
Contributor Author

Real Adapter Contract Tests is red here for the same reason it is red on every PR since #22807: test_pi_real_adapter setup raises SandboxUnavailableError on the CodeBuild runner. Tracked in #22958 / #22959, with #22951 open as the fix. This PR touches no pi or sandbox code; it will rebase once that fix lands. The other red rows are cancelled duplicates superseded by a later run of the same lane.

@kyleseaman

kyleseaman commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased onto main (picks up test_issue_radar_crew_runtime_trust.py changes) and added the attempt_ended string to the 11 non-English catalogs, which Frontend Tests (3) catalogParity flagged. New head 34d2d74; CI re-running. Real Adapter Contract Tests is still expected red until #22951 lands (main-red, #22958/#22959).

@kyleseaman
kyleseaman force-pushed the fix/mcp-sign-in-card-expiry branch from eed18da to 34d2d74 Compare October 22, 2026 00:11
@kyleseaman

kyleseaman commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Frontend Tests (1)/(2): the fr, ru and bn attempt_ended strings used the formal register; switched to tu / ты / তুমি per each locale's style guide. All 50 src/i18n test files pass locally. New head d1fa204; rebased onto main.

@kyleseaman
kyleseaman force-pushed the fix/mcp-sign-in-card-expiry branch 2 times, most recently from d1fa204 to 0f26623 Compare October 22, 2026 00:55
@kyleseaman

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: removed the _kirocrew/mcp/sign_in_ended queue frame, EVENT_MCP_OAUTH_EXPIRED, its dispatch branch and pre-turn drain carve-out

  • span=5a53059d0b81 Second delivery path for the same retirement — duplicate

fixed in 0f26623. The frame path is removed: the per-session hook, installed by the dashboard before it shows a KAS link, is now the only way an ended attempt reaches the chat, busy or idle.
No case retired a card only by the frame: the only KAS card source is _show_mcp_oauth_request, which installs the hook first and records an end heard before the card exists.
session_handle_dispatch.py and session_handle_turn.py are back to main; the frame tests went with them, and the hook tests cover timeout, unsuccessful answer, success, other or departed session, a raising hook, dead process and cancellation.

@kyleseaman
kyleseaman force-pushed the fix/mcp-sign-in-card-expiry branch from 0f26623 to 33304fa Compare October 22, 2026 01:17
@kyleseaman

Copy link
Copy Markdown
Contributor Author
  • span=3338e5f1db13 Hard swap on replacement

Rebutted: dropping the replaced row without a transition is the repo owner's decision for this PR (Kyle, 2026-10-26); the new card is appended where its offer arrives, as on main.
An exit animation is new scope outside the frozen goal; recording the decision needs a maintainer owner-decision override.

@iamwhatever

Copy link
Copy Markdown
Contributor

Rebased onto main (2ec42c9 -> current main). Conflicts resolved: locale catalogs keep main's new failed_next_step and drop superseded; the mid-turn path keeps main's card_owned tag (#25687) and now passes session_id through _show_mcp_oauth_request. Test fixes in 201ea88: since #26481 a replacement sign-in is offered only for a named server, so the replacement test names it; main's mid-turn and dedupe fakes gain the two LLMProvider sign-in defaults. #28630 (shared sign-in store) does not cover this: the first sign-in still needs a live card. Local: 528 Python tests in the MCP banner / KAS sign-in files, McpOAuthBanner vitest (28), i18n:check, lint:i18n and tsc pass.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Nov 3, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

Blocked on a maintainer decision after the rebase (head 201ea88). GPT review passes; First Principles and UX both BLOCK on the same point raised before: hiding superseded and attempt_ended cards with no notice reverses the #7580 pin ("a vanished banner reads as success"). Earlier heads carried rebuttals citing an owner decision (Kyle, 2026-10-26), but no linked issue or docs/decisions entry records it, and UX now asks for a recording of a live card vanishing.

A maintainer needs to pick one:

  1. Keep the design: record the decision (issue or docs/decisions entry, linked from the description) and post, if you agree:
    /ai-review override first-principles 201ea882e62328de5bfe019ab35f73e437a32734 false-positive: Hiding replaced and ended Authorize cards is the owner's recorded decision for this fix; only a live card per server is shown.
    plus a UX override or a screen recording of a card retiring.
  2. Narrow the PR: restore the superseded render path, strings, tests and capture runner, and keep attempt_ended as the only hidden state (or show a short "link expired, a new one is on its way" note).

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: checking Automated validation is still running labels Nov 3, 2026
@kyleseaman
kyleseaman force-pushed the fix/mcp-sign-in-card-expiry branch from 201ea88 to 5007706 Compare November 6, 2026 20:08
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 6, 2026
kseamaws and others added 2 commits November 6, 2026 23:09
A KAS sign-in attempt holds its OAuth callback listener for one connect
attempt. Once the attempt ends unconnected, its Authorize link points at a
closed localhost port. The runtime now tags each consent URL with a
monotonic sign-in attempt number, drops queued URLs from an ended attempt,
and tells the owning chat (idle or mid-turn) through a per-session
sign-in-ended hook, which withdraws that server's open links.

A replaced card (superseded) or an ended attempt (expired, reason
attempt_ended) is no longer drawn at all, so a chat shows at most one live
Authorize card per server. A late success still flips the row to
authenticated. The now-unused superseded and attempt_ended copy is removed
from every locale.

Closes #22897
Since #26481 a replacement sign-in is offered only for a server the user
named, so the replacement test names it. The mid-turn and dedupe fakes
from main gain the two LLMProvider sign-in defaults the banner path now
calls.
@kyleseaman
kyleseaman force-pushed the fix/mcp-sign-in-card-expiry branch from 5007706 to 74398e8 Compare November 6, 2026 23:10
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 8, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

[operator: bolichen97] Continuing this in #34627; thanks for the start.

bolichen97 added a commit that referenced this pull request Nov 11, 2026
On the KAS backend the engine keeps a sign-in attempt's OAuth callback
listener open only for the server's connect timeout. When the attempt
ended, the runtime freed its sign-in slot but told nobody, so the chat
kept a live-looking Authorize card whose link now ends on a refused
localhost port.

The runtime now reports an attempt that ends without the server
connecting to a per-session hook, which the dashboard installs through
the provider before it draws a link. The hook withdraws that server's
open links and marks the rows expired with reason attempt_ended. An
attempt that ended before its row was drawn is caught when the row is
appended, by asking the provider whether the runtime still holds that
sign-in. The card renders as a failure notice that says the sign-in
timed out and how to get a fresh link. A later success still turns the
card green.

Builds on #22907.

Closes #22897
bolichen97 added a commit that referenced this pull request Nov 11, 2026
…ut (#34627)

On the KAS backend the engine keeps a sign-in attempt's OAuth callback
listener open only for the server's connect timeout. When the attempt
ended, the runtime freed its sign-in slot but told nobody, so the chat
kept a live-looking Authorize card whose link now ends on a refused
localhost port.

The runtime now reports an attempt that ends without the server
connecting to a per-session hook, which the dashboard installs through
the provider before it draws a link. The hook withdraws that server's
open links and marks the rows expired with reason attempt_ended. An
attempt that ended before its row was drawn is caught when the row is
appended, by asking the provider whether the runtime still holds that
sign-in. The card renders as a failure notice that says the sign-in
timed out and how to get a fresh link. A later success still turns the
card green.

Builds on #22907.

Closes #22897
@iamwhatever

Copy link
Copy Markdown
Contributor

Thanks for starting this. A maintainer continued this work in #34627, which has since merged on main and closed issue #22897, so I'm closing this PR as superseded. Please reopen if anything here is still missing from main.

auto-merge was automatically disabled November 14, 2026 11:09

Pull request was closed

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

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP Authorize card stays clickable after its sign-in attempt times out

4 participants