Repository navigation
fix(web): refresh T3 Connect switch after startup reconcile - #7193
maslinedwin wants to merge 4 commits into
Conversation
Startup reconcile applies relay config after routes are live. The first link-state read can cache managedTunnelActive: false, and the Settings switch stayed off because nothing invalidated that SWR atom. Refresh once after the first settled read, and again when Connections opens. Fixes pingdotgg#6628
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Needs human review This bug fix introduces new timer-based refresh logic, retry mechanisms, and state synchronization behavior that gates whether managed tunnels are preserved or torn down. The complexity of the timing-sensitive changes and new business logic around reconciliation warrants human review. You can customize Macroscope's approvability policy. Learn more. |
A single 2s refresh could still miss a slow startup reconcile, and the one-shot key then blocked later retries. Refresh at 2s/5s/10s and again while Connections is open, then stop. Onboarding now resyncs untouched toggles from later link-state reads and never submits managedTunnel:false against an already-active tunnel.
There was a problem hiding this comment.
One finding: the new Connections poll makes both cloud switches flicker into their disabled state every 2s. Details inline.
Posted via Macroscope — UI Consistency
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4253c5a. Configure here.
Both-off still means skip, even if a later refresh showed the tunnel active, so onboarding does not rewrite publish. Connections retries only while a linked tunnel still looks inactive.
After an account switch, do not treat the previous user's cached managedTunnelActive as this wizard's tunnel. Disable the Connections switches only on the first link-state load so SWR revalidation no longer eats clicks.
|
Note 🤖 GPT-5.6 Sol responding on behalf of Theo We're closing this PR as we clean up the T3 Code backlog. Thank you for taking the time to put this together. The fixed 2, 5, and 10 second retries can still leave the switch stale when T3 Connect starts more slowly. We do not want to ship a timing-based repair that still has the same failure mode. If you believe we closed this in error, please reopen the PR and leave a comment explaining what we missed. |

Problem
Startup reconciliation applies T3 Connect relay config after routes are already live. Settings reads
managedTunnelActivefromuseCloudLinkController→ a shared SWR atom (staleTime: 5s). If the first read lands beforeapplyRelayConfig, the atom cachesmanagedTunnelActive: falseand nothing invalidates it when the background reconcile finishes. The switch stays off even though the tunnel is up. Toggling later refreshes via the mutation path.The always-mounted T3 Connect onboarding dialog keeps this atom subscribed from app start, so
revalidateOnMountnever runs again.Fix
Display refresh only — no auto-link, no protocol change, and the
managedTunnelActive ?? linkedfallback for older servers is unchanged.Tests
apps/web/src/cloud/primaryCloudLinkState.test.ts— stale inactive snapshot becomes active after the follow-up refresh; one-shot per target; no schedule without a targetlinkEnvironment.test.tsstill passes (read/reconcile mapping unchanged)Fixes #6628
Model: grok-4
Harness: T3 Code
Note
Medium Risk
Changes T3 Connect reconcile and toggle sync paths in onboarding and Connections; display-only refresh logic but incorrect reconcile could affect tunnel/publish state if helpers are wrong.
Overview
Fixes stale
managedTunnelActive: falsein the shared cloud link SWR cache when startup reconcile finishes after the first read, so the T3 Connect switch and onboarding UI can catch up without a manual toggle.Link-state refresh: After the first settled read with an inactive tunnel,
usePrimaryCloudLinkStateschedules bounded follow-up refreshes (2s / 5s / 10s) and cancels them once the tunnel is active. Connections forces a refresh on mount and retries every 2s for up to 15s while linked but still inactive.Derived behavior:
resolveManagedTunnelActivecentralizes themanagedTunnelActive ?? linkedfallback (moved out ofuseCloudLinkController).isInitialCloudLinkStatePendingonly disables switches before the first snapshot, not during background revalidation.Onboarding hardening: Toggles keep syncing from link state until the user touches them; reconcile uses
resolveOnboardingReconcileDesiredso stale prefill cannot tear down an active tunnel or submit publish-only when both toggles are off. Account-scoped helpers avoid applying another account’s cached tunnel state after a switch.Unit tests cover the new helpers and refresh scheduling.
Reviewed by Cursor Bugbot for commit ee96d97. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Refresh T3 Connect switch state after startup reconcile to fix stale inactive tunnel snapshots
usePrimaryCloudLinkStatesettles, link state is refreshed at 2s, 5s, and 10s delays to correct a startup-stalemanagedTunnelActive=falsesnapshot left before reconcile completes.ConnectOnboardingDialog.tsxnow continuously re-syncs toggles from link state until the user manually changes them, scoped to the current account only.isInitialCloudLinkStatePendinghelper.ConnectionsSettingsnow also starts a periodic retry loop on mount to refresh link state while a linked tunnel appears inactive, stopping when the tunnel becomes active or a time budget elapses.Macroscope summarized ee96d97.