Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): Retry recovers a T3 Connect environment after Clerk failed to load #37621

Openjuliusmarmingewants to merge 1 commit intomain fromrefs/pull/37621/headopened View on GitHub

juliusmarmingecommented

No changes needed this round. PR #37621 at b451625: all 39 checks pass. CodeRabbit reported no actionable comments. Macroscope posted only an approvability verdict ('Needs Human Approval'), not a code finding. It cites the intended behaviour (Retry reloads the page for T3 Connect environments when Clerk failed to load) and the new 'oxlint-disable-next-line t3code/no-unreasoned-state-sync -- ' line, which is the form AGENTS.md prescribes for an effect that stays. Nothing to fix; it needs a maintainer's approval. The fix itself: ManagedRelayAuthProvider registers the mounted Clerk instance in clerkLoadFailure.ts, and Settings 'Retry now' and the composer banner's Retry/Reconnect call the existing retryClerkLoad() (reload) when Clerk's status is 'error' and the environment has a T3 Connect route, because Clerk never retries a failed load within the page.

Fixes pingdotgg/t3code#37602

Reproduction on main

Commit dfeaf7b137 (origin/main). Host: t3 connect link --headless + t3 serve with a fresh base dir against the T3 Connect test stage (relay tunnel connected). Client: T3CODE_DEV_SEED=0 vp run dev with the test-stage VITE Clerk/relay env, driven by Playwright Chromium with a persistent profile. 1) Paired, signed in to T3 Connect as test user 1 in Settings > Connections, added the host's environment: 'T3 Connect · Connected'. 2) Closed the browser and relaunched it with requests to the Clerk/accounts.dev and relay hosts aborted (name-not-resolved), opened Settings > Connections: after 30s the environment showed 'This device is still loading its T3 Connect sign-in · attempt 5' and the sidebar showed 'Retry T3 Connect' (Clerk status error). 3) Unblocked the network (navigator.onLine true): 70s later still session_pending, 'attempt 7', growing backoff. 4) Opened Details, clicked 'Retry now' twice 15s apart: attempts reset but still 'Cause session_pending / Error Waiting for the T3 Connect sign-in to load.', 'This device: Failed', 'What to try: Wait a moment. T3 Code retries on its own.' 5) Reloaded the page: environment immediately 'T3 Connect · Connected'. The reporter's earlier 'This device is offline' variant (navigator.onLine false at launch) was not separately reproduced.

Evidence

Pair and sign in with fresh client state; confirm the saved relay environment connects. Restart Chromium with Clerk and relay requests blocked. After 30 seconds, restore requests, wait 70 seconds, then open Details and press Retry. Observe for 15 seconds and repeat Retry if still disconnected. Base stays session_pending after both retries; head connects after its first Retry.

BeforeAfter
dfeaf7b137b451625b57
Before: still waiting for sign-in after retriesAfter: Connected after Retry
Before recordingAfter recording

Scenario file. Both sides were inspected before upload. Head evidence redacts an unrelated environment name.

Not shown:

  • The actual macOS reboot/Electron startup and navigator.onLine=false variant were not exercised; this proves the supplied web session_pending reproduction.
  • Automatic recovery without Retry was not demonstrated: head still waited on sign-in after 70 seconds of restored network access; its first Retry recovered by reloading the page.
  • The composer Retry/Reconnect entry points were not exercised; this proof drives Settings > Connections > Details > Retry now.

Tests

No new commands this round. CI on b451625: all 39 checks passed, including the 8 required ones. From the previous round: vp run check:changed passed, and the Playwright before/after showed Retry now reloading and recovering Clerk only with the fix.

Not in this change

  • Automatic recovery when the network returns (for example reloading on the 'online' event while Clerk is in error): not done because it would reload the window without the user asking, which PR #36769 also chose to avoid.
  • The session_pending diagnosis still says 'Wait a moment. T3 Code retries on its own.' and the button still says 'Retry now'. Changing this copy or adding a separate sign_in_failed state (as in PR #36769) is a visible change outside this fix.
  • Launching fully offline can make Clerk load signed out rather than fail (noted in #36769 as #17917/#24642). Not addressed.
  • Bulk retry in updateEverythingRun still calls environmentCatalog.retryNow directly and does not reload.
  • Automatic recovery when the network returns (reloading without user action): not done.
  • The session_pending copy 'T3 Code retries on its own' and the 'Retry now' label are unchanged.
  • Launching fully offline can make Clerk load signed out rather than fail (#17917/#24642). Not addressed.
  • Bulk retry in updateEverythingRun still calls environmentCatalog.retryNow and does not reload.

Who did the work

  • Written by Claude Opus 5.5, in Claude Code
  • Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
  • Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5

Run by the t3code factory in T3 Code.

    1. tanstack-source added labelsbug

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. Approvability

      Verdict: Needs Human Approval

      Macroscope's review found this PR requires human approval — Retry now reloads the page for relay environments when Clerk has failed to load. The new line-level lint suppression requires human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      The change tracks the mounted Clerk instance and adds a shared retry check for relay connections. Composer reconnect and saved-environment diagnosis handlers use that check before falling back to their existing environment retry behavior.

      Changes: Relay environment retry

      Layer / File(s)Summary
      Track Clerk and expose relay retry
      apps/web/src/cloud/managedAuth.tsx, apps/web/src/components/clerk/clerkLoadFailure.ts
      The managed auth provider tracks its mounted Clerk instance. The shared helper reloads the page when Clerk is in an error state and the connection entry has a relay route.
      Use Clerk retry in environment handlers
      apps/web/src/components/chat/useSystemComposerBanners.tsx, apps/web/src/components/settings/SavedEnvironmentRows.tsx
      Composer reconnect and saved-environment diagnosis handlers call the shared helper before their existing environment retry paths. The composer enables an environment if its entry is explicitly disabled.

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

      Change: Bug fix · Severity of issue fixed: Medium

      Possibly related PRs

      • pingdotgg/t3code#23620: It adds Clerk load-failure and retry helpers for the same cached script-load error state.

      Suggested reviewers: t3dotgg, jacksondr5, macroscopeapp

      Merge Risk: Minimal · up to b4516

      This adds a user-triggered page reload to the retry actions when Clerk fails to load for a T3 Connect environment. Other environments keep their existing retry behavior. No merge-blocking risk was found.

      Pre-merge checks: Passed 3 · Inconclusive 1

      Failed Failed checks: 1 inconclusive
      Check nameStatusExplanationResolution
      Linked Issues checkInconclusiveLinked issue #37602 has two parts. Its title and the PR's tested case match: a T3 Connect environment stays in session_pending after Clerk fails to load. The PR adds a Retry path. When Clerk status is…Provide evidence for one of the following: (a) a signed-in run where the reload path reaches 'T3 Connect · Connected' after Clerk recovers; or (b) confirmation that the issue's 'This device is offline' variant is out of scope for this PR, w…
      Passed Passed checks: 3 passed

      Check nameStatusExplanation
      Title checkPassedThe title says a retry recovers a T3 Connect environment after Clerk failed to load. The changeset adds trackMountedClerk and retryClerkLoadForEnvironment, and wires the Settings 'Retry now' and compo…
      Out of Scope Changes checkPassedAll changed files relate to the Clerk load retry path described in the PR and in #37602. managedAuth.tsx adds trackMountedClerk for the mounted Clerk instance. clerkLoadFailure.ts adds trackMountedCle…
      Description checkPassedThe description is detailed and covers the problem, the change, scope, and verification. It cites the linked issue #37602 and a reproduction on main with before/after evidence. It has a clear problem …
      Full details: Title check

      Explanation

      The title says a retry recovers a T3 Connect environment after Clerk failed to load. The changeset adds trackMountedClerk and retryClerkLoadForEnvironment, and wires the Settings 'Retry now' and composer banner retry to reload the page when Clerk is in error state and the environment has a T3 Connect relay route. The title names the main change and the type of fix, and follows the conventional commit format from the template. It is specific and concise.

      Full details: Out of Scope Changes check

      Explanation

      All changed files relate to the Clerk load retry path described in the PR and in #37602. managedAuth.tsx adds trackMountedClerk for the mounted Clerk instance. clerkLoadFailure.ts adds trackMountedClerk and retryClerkLoadForEnvironment. SavedEnvironmentRows.tsx and useSystemComposerBanners.tsx call the new retry first and fall back to the existing environmentCatalog.retryNow. The enabled-state handling in useSystemComposerBanners is part of the same retry flow. No unrelated refactoring, copy, label, or automatic reload change is in the summary. The PR states that bulk retry in updateEverythingRun is unchanged.

      Full details: Description check

      Explanation

      The description is detailed and covers the problem, the change, scope, and verification. It cites the linked issue #37602 and a reproduction on main with before/after evidence. It has a clear problem statement and change explanation. However, the Problem section is not labeled as such and the Change section is folded into the author's intro rather than the template headings. Also, the Scope section does not explain why this is a bug fix rather than a feature, and the 'Not in this change' section repeats two bullets verbatim. The description also includes non-template material (review bot commentary, approvability verdict, agent attribution) that does not follow the template structure. Most required information is present, so the check passes.

      Full details: Linked Issues check

      Explanation

      Linked issue #37602 has two parts. Its title and the PR's tested case match: a T3 Connect environment stays in session_pending after Clerk fails to load. The PR adds a Retry path. When Clerk status is 'error' and the environment has a T3 Connect route, 'Retry now' and the composer Retry/Reconnect call retryClerkLoadForEnvironment, which reloads the window (clerkLoadFailure.ts, SavedEnvironmentRows.tsx, useSystemComposerBanners.tsx, managedAuth.tsx). The PR reports a before/after Playwright run: before, no reload and still session_pending; after, a reload and Clerk loaded. The issue body describes a different state: the 'This device is offline' banner, caused by a supervisor offline phase or navigator.onLine false at launch. The PR does not address that state. When Clerk is not in error, Reconnect still calls environmentCatalog.retryNow unchanged. The PR states that launching fully offline is not addressed. The issue expects the remote environment to connect once the network is up, or when Reconnect is pressed. The PR's validation used a signed-out profile and did not show a 'Connected' state after reload. Whether the offline-banner variant is in scope, and whether the reload path yields a connected environment for a signed-in user, is not established by the evidence.

      Resolution

      Provide evidence for one of the following: (a) a signed-in run where the reload path reaches 'T3 Connect · Connected' after Clerk recovers; or (b) confirmation that the issue's 'This device is offline' variant is out of scope for this PR, with a separate tracking reference. Confirming the cause of the offline variant (navigator.onLine at launch, supervisor offline phase) would also resolve the uncertainty. Also state whether the Reconnect behavior for that variant is expected to change in this PR.

      Finishing Touches

      Generate unit tests (beta)

      • Commit to this branch
      • 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 760f9cbe64e3409a7ebcc1ec16debe31a61e9f2b and b451625b57c6be9d0ab5ec0e1dc4842918a63cf7.

      Files selected for processing: 4

      • apps/web/src/cloud/managedAuth.tsx
      • apps/web/src/components/chat/useSystemComposerBanners.tsx
      • apps/web/src/components/clerk/clerkLoadFailure.ts
      • apps/web/src/components/settings/SavedEnvironmentRows.tsx

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

Sign in to join this conversation.