Skip to content

fix(mobile): T3 Connect sign-in recovers after launching offline - #41712

Open
tris203 wants to merge 1 commit into
pingdotgg:mainfrom
tris203:fix/android-connection-recovery
Open

tris203 wants to merge 1 commit into
pingdotgg:mainfrom
tris203:fix/android-connection-recovery

Conversation

@tris203

@tris203 tris203 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Problem

If the mobile app starts while the device has no network (Android often restarts a killed app as you return to it, sometimes before Wi‑Fi reconnects), Clerk's first load fails and never retries. The T3 Connect sign-in stays empty, so every environment — including ones on a LAN route — sits on "This device is still loading its T3 Connect sign-in" and keeps retrying until the app is force-quit.

Reproduce on Android: force-stop the app, turn on airplane mode, open the app, wait ~10 s, turn airplane mode off. Expected: the sign-in loads and environments reconnect. Actual: stuck until force-quit. Seen on the Android internal build 2.3.0-816; the steps above reproduce it on that build.

This is the mobile side of #37602. #37621 fixes the web client by reloading the page; that does not apply to mobile.

Change

  • Turn on @clerk/expo's resource cache. Without it, clerk-js (6.42.3) treats a failed native launch load as fatal and nothing retries it. With it, Clerk loads the cached client offline and retries the network fetch with backoff. It is passed in both places it matters: getClerkInstance (the singleton is created there, and Clerk only reads the cache when it creates the singleton) and <ClerkProvider> (which only reports offline failures as network_error, the code the fallback needs, when the cache is set).
  • The cloud account service already ignores signed-out emissions from Clerk's client_init placeholder until Clerk's API confirms a sign-out. An empty resource cache loads a different placeholder, client_DUMMY_ID, with no user. Without treating it the same way, a signed-in user's first offline launch on this build would count as a sign-out and remove their T3 Connect environments. Clerk does not export its isDummyClient check, so the id is matched next to client_init.

Scope

Bug fix. Linked issue: #37602 (same symptom and cause, reported for desktop).

Verification

On an Android emulator (Pixel 9, API 37) with the dev client and production T3 Connect config, signed out. The "T3 Account" row in Settings shows "Checking" until Clerk has loaded, so it shows whether the load recovered.

  • Before: airplane mode on, launch, airplane mode off. The row stayed on "Checking" for the 90 s I watched after the network came back.
  • After, with app data cleared (empty cache): offline, Clerk loaded the placeholder client and the row showed "Sign in". About 10 s after the network returned, Clerk fetched the real client (temporary logging showed the id change from client_DUMMY_ID to a real client_… id) with no restart, and the sign-in screen opened.
  • cloudAccountService.test.ts: the new client_DUMMY_ID case fails on main and passes with this change. vp run check:changed passes.
Before (90 s after reconnecting) After (back online, no restart)
before after

Not checked: the signed-in path end to end, meaning an offline launch while signed in that then reconnects a T3 Connect environment once the network returns. I only tested signed out, so that path is inferred from Clerk's code, not observed.

Claude Opus 5.5 in Claude Code (T3 Code)

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 23, 2026
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 6bfe0fb and 121ba4a.

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

No actionable comments were generated in the recent review.

Walkthrough

The mobile Clerk provider and service singleton now receive the same resource cache. The cloud account service ignores client_DUMMY_ID as a placeholder, and the offline-launch test covers this observation.

Changes: Mobile Clerk resource-cache handling

Layer / File(s) Summary
Pass the resource cache to Clerk
apps/mobile/src/features/cloud/CloudAuthProvider.tsx
The service singleton and rendered ClerkProvider receive Clerk’s resourceCache.
Ignore the Expo placeholder client
packages/client-runtime/src/relay/cloudAccountService.ts, packages/client-runtime/src/relay/cloudAccountService.test.ts
The service rejects client_DUMMY_ID as a placeholder. The offline-launch test verifies that this observation leaves the service unobserved and produces no log entries.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

  • pingdotgg/t3code#24306 — The issue reports a mobile account row stuck on “Checking” during launch. This change addresses an offline-launch placeholder observation, though the issue’s trigger is unknown.

Possibly related PRs

  • pingdotgg/t3code#25150 — Adds the mobile adapter and attaches the cloud account service to the native Clerk singleton used by this change.
  • pingdotgg/t3code#24974 — Adds the shared cloud account service and tests that this change updates.

Suggested reviewers: juliusmarminge, macroscopeapp

Merge Risk: Minimal · previous review 6bfe0

This change lets mobile T3 Connect sign-in recover after the app launches offline, and it stops the Clerk placeholder client from being treated as a sign-out. No concrete merge-blocking risk was established. The signed-in offline-launch and reconnection path was not tested and is worth a manual check if convenient.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a mobile fix so T3 Connect sign-in recovers after the app launches offline. The changeset enables Clerk's resource cache and treats the client_DUMMY_ID placeholder as …
Description check Passed The description follows the template sections: Problem, Change, Scope, and Verification. The Problem section gives the symptom, reproduction steps, and expected and actual behavior. The Change section…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: a mobile fix so T3 Connect sign-in recovers after the app launches offline. The changeset enables Clerk's resource cache and treats the client_DUMMY_ID placeholder as an id-less client, which matches the title. It is a conventional commit title in plain language.

Full details: Description check

Explanation

The description follows the template sections: Problem, Change, Scope, and Verification. The Problem section gives the symptom, reproduction steps, and expected and actual behavior. The Change section explains both the resource cache and the client_DUMMY_ID handling, and why each is needed. Scope links issue #37602 and calls the work a bug fix. Verification gives focused test results and before/after evidence, and it states what was not checked. The author also names the model and harness used, as the template asks. Minor gap: the Scope section does not say why the change needs no issue, but a linked issue is provided, so this is not required.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
Fix failing CI checks

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 42c9107 and 6bfe0fb.

Files selected for processing: 3

  • apps/mobile/src/features/cloud/CloudAuthProvider.tsx
  • packages/client-runtime/src/relay/cloudAccountService.test.ts
  • packages/client-runtime/src/relay/cloudAccountService.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@tris203
tris203 force-pushed the fix/android-connection-recovery branch from 6bfe0fb to 121ba4a Compare November 23, 2026 22:51

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant