Skip to content

Commit bcdbb3b

Browse files
t3dotggclaude
andcommitted
fix(web): T3 Connect toggle opens sign-in when signed out
The T3 Connect switches in Settings > Connections were disabled when signed out, with the only hint in a tooltip on the disabled control. Keep them enabled and open the T3 Connect sign-in prompt instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 453bf01 commit bcdbb3b

1 file changed

Lines changed: 38 additions & 34 deletions

File tree

‎apps/web/src/components/settings/SavedEnvironmentRows.tsx‎

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import {
6565
ServerUpdateProgress,
6666
} from "../ServerUpdateAction";
6767
import { CloudEnvironmentConnectRows } from "../cloud/CloudEnvironmentConnectList";
68+
import { useT3ConnectAuthPrompt } from "../clerk/useT3ConnectAuthPrompt";
6869

6970
type SavedBackendListRowProps = {
7071
environment: EnvironmentPresentation;
@@ -476,15 +477,22 @@ function ConfiguredCloudLinkRow({ canManageRelay }: { readonly canManageRelay: b
476477
operationError,
477478
reconcileCloudState,
478479
} = useCloudLinkController();
480+
const { openAuthPrompt } = useT3ConnectAuthPrompt();
479481
const [isUpdating, setIsUpdating] = useState(false);
480482
const [isUpdatingPreference, setIsUpdatingPreference] = useState(false);
481483

482-
const disabledReason = !isSignedIn
483-
? "Sign in to T3 Connect to manage this environment."
484-
: !canManageRelay
485-
? "Your session does not have permission to manage T3 Connect access."
486-
: null;
484+
const disabledReason = canManageRelay
485+
? null
486+
: "Your session does not have permission to manage T3 Connect access.";
487487
const isBusy = isUpdating || isUpdatingPreference;
488+
// Signed out, the switches stay clickable and open sign-in. A fresh sign-in
489+
// opens ConnectOnboardingDialog, which offers to link this environment.
490+
// `isSignedIn` is undefined until Clerk loads.
491+
const switchDisabled =
492+
!canManageRelay ||
493+
isSignedIn === undefined ||
494+
(isSignedIn && (primaryCloudLinkState.data === null || primaryCloudLinkState.isPending)) ||
495+
isBusy;
488496
const refreshLinkState = useEffectEvent(primaryCloudLinkState.refresh);
489497
// The server rechecks reachability when the tunnel's 30 s readiness poll changes.
490498
// Poll while mounted, so a failed read does not stop later ones.
@@ -583,31 +591,29 @@ function ConfiguredCloudLinkRow({ canManageRelay }: { readonly canManageRelay: b
583591
<SettingsRow
584592
title={searchableSetting("t3-connect").title}
585593
description={
586-
linkRevoked
587-
? "This environment was removed from T3 Connect. Turn it on to link it again."
588-
: managedTunnelActive
589-
? reachability?.status === "unreachable"
590-
? "T3 Connect is on, but other devices cannot reach this environment."
591-
: reachability?.status === "reachable"
592-
? "This environment is available to your other devices through T3 Connect."
593-
: "T3 Connect is on. Reachability has not been checked yet."
594-
: managedTunnelOutOfSync
595-
? "T3 Connect is out of sync. This environment is linked only to publish agent activity, so other devices cannot connect. Turn T3 Connect on to repair it."
596-
: "Make this environment available to your other devices through T3 Connect."
594+
isSignedIn === false
595+
? "Sign in to make this environment available to your other devices through T3 Connect."
596+
: linkRevoked
597+
? "This environment was removed from T3 Connect. Turn it on to link it again."
598+
: managedTunnelActive
599+
? reachability?.status === "unreachable"
600+
? "T3 Connect is on, but other devices cannot reach this environment."
601+
: reachability?.status === "reachable"
602+
? "This environment is available to your other devices through T3 Connect."
603+
: "T3 Connect is on. Reachability has not been checked yet."
604+
: managedTunnelOutOfSync
605+
? "T3 Connect is out of sync. This environment is linked only to publish agent activity, so other devices cannot connect. Turn T3 Connect on to repair it."
606+
: "Make this environment available to your other devices through T3 Connect."
597607
}
598608
status={operationError ?? primaryCloudLinkState.error ?? reachabilityStatus}
599609
control={
600610
<CloudLinkSwitch
601611
checked={managedTunnelActive}
602-
disabled={
603-
!canManageRelay ||
604-
!isSignedIn ||
605-
primaryCloudLinkState.data === null ||
606-
primaryCloudLinkState.isPending ||
607-
isBusy
608-
}
612+
disabled={switchDisabled}
609613
disabledReason={disabledReason}
610-
onCheckedChange={(enabled) => void updateManagedTunnel(enabled)}
614+
onCheckedChange={(enabled) =>
615+
isSignedIn ? void updateManagedTunnel(enabled) : openAuthPrompt()
616+
}
611617
/>
612618
}
613619
/>
@@ -624,15 +630,11 @@ function ConfiguredCloudLinkRow({ canManageRelay }: { readonly canManageRelay: b
624630
<CloudLinkSwitch
625631
ariaLabel="Publish agent activity to mobile clients"
626632
checked={publishAgentActivity}
627-
disabled={
628-
!canManageRelay ||
629-
!isSignedIn ||
630-
primaryCloudLinkState.data === null ||
631-
primaryCloudLinkState.isPending ||
632-
isBusy
633-
}
633+
disabled={switchDisabled}
634634
disabledReason={disabledReason}
635-
onCheckedChange={(enabled) => void updatePublishAgentActivity(enabled)}
635+
onCheckedChange={(enabled) =>
636+
isSignedIn ? void updatePublishAgentActivity(enabled) : openAuthPrompt()
637+
}
636638
/>
637639
}
638640
/>
@@ -644,9 +646,11 @@ function ConfiguredCloudLinkRow({ canManageRelay }: { readonly canManageRelay: b
644646
<CloudLinkSwitch
645647
ariaLabel="Hold webhook requests while this environment is offline"
646648
checked={holdWebhooksWhileOffline}
647-
disabled={!canManageRelay || !isSignedIn || primaryCloudLinkState.isPending || isBusy}
649+
disabled={switchDisabled}
648650
disabledReason={disabledReason}
649-
onCheckedChange={(enabled) => void updateHoldWebhooks(enabled)}
651+
onCheckedChange={(enabled) =>
652+
isSignedIn ? void updateHoldWebhooks(enabled) : openAuthPrompt()
653+
}
650654
/>
651655
}
652656
/>

0 commit comments

Comments
 (0)