Repository navigation
fix(website): cancel a pending kiro sign-in once signed in elsewhere - #35176
Conversation
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The fix reuses What this change shipsInventory (5 items) — 5 justifiedIntent: FIX. If you start a Kiro sign-in in the dashboard and finish signing in somewhere else (another tab or the CLI), the dashboard should stop the sign-in it left waiting instead of polling it unseen (#34446).
[FIRST-PRINCIPLES-REVIEWED] 32d69c4 Description read[DESCRIPTION-READ] 7a1342d728f1ec4d2c437c17a54c455f74d39ebb80295fb9a58d65723a3b9266 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 pending sign-in is now cancelled through the same Notes
[DESIGN-REVIEWED] 32d69c4 Description read[DESCRIPTION-READ] efbe86b9a0659067af15f4aa0f3e818787d6fa95705872aed5bd3d480070dd02 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. The new notice says what happened, says it ends by itself, and offers a retry. The only weak spot is the retry button's label, which sits on a rare failure path. Notes
[UX-REVIEWED] 32d69c4 Description read[DESCRIPTION-READ] 04ed723397fcafe6e9dc7980a2fa51991c6bd0b7fd606a3d527067ebe5a8f1a5 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: |
Code change approver recommendation: ApproveWhy: the decider estimates a 12% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes. The PR adds an effect to KasLoginFlow. When the status read says signed in, no account switch is running, no cancel is already in flight, and a session is still pending, it drops the session (which turns off its poll) and cancels it through the existing settleCancel path. A failed cancel shows an ErrorNotice with Try again in the signed-in view. Verified: the backend cancel is idempotent (an unknown or finished id returns 200), so a login that already finished causes no false notice. A sign-in that lands at the same moment still clears the cached model list through settleCancel's landed check. Account switches are excluded, and the switch back-out button only appears when nothing is pending. Start over, Use code instead and Cancel are excluded while their cancel is in flight. The two new tests would fail without the fix. The new string is in en.manual.json and all 12 translated locales, the same way the existing cancel_unsettled key is. The GPT lane's blocking finding is about an earlier head and is fixed in this one. 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 |
67999f7 to
0d0e54b
Compare
|
Starting a Kiro sign-in and then signing in another way (another tab, the CLI) showed the signed-in view while the hidden login kept polling /api/kas-login/poll every few seconds. The gate renders the signed-in branch before the session branch, and the session was dropped only when its own poll answered authorized. When the status reads signed in, no account switch is running and no cancel is settling, the gate now drops the pending session and cancels it through the same settle path a user's cancel takes. If that cancel fails, the signed-in view shows a notice with Try again instead of dropping the failure. Closes #34446
buluoray
left a comment
There was a problem hiding this comment.
Approve on 0d0e54b. The new head handles the case the last review left open. When the automatic cancel of a dropped sign-in fails, the signed-in view now shows an error notice with Try again, and the dropped session stays dropped, so its poll does not resume. The new string is in every shipped locale. The new test turns red if the notice, the retry or the reset before a retry is removed. The red backend shards are the two tests that were failing on main before this PR's run, so the PR only needs a rebase. One small gap remains: no test covers the guard that skips the automatic cancel while a user's own cancel is settling. Removing that guard would only send a second cancel, which the gateway ignores. Decisive lines: website/src/components/KasLoginGate.tsx:1103-1114, website/src/components/KasLoginGate.tsx:1181-1196, website/src/components/KasLoginGate.test.tsx:391-431
0d0e54b to
32d69c4
Compare
|
Rebased: main moved in src/kiro_crew/dashboard/handlers/updates.py and test/test_update_boot_apply.py since this head's CI ran (f9788c5 -> e1b079c); CI re-running. The four Backend Tests reds and the Coverage Gate on 0d0e54b were main's (#35660: [operator: bolichen97] |
Problem / Motivation
Goal: When you start a Kiro sign-in in the dashboard and then sign in some other way, the dashboard ends the sign-in it left waiting instead of polling it unseen.
Start a Kiro sign-in in the dashboard (device code or browser), then finish signing in another way: another tab, or the CLI. The dashboard shows the signed-in view, but the abandoned sign-in keeps calling
/api/kas-login/pollevery few seconds for as long as the page stays open. The report counted 4 calls in the 16 s after the signed-in view appeared.Why it matters
Anyone who starts a sign-in in one place and finishes it in another gets a poll loop they cannot see or stop. The gateway keeps that login open until it times out, and for the browser flow that includes its callback port. On the Kiro sign-in card in Settings, Switch account then brings back the old code screen instead of the sign-in choices.
Not a goal
What changed (motivation → approach → change)
Once the account is signed in some other way, the dashboard now ends the Kiro sign-in it left waiting. Its poll stops, and Switch account on the Settings sign-in card opens the sign-in choices instead of the abandoned code. If ending it fails, the signed-in view says so and offers Try again.
Why it kept polling: the gate shows the signed-in view whenever the status says signed in, and it makes that check first. A pending sign-in is therefore hidden but stays alive, and its poll runs for as long as it exists. Only its own poll answering
authorizedever ended it, and that never happens when the sign-in finished in another tab or in the CLI.The fix is in
website/src/components/KasLoginGate.tsx. With no account switch running and no cancel already settling, the gate drops the pending sign-in and cancels it throughsettleCancel, the same path the Cancel button uses. That path re-reads the status and clears the cached model list when a sign-in landed, so a sign-in this login completed at that same moment still counts as one. The notice is anErrorNoticewith the agent hand-off, beside the existing "previous sign-in could not be removed" notice. Its one new string is in every shipped language underwebsite/src/i18n/locales/. The Settings card embeds the same flow and behaves the same way. Thekas-authspec says so.Backwards compatibility
Compatible: nothing a user can do today stops working. A pending sign-in is cancelled only after the status already says signed in, when nothing on screen can reach it any more.
Removes nothing: the only thing dropped is a hidden pending sign-in that the user could no longer see or act on.
Tests
KasLoginGate.test.tsx,cancels a pending sign-in and stops its poll once the account signs in elsewhere: starts the device flow, waits for its first poll, then changes the status read to signed in. It checks that the app renders, that the pending login is cancelled exactly once by its id, and that no poll runs in the next 15 s. Red on the parent commit (no cancel, and the poll keeps running), green with the fix.KasLoginGate.test.tsx,says so in the signed-in view when that cancel fails, and retries it from there: the same start, with the first cancel rejected. It checks that the signed-in view shows the notice, that no poll runs in the next 15 s, and that Try again cancels the same login id again and removes the notice once it settles. Red without the notice, green with it.Start over during an account switch ...) keep a pending sign-in open while the status still says signed in. They stay green, which pins the "no switch running" condition.Proof: not provable -- frontend test (prove.py runs Python only)
Manual verification
Ran the real Settings sign-in card (
KiroSignInCard) and the full-screen gate (KasLoginGate) in Chromium through Vite, scripted with Playwright, with only the/api/kas-logincalls stubbed. Started a Google device sign-in, then made the status read say signed in.KWXR-VBTM.Screenshots / video
Switch account after signing in elsewhere, before (the abandoned code screen comes back):
After (the sign-in choices):
The cancel failed: the Settings sign-in card, dark and light:
The same notice over the full-screen gate, above the dashboard:
The signed-in view once the cancel settles, the same as before this change
Related Issues
Closes #34446
Sibling sweep
Swept: git grep -nlE "login_id|loginId|user_code|qr_code|qrcode|deviceCode|device_code" -- website/src
Sibling: website/src/pages/settings/WeixinPanel.tsx -- not affected -- its QR stays on screen, and its own poll answer (confirmed, connected or expired) ends the session
Sibling: website/src/pages/settings/WhatsAppPanel.tsx -- not affected -- its QR stays on screen, and its own poll answer (connected, error or expired) ends the session
Sibling: website/src/components/MobileConnectModal.tsx -- not affected -- it reads its status once on open and has no pending sign-in to poll
Sibling: website/src/components/KasLoginGate.tsx -- not affected -- its
resetandreplaceAttemptcancels already show a failed cancel on the waiting screenPattern harvest
Rule candidate: review-prompt
Pattern: a render branch that hides a component's in-flight work (a poll, a listener) must also stop that work
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)