Skip to content

perf(mobile): reconnect environments immediately on resume - #4878

Merged
t3dotgg merged 7 commits into
mainfrom
t3code/speed-up-mobile-reconnect-1
Jul 30, 2026
Merged

perf(mobile): reconnect environments immediately on resume#4878
t3dotgg merged 7 commits into
mainfrom
t3code/speed-up-mobile-reconnect-1

Conversation

@t3dotgg

@t3dotgg t3dotgg commented Jul 29, 2026

Copy link
Copy Markdown
Member

Returning to T3 Code Mobile after using another app could leave every suspended environment waiting on a socket probe and retry backoff, making multi-environment reconnects feel sequential.

This change gives mobile resume an explicit fast path:

  • brief interruptions immediately probe existing sessions and refresh shell/thread subscriptions
  • meaningful background suspensions replace stale session leases so environments reconnect in parallel
  • foreground activation interrupts any in-flight probe or retry delay and resets the retry ladder
  • a reconnect request received during an active probe is retained and honored after the probe finishes

The branch is rebased onto current main, including #4882. That PR improves mobile action/feed responsiveness but does not overlap the connection runtime. After comparing #4885, this PR adopts its useful retry-backoff reset while keeping the existing in-memory token catalog and relay synchronization model; migrating persisted tokens or widening the relay critical section would add failure surface without improving the normal foreground path.

Verification

  • 58 focused client-runtime/mobile tests
  • @t3tools/client-runtime typecheck
  • @t3tools/mobile typecheck
  • targeted client-runtime lint
  • iOS Simulator: two connected environments plus five offline environments, backgrounded for 11 seconds, then resumed from the app icon; connected environments stayed available while only the offline environments retried

iOS resume verification

Watch the full verification clip (the middle background interval is accelerated).

Made with GPT-5.6 Sol in the Codex harness through T3 Code.

Note

Reconnect mobile environments immediately on resume after long background suspension

  • Adds mobileApplicationActiveWakeup in app-state-wakeups.ts to classify resume events as either application-active-probe (short interruption, <10s) or application-active-reconnect (long suspension, ≥10s).
  • On application-active-reconnect, the connection supervisor resets the retry backoff ladder and immediately replaces the session rather than probing the existing one.
  • On application-active-probe, the supervisor runs a liveness probe with a 3s timeout (vs 15s normally); shell and thread state resubscribe on probe but not on reconnect.
  • Bearer descriptor caching (10s TTL) and a 3s DPoP socket ticket timeout are added to the authorization service to reduce reconnect latency.
  • Behavioral Change: application-active wakeup is split into two distinct kinds; any code relying on application-active alone will not receive mobile resume events.

Macroscope summarized e279787.


Note

Medium Risk
Changes core connection supervisor behavior, mobile wakeup semantics, and remote auth caching/timeouts; broad test coverage but affects reconnect and token paths for all mobile environments.

Overview
Mobile resume no longer treats every foreground return like a single application-active probe. Short background gaps emit application-active-probe (3s health check, shell/thread resubscribe). ≥10s in background emits application-active-reconnect, which replaces the session immediately and resets the retry ladder instead of waiting on probes or backoff.

The connection supervisor honors application-active-reconnect during setup, while connected, and during an in-flight probe (probe is interrupted). Foreground activation also resets backoff when offline, blocked, or waiting to retry.

Remote authorization caches validated bearer descriptors for 10s (fewer descriptor fetches; fresh websocket tickets each connect). Cached DPoP endpoint use now uses a 3s websocket-ticket timeout and refreshes after the first transient socket failure (replacing a two-failure threshold).

Shell and thread sync only resubscribe on probe-style wakeups, not on reconnect (new session already drives sync).

Reviewed by Cursor Bugbot for commit e279787. Bugbot is set up for automated code reviews on this repo. Configure here.

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

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR 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