perf(mobile): reconnect environments immediately on resume - #4878
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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
@t3tools/client-runtimetypecheck@t3tools/mobiletypecheckWatch 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
mobileApplicationActiveWakeupin app-state-wakeups.ts to classify resume events as eitherapplication-active-probe(short interruption, <10s) orapplication-active-reconnect(long suspension, ≥10s).application-active-reconnect, the connection supervisor resets the retry backoff ladder and immediately replaces the session rather than probing the existing one.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.application-activewakeup is split into two distinct kinds; any code relying onapplication-activealone 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 emitsapplication-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-reconnectduring 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.