Skip to content

fix(ui): show setup-MFA backup codes before the next session task - #1083

Merged
swolfand merged 8 commits into
mainfrom
claude/mfa-backup-codes-1081
Oct 15, 2026
Merged

swolfand merged 8 commits into
mainfrom
claude/mfa-backup-codes-1081

Conversation

@claude

@claude claude Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Requested via Slack thread

Before: with both setup-mfa and choose-organization pending, the response that enables the second factor changes the session. ObservePendingSessionTaskRouting reacts to that by pushing choose-organization on top of SessionTaskMfaView, so the backup codes step never shows.

After: the MFA task stays on screen until the user closes the backup codes. Closing them then continues to choose-organization, or completes auth if nothing else is pending.

How: authNavigationCommand no longer pushes a pending task over AuthDestination.SessionTaskMfa, because that view owns its own exit. The MFA entry in AuthView now finishes through AuthState.handleSessionTaskCompletion, the same hand-off the organization and reset-password tasks use, instead of calling onAuthComplete directly. That replaces the MFA destination with the next pending task, or completes auth when there is none. Adds a routing test for the MFA-on-top, org-pending case.

Because the MFA view now owns its exit, it also exits when the task goes away from any step, not only the method list. If MFA is set up on another device while the authenticator setup, phone number or code entry step is showing, the view hands off right away. It stays only while the backup codes are showing or while this device's own enrollment request is in flight, since that response is what removes the task and carries the codes.

UserButton: the setup-MFA dialog it opens for a ForcedMfa session now shows choose-organization inside the dialog after the backup codes are closed, instead of closing the dialog.

Tests: SessionTaskMfaViewTest covers MFA set up elsewhere during the authenticator setup and code entry steps. AuthViewMfaBackupCodesTest runs the whole AuthView: setup-mfa, then backup codes, close, then choose-organization, with onAuthComplete not called.

Fixes #1081
Linear: MOBILE-666

🤖 Generated with Claude Code

https://claude.ai/code/session_0152AP8LYmzdGZ7prbS9nKZV


Generated by Claude Code

mikepitre and others added 4 commits October 9, 2026 00:59
Three of the six tests fail here. The task calls onAuthComplete as soon
as the session stops requiring MFA, which is before the user has seen
the backup codes that the enrollment returned.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…letes

SessionTaskMfaView called onAuthComplete as soon as the session stopped
requiring MFA. The response that enables the second factor is also the
one that carries the backup codes, so the task completed while the code
step or the phone number step was still on screen, and the app left
AuthView before the backup codes step could show.

The task now completes when MFA is set up and the flow would otherwise
go back to the method list, which is where every step goes when it
ends. A step that is still open keeps the screen: a verification that
returns backup codes shows them, and closing them completes the task.
onAuthComplete is called once, however many times they are closed.

System back on the backup codes closes them the same way. Without that
it popped the task off AuthView's back stack and left the sign-in screen
up over an active session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ompletes

UserButton closed the dialog it opens for a session that must set up
MFA as soon as the session stopped requiring MFA. That is the moment the
backup codes arrive, so the dialog closed before they could show.

AuthView already closes the dialog through onAuthComplete. The effect
now closes it only when the session is gone, which keeps a sign-out
inside the dialog from leaving the sign-in screen up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ackup codes

The pending-task router pushed choose-organization as soon as the response that
enables the second factor changed the session, so the MFA view never showed its
backup codes. The router now leaves the MFA task on top, and the MFA entry hands
off through AuthState once the user closes the codes, which continues to the next
pending task or completes auth.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0152AP8LYmzdGZ7prbS9nKZV
@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository: clerk/clerk-android/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b21eee87-a73f-4a11-ad5e-73525d7272f0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Base automatically changed from mike/fix-setup-mfa-backup-codes to main October 13, 2026 17:59
@swolfand

Copy link
Copy Markdown
Collaborator

AuthView no longer pushes the next session task over SessionTaskMfaView,
so the MFA view has to exit on its own. It only did that from the method
list. If the task went away while the authenticator setup, phone number
or code entry step was showing (MFA set up on another device), the user
stayed on that step.

The view now completes the task from any step once the session no
longer requires MFA, except while the backup codes are showing or while
this device's own enrollment request is still in flight. That request
is the one whose response removes the task and carries the backup
codes, so the step stays until the codes arrive.
@swolfand
swolfand marked this pull request as ready for review October 15, 2026 17:34
@swolfand
swolfand merged commit 864a607 into main Oct 15, 2026
20 checks passed
@swolfand
swolfand deleted the claude/mfa-backup-codes-1081 branch October 15, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setup-MFA backup codes are never shown when forced organization selection is also on

3 participants