Skip to content

Fix authentication request mismatch: double-tap guard + stale redirect drop - #9

Merged
wparad merged 1 commit into
mainfrom
claude/authress-login-performance-9tzo38
Aug 16, 2026
Merged

Fix authentication request mismatch: double-tap guard + stale redirect drop#9
wparad merged 1 commit into
mainfrom
claude/authress-login-performance-9tzo38

Conversation

@wparad

@wparad wparad commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #8 (merged) — the diagnostic logging it added surfaced a real "authentication request mismatch" happening in practice, root-caused here.

Two distinct triggers, both fixed:

  • Double-tap on Continue. Compose doesn't debounce onClick, so two rapid taps could fire authenticate() twice before the first tap's status update recomposed the button away. The second call's POST /authentication overwrites the pending request the first call's Custom Tab is about to redirect back to → mismatch. LoginScreen now disables Continue synchronously on click via a local guard (signInStarting), independent of the coroutine's async state update, so a second tap in the same frame is a no-op.
  • "Try again" while an old Custom Tab is still alive. This is a legitimate, intentional retry path (shown after the slow-hint), but the abandoned tab can still redirect back afterward carrying its now-superseded authenticationRequestId. authenticate() already logged this abandonment; completeAuthenticationRequest() now checks the redirect's ID against the recorded abandoned one and drops a recognized stale redirect quietly (info log, no _authStatus mutation, no user-facing error) instead of throwing AuthressException("Authentication request mismatch"). A mismatch that isn't a recognized abandonment still throws — that's still a real problem worth surfacing.

Test plan

  • Manual: rapid double-tap Continue — confirm only one Custom Tab opens and no mismatch error appears
  • Manual: tap Continue, wait past the slow-hint, tap "Try again", then complete sign-in in the first browser tab if it's still open — confirm the stale redirect is dropped silently (visible only as an info log in the diagnostic overlay) and the second attempt still completes normally
  • Could not run a full Gradle build in this environment (no Android SDK available in the sandbox); changes were reviewed manually against existing call sites

Generated by Claude Code

Two real triggers for "authentication request mismatch", both now fixed:

- Continue had no debounce: two rapid taps could fire authenticate() twice
  before the first tap's state change recomposed the button away, so the
  second call's POST /authentication overwrote the pending request the
  first call's Custom Tab was about to redirect back to. LoginScreen now
  disables Continue synchronously on click via a local guard, independent
  of the coroutine's state update.
- Tapping "Try again" while an earlier Custom Tab is still alive is a
  legitimate, intentional way to restart — but that old tab can still
  redirect back afterwards with its now-superseded authenticationRequestId.
  authenticate() already logged this abandonment; completeAuthenticationRequest()
  now checks the redirect's ID against it and drops a recognized stale
  redirect quietly (info log, no _authStatus change, no user-facing error)
  instead of throwing "Authentication request mismatch". An unrecognized
  mismatch still throws — that's still a genuine problem worth surfacing.
@wparad
wparad merged commit 24b5a04 into main Aug 16, 2026
2 checks passed
@wparad
wparad deleted the claude/authress-login-performance-9tzo38 branch August 16, 2026 08:08
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.

2 participants