Repository navigation
fix(mcp): retire an Authorize card once its sign-in attempt ends - #22907
kyleseaman wants to merge 2 commits into
Conversation
First Principles Review (Opus 5.5) — 🔴 BLOCKPremise-level review of 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 shipsInventory (8 items) — 6 justifiedIntent: stop an MCP Authorize card from offering a link after its KAS sign-in attempt has ended. This is a FIX.
BlockersHiding retired cards reverses the "a vanished banner reads as success" pin — rides along [FIRST-PRINCIPLES-REVIEWED] 74398e8 Description read[DESCRIPTION-READ] ad90b3ef21aaf5d93683d1479f593cbb59c530c4be02ce3ebb52e3de6a9480d3 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of 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 |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks. Screenshots and the blind read cover all three states. Removing a card is not a lens-13 swap. Notes
[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 |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
55d6709 to
ca0e03e
Compare
|
self-added: no
|
|
ca0e03e to
eed18da
Compare
|
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. |
|
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). |
eed18da to
34d2d74
Compare
|
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. |
d1fa204 to
0f26623
Compare
|
self-added: yes
|
0f26623 to
33304fa
Compare
|
64d01a7 to
201ea88
Compare
|
Rebased onto main (2ec42c9 -> current main). Conflicts resolved: locale catalogs keep main's new |
|
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 A maintainer needs to pick one:
|
201ea88 to
5007706
Compare
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.
5007706 to
74398e8
Compare
|
[operator: bolichen97] Continuing this in #34627; thanks for the start. |
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
…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
Pull request was closed
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
localhostcallback.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=…withERR_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
timeoutinmcp.json, at most 600 s), not something Crew's reset request controls.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.
_run_mcp_sign_infrees the slot when the engine answers thestartOAuthreset, but tells no one. Cards were only retired by a newer request or a dead child process.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_requestframe assignInAttempt. 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
expiredstate every terminal gate already reads, withexpired_reason: "attempt_ended".McpOAuthBanner.tsxrenders nothing for that row or for asupersededone; a completion that lands afterwards still flips the row to authenticated, and it shows. The dead-processexpiredcard still renders, because nothing else offers that user a way back in. Thesupersededandattempt_endedstrings are removed fromlocales/en.json,locales/en-XA.jsonand the eleven translated catalogs. The superseded capture runner goes with its state, the banner capture harness andcapture-mcp-oauth-expired.mjsdrop the superseded row, and theacp-client.mdspec 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 inacp/session_handle_mcp.py; session-side install inacp/session_provider.py; provider hook inproviders/base.pyandproviders/acp.py; cards inchat_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 onLLMProvider) and an optionalexpired_reasonmeta 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
supersededandattempt_endedrows; testrenders nothing for a replaced card, even one still carrying a urlReader: 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 onesReader: 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; testtest_the_read_gate_keeps_the_timeout_reasonReader: 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_endedrow; testtest_a_completion_that_lands_after_the_timeout_still_signs_inReader: website/src/i18n/locales/*.json:pages.chat.mcpOAuthBanner.superseded and .attempt_ended -- release -- no remaining caller (
git grepfinds none);npm run i18n:checkandlint:i18npassTests
Cases covered:
test_showing_a_link_installs_a_hook_that_retires_it_while_idle,test_an_unconnected_end_calls_the_sessions_hook_while_the_slot_is_heldtest_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_pathtest_a_link_drained_at_turn_start_is_judged_and_hookedtest_an_ended_attempt_request_cannot_deduplicate_its_replacement,test_a_fresh_banner_after_the_timeout_is_live, vitestkeeps the one live card beside hidden retired onestest_a_completion_that_lands_after_the_timeout_still_signs_in, vitestshows a late success on a card whose attempt had endedtest_another_servers_banner_keeps_its_link,test_a_queued_request_after_a_reinstalled_hook_is_still_judged,test_another_sessions_hook_is_not_calledtest_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_nonetest/test_kas_mcp_sign_in.py: the hook fires (slot still held) for a timeout or an unsuccessful answer, never forsuccess: 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 broadcastsoauth_url: ""bymid; 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 twoLLMProviderdefaults, 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.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:
The only attempt ended and nothing has been offered since; no card shows, and the next message's offer mints a fresh one:
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:
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_oauthrows, and a retired row carries nooauth_urlSibling: 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