← Back to Pull requests

Sign-in: keep the app answering the browser while it waits (bugfix) #572

Closed
unknown closed this pull request without merging on Nov 27, 2026 21:05 UTC
View on GitHub
unknown unknown commented on Nov 27, 2026 19:54 UTC
Author

Fixes #555

What and why


Sign in with browser comes back through a listener on 127.0.0.1 inside the app. On Android, once the sign-in page covers Kyllene, the app drops to the cached state. Two things then stop the listener from answering:

  • Frozen. The cached-app freezer freezes the app, about 60–75 s in on an Android 17 emulator. The browser's request waits in the listener's queue and is never accepted. This happens with battery usage Optimized, and with Unrestricted too when the sign-in is slow.

  • Blocked. With battery usage Restricted, Android's standby firewall drops loopback packets to the app. The browser shows "can't connect".
  • The gateway logs the code as issued, but POST /auth/native/token never arrives. Every Hermes tag from v0.22.0 to v0.23.4 accepts only an http://127.0.0.1 or [::1] redirect, so a custom-scheme or App Link redirect isn't possible.

    This change:

  • SignInService, a special-use foreground service with a quiet "Finishing sign-in…" notification.

  • - BrowserSignIn holds it from just before the browser opens, while Kyllene is still in front, until the sign-in ends: success, a turned-down code, the 10-minute timeout, Cancel, or switching gateway (in a finally).
    - It is START_NOT_STICKY and stopWithTask, and it stops itself after 11 minutes at most. If the process dies, it goes with it.
    - Why special use: shortService is cut off after 3 minutes, less than a sign-in with a second factor can take.
  • When battery usage is Restricted, Android demotes any foreground service as soon as the app leaves the front, so the service isn't started.

  • - The waiting screen shows a warning line instead, with a Battery settings button that opens the app's info page. Android has no public link to the battery page itself.
    - The check runs again whenever Kyllene comes back in sight. A sign-in still waiting gets held up once the restriction is lifted.
  • Shared code: a SignInKeepAlive interface in shared:core. It does nothing on desktop and in tests.

  • New strings are in every values-* folder. The ROADMAP item for browser sign-in now has a note.
  • Gateway versions: the change is client-side only. It changes no gateway call or route, so it behaves the same with Hermes v0.22.0 to v0.23.4, in legacy and session-authority modes. I didn't run the gateway matrix.

    Tests


  • BrowserSignInTest (MockEngine for /auth/native/token). These tests fail without the fix:

  • - the app is held from before the browser opens until the code is redeemed;
    - it is let go on a turned-down code (400), on the timeout and on cancel;
    - nothing is held when the listener can't start;
    - a refused hold still signs in.
  • SignInViewModelTest:

  • - the hold covers only the wait, and Cancel and switching gateway let go;
    - the restricted hint follows the setting.
  • New preview: PreviewScene.SignInRestricted, at 360 dp.

  • Commands run:

  • - Passed: the CI command, plus :desktopApp:compileKotlinJvm.
    - :shared:ui:jvmTest: DesktopPdfTest failed two tests locally (closeDuringReplacementStartupCannotPublishALiveWorker, renderDeadlineAndExplicitCloseUnblockPipeReads). This change doesn't touch that code, and that task isn't in CI's command.
  • Race from review: a cancelled sign-in that lets go late used to drop the next sign-in's hold. Covered by aCancelledSignInLettingGoLateKeepsTheNextOneHeld: it failed before d5ecf7e9 and passes now.

  • Device: not tested.

  • - I waited 30 minutes, but no emulator slot was free. Slot 0 was taken, and slots 1 and 2 can't boot while slot 0 runs without -read-only.
    - I reproduced the bug on an Android 17 emulator against a fake OIDC gateway, but not on this branch.
    - Still to check on a device, with a ~90 s identity-provider delay:
    - Optimized and Unrestricted: no am_freeze, and the token POST arrives.
    - Restricted: the hint shows, and the button opens App info.
    - The notification appears and goes away when the sign-in ends.

    Diff: 507 lines (+380 / -127) across 6 files Reviewer: Giton22 Review duration: 70m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 507 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.373
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #572"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.6% (MEDIUM) · Higher = larger blast radius
    47.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.8% · Safe to merge
    18.8%