fix(web): refresh T3 Connect switch after startup reconcile #7193
Closedmaslinedwin(GitHub profile, opens in a new tab)wants to merge 4 commits into
main fromrefs/pull/7193/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/web/src/cloud/primaryCloudLinkState.ts line 78OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -50,0 +58,21 @@58+59+// Startup reconcile applies relay config after routes are already live. The60+// first link-state read can cache `managedTunnelActive: false`; one delayed61+// refresh replaces that once reconcile has had a chance to finish.62+export const STARTUP_CLOUD_LINK_RECONCILE_REFRESH_MS = 2_000;63+64+const scheduledStartupReconcileRefreshKeys = new Set<string>();65+66+export function scheduleStartupReconcileLinkStateRefresh(67+ target: CloudLinkTarget | null,68+ refresh: (target: CloudLinkTarget | null) => void = refreshPrimaryCloudLinkState,69+): boolean {70+ if (!target) {71+ return false;72+ }73+ const key = targetKey(target);74+ if (scheduledStartupReconcileRefreshKeys.has(key)) {75+ return false;76+ }77+ scheduledStartupReconcileRefreshKeys.add(key);78+ setTimeout(() => {
- apps/web/src/cloud/primaryCloudLinkState.ts line 115OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -69,3 +106,10 @@69106 const refresh = useCallback(() => {70107 refreshPrimaryCloudLinkState(target);71108 }, [target]);109+ const settled = result._tag === "Success" || result._tag === "Failure";110+ useEffect(() => {111+ if (!settled) {112+ return;113+ }114+ scheduleStartupReconcileLinkStateRefresh(target);115+ }, [settled, target]);
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/web/src/components/cloud/ConnectOnboardingDialog.tsx lines 211 to 211OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -186,5 +203,9 @@186203187204 const applyPublishSelection = async () => {188205 // The wizard only ever enables — with both toggles off there is nothing to189- // apply, and an existing link must not be torn down from onboarding.190- if (!exposeEnvironment && !publishAgentActivity) {206+ // apply, and an existing managed tunnel must not be torn down from207+ // onboarding if a later link-state refresh showed it active.208+ const desired = resolveOnboardingReconcileDesired({209+ exposeEnvironment,210+ publishAgentActivity,211+ managedTunnelActive: controller.managedTunnelActive,
- apps/web/src/components/settings/ConnectionsSettings.tsx lines 1610 to 1629OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1602,0 +1609,21 @@1609+ // on open, then retry on a short budget while this page stays mounted.1610+ useEffect(() => {1611+ primaryCloudLinkState.refresh();1612+ }, [primaryCloudLinkState.refresh]);1613+ useEffect(() => {1614+ if (managedTunnelActive) {1615+ return;1616+ }1617+ const startedAt = Date.now();1618+ const intervalId = window.setInterval(() => {1619+ const elapsedMs = Date.now() - startedAt;1620+ if (!shouldContinueConnectionsCloudLinkRetry(elapsedMs, managedTunnelActive)) {1621+ window.clearInterval(intervalId);1622+ return;1623+ }1624+ primaryCloudLinkState.refresh();1625+ }, CONNECTIONS_CLOUD_LINK_RETRY_INTERVAL_MS);1626+ return () => {1627+ window.clearInterval(intervalId);1628+ };1629+ }, [managedTunnelActive, primaryCloudLinkState.refresh]);
- apps/web/src/cloud/connectOnboarding.ts line 60Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -18,0 +27,21 @@27+ !input.touched &&28+ input.openForAccount !== null &&29+ input.linked &&30+ input.cloudUserId === input.openForAccount31+ );32+}33+34+// The wizard only ever enables. A stale prefill of expose=false after35+// startup reconcile must not submit publish_only and tear the tunnel down.36+export function resolveOnboardingReconcileDesired(input: {37+ readonly exposeEnvironment: boolean;38+ readonly publishAgentActivity: boolean;39+ readonly managedTunnelActive: boolean;40+}): { readonly managedTunnel: boolean; readonly publish: boolean } | null {41+ const managedTunnel = input.exposeEnvironment || input.managedTunnelActive;42+ const publish = input.publishAgentActivity;43+ if (!managedTunnel && !publish) {44+ return null;45+ }46+ return { managedTunnel, publish };47+}
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
053ad919-d848-4fc0-87a2-6aa33c81a8c6You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.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.
❤️ Share