Repository navigation
fix(mcp): withdraw an Authorize link once its sign-in attempt times out - #34627
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The runtime reports the end of the attempt at the point where it already frees the sign-in slot. The card also checks once when it is drawn, which covers attempts that end before the card exists. Notes
[DESIGN-REVIEWED] 721b36a Description read[DESCRIPTION-READ] 05d07be83a386abcb7d76a21d17b3ffe611f90732a2d3c7b886b57a9d4e2c2e0 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Each new surface has exactly one consumer (the mid-turn arm), and the fix sits where the cause is: the runtime freed the sign-in slot but never told the chat. What this change shipsInventory (7 items) — 7 justifiedIntent: a user who opens a KAS MCP Authorize card after its sign-in attempt ended should see that the sign-in timed out, not a link that ends on a refused localhost page. FIX (#22897).
[FIRST-PRINCIPLES-REVIEWED] 721b36a Description read[DESCRIPTION-READ] eecfcdd98201af26d4be302aecd3ab952f1c1a2d28061751cdd8a599c7083d59 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks: the only new surface is the timed-out notice, and the blind reader read it correctly ("my sign-in attempt expired… type the name in the chat to get a new sign-in button"). Notes
[UX-REVIEWED] 721b36a Description read[DESCRIPTION-READ] 27f56d6bfbad953792d46bce444c45f9b3a6c2adc7fdcb1ee01a7951dcd23b4e That sha256 names everything this verdict read: the PR description, plus the 7 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: |
buluoray
left a comment
There was a problem hiding this comment.
Approve on 4c78817. The runtime-to-chat expiry hook is correct and well tested (3 mutations each turn a named test red), but the PR's own new fr/ru/hi timed_out strings break the repo's i18n style tests (Frontend Tests 1 and 3 red), so it cannot merge as is; a 3-string fix. Named findings for Bolin: (1) fix the new fr/ru/hi pages.chat.mcpOAuthBanner.timed_out strings so Frontend Tests 1 and 3 pass; (2) GPT F2, McpOAuthBanner.tsx:180: the ended-attempt failure is grey text, not ErrorNotice; (3) GPT F1, mcp_session.py:802: if the attempt ends while the banner is still preparing (only when the connect timeout is set below the 8 s discovery cap and discovery is slow), a clickable Authorize card is left pointing at a closed callback port. No credential or privilege impact and the next message re-prompts, but GPT marked it security-class, so it needs your fix or your owner decision. Decisive lines: website/src/i18n/locales/fr.json (pages.chat.mcpOAuthBanner.timed_out), website/src/i18n/locales/ru.json (same key), website/src/i18n/locales/hi.json (same key); src/kiro_crew/dashboard/chat_turn/mcp_session.py:802 (F1, non-blocking); website/src/pages/chat/McpOAuthBanner.tsx:180 (F2, rule-scope call)
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
4c78817 to
721b36a
Compare
|
self-added: no
[operator: bolichen97] |
|
self-added: no
[operator: bolichen97] |
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates an 18% chance that this change introduces a defect, above the 12% limit for approving on its own. Approve. The PR adds a hook from the runtime to the chat, called when a KAS MCP sign-in attempt ends unconnected (answered An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
buluoray
left a comment
There was a problem hiding this comment.
Approve on 721b36a. The delta fixes every finding from the earlier APPROVE: an attempt that ends before its card is drawn now arrives withdrawn, the timed-out card is an ErrorNotice, and the fr/ru/hi (plus bn) strings follow the style rules; tests and two new mutations hold, and every red check on this head is GitHub rate-limit noise. Decisive lines: src/kiro_crew/dashboard/chat_turn/mcp_session.py:896-897 (draw-time check, fixes F1); src/kiro_crew/acp/session_provider.py (mcp_sign_in_ended, reattempts_mcp_servers and not mcp_sign_in_holds(...)); website/src/pages/chat/McpOAuthBanner.tsx (timedOut -> ErrorNotice with askAgent, fixes F2); website/src/i18n/locales/{fr,ru,hi,bn}.json pages.chat.mcpOAuthBanner.timed_out
Problem / Motivation
Goal: When a KAS MCP sign-in attempt ends without the server connecting, its Authorize card stops offering the dead link and says the sign-in timed out.
On the KAS backend the engine keeps a sign-in attempt's OAuth callback listener open only for the server's connect timeout (60 s by default). Nothing told the chat when that attempt ended, so its Authorize card stayed clickable. A click after that walks the user through the provider's consent page and lands the browser on
localhost:<port>/oauth/callback?code=…withERR_CONNECTION_REFUSED, and the sign-in never completes.Why it matters
A user who reaches the card more than a minute after it appeared cannot sign in from it, and nothing on screen says why. They finish the provider's consent page and end on a browser error, so the server looks broken instead of merely timed out.
Not a goal
mainthat a retired card stays visible as a grey notice.What changed (motivation → approach → change)
When a KAS sign-in attempt ends without the server connecting, its Authorize card drops the dead link and shows a failure notice that says the sign-in timed out, in tabs that are already open too. The cause:
AcpRuntime._run_mcp_sign_infreed the sign-in slot when the engine answered the reset but told nobody, so the chat kept the link live. The fix is a hook from the runtime to the chat, called when an attempt ends unconnected, plus one check when a card is drawn, because an attempt can end before its card exists.Builds on #22907 by @kyleseaman. It keeps that PR's runtime-to-chat hook and leaves out its card removal and attempt tagging.
acp/)success: false, refused with an error, or never answered, on a live process calls the session's ended-attempt hook with the server name, after the slot is freed; any other answer calls nothing.set_mcp_sign_in_ended_hookinstalls it andunregister_sessiondrops it. A process that died stays with the dashboard's dead-child gate.providers/base.py,providers/acp.py,acp/session_provider.py)LLMProvider.set_mcp_sign_in_ended_hookis a no-op andmcp_sign_in_endedanswers False by default.AcpProviderforwards both to the shared-runtimeAcpSessionProvider, which installs the hook for its session and answersmcp_sign_in_endedtrue when, on a live host that opens external URLs, the runtime no longer holds that session and server's sign-in.dashboard/chat_turn/mcp_session.py)mcp_sign_in_endedonce the row is appended, for an attempt that ended while its link waited in the queue or while endpoint discovery ran. Either way the row loses its link, takesexpiredwithexpired_reason: "attempt_ended"and the change reaches open tabs, idle chats included. A later success still turns the row green. Supersede and this expiry share one retire loop.website/src/pages/chat/McpOAuthBanner.tsx,website/src/i18n/locales/)attempt_endedrow renders throughErrorNotice, with the same "Ask the agent" decision as a failed sign-in, and a newtimed_outstring translated in every catalog: "sign-in timed out before it was completed. Name this server in a message to get a fresh Authorize link." A process-ended row keeps its grey notice. The capture harness (website/capture/mcp-oauth-banner.tsx) gains atimed-outrow.The specs
acp-client.mdandlearn-cron-dashboard.mddescribe the hook, the draw-time check and the expiry.Backwards compatibility
Compatible:
expired_reasonis a new optional meta key and both provider methods have a default; a row without the key renders as it does today.Removes nothing: the only link withdrawn is one whose callback listener the engine has already closed, and every banner state
maindraws still draws.Tests
test/test_kas_mcp_sign_in.py::test_a_sign_in_that_ends_unconnected_tells_the_chat_that_showed_its_linkdrives a sign-in through the realAcpProvider→AcpSessionProvider→AcpRuntimechain for five answers:success: falseand no answer tell the hook;success: true, an answer that states neither, and a dead process do not;mcp_sign_in_endedis False while the sign-in is held and True after; andunregister_sessiondrops the hook.test/test_mcp_oauth_banner_midturn.py::test_an_ended_sign_in_attempt_withdraws_its_link_and_the_next_offer_is_livepins that the hook the mid-turn arm installs withdraws the link (stored row and the open-tab frame) and that the next offer draws a live card.test/test_mcp_oauth_banner_midturn.py::test_an_attempt_that_ends_before_its_row_exists_still_withdraws_itpins both early windows (queued,discovery): the row arrives withdrawn, with no link.test/test_mcp_oauth_banner_midturn.py::test_a_late_success_still_turns_an_ended_attempts_card_greenpins that a success still lands on the timed-out row and a failure does not.website/src/test/McpOAuthBanner.test.tsx"says an attempt that ended unconnected timed out, with no link" and "shows a timed-out attempt as a failure, with the hand-off the host allows" (alert role, hand-off on and off, plain notice for a process-ended row).Proof: PROVEN test/test_acp_bindings.py::test_the_member_set_is_the_frozen_inventory (head 721b36a)
Determinism: the four new backend tests (five cases) passed 20/20 at
-n0and 10/10 at-n 4 --dist loadgroup --max-worker-restart=2besidetest_mcp_oauth_banner_dedupe.pyandtest_mcp_oauth_banner.py, and the 102 tests of their two files passed in a shuffled order (seed 16320). The frontend timed-out test passed 20/20, andMcpOAuthBanner.test.tsxpassed in a shuffled order (seed 16320).Manual verification
Rendered the real
McpOAuthBannerfrom this head in its capture harness (website/capture/mcp-oauth-banner.htmlon a local vite server), dark and light, with DOM checks: the live card has a link; the timed-out card has none, is an alert and says it timed out; the process-ended card is not an alert. Not run end to end against a live KAS engine and an OAuth MCP server; the runtime and dashboard tests above drive that path.Screenshots / video
Before (what
mainstill shows once the attempt has ended): the Authorize button looks live.After: the same card once its attempt ended, dark and light.
Every banner state from this head, light
Related Issues
Closes #22897
Sibling sweep
Swept:
git grep -nE "_run_mcp_reattempt|begin_mcp_sign_in|_mcp_sign_in = None" -- src/kiro_crew/acp/Sibling: src/kiro_crew/acp/runtime_host_requests.py:544 -- not affected --
_run_mcp_reattemptresets without startOAuth, so it never shows a linkSibling: src/kiro_crew/dashboard/chat_utils_display.py:1016 -- not affected --
_expire_dead_child_oauth_metaalready withdraws a link whose process diedPattern harvest
Not generalizable: the one runtime seam where an attempt's end was known but never reported to the chat; no other flow mints a link bound to a short-lived listener.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)