Skip to content

Commit 6548c00

Browse files
t3dotggclaude
andauthored
fix(web): signed-out T3 Connect shows a Sign in button (pingdotgg#24636)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 453bf01 commit 6548c00

1 file changed

Lines changed: 70 additions & 50 deletions

File tree

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

Lines changed: 70 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import {
4848
supportsServerUpdateThreadContinuation,
4949
} from "~/versionSkew";
5050
import { hasCloudPublicConfig } from "~/cloud/publicConfig";
51+
import { isElectron } from "~/env";
5152
import { useCloudLinkController } from "~/cloud/useCloudLinkController";
5253
import { environmentCatalog } from "~/connection/catalog";
5354
import { readEnvironmentScope } from "~/state/session";
@@ -65,6 +66,7 @@ import {
6566
ServerUpdateProgress,
6667
} from "../ServerUpdateAction";
6768
import { CloudEnvironmentConnectRows } from "../cloud/CloudEnvironmentConnectList";
69+
import { useT3ConnectAuthPrompt } from "../clerk/useT3ConnectAuthPrompt";
6870

6971
type SavedBackendListRowProps = {
7072
environment: EnvironmentPresentation;
@@ -476,15 +478,29 @@ function ConfiguredCloudLinkRow({ canManageRelay }: { readonly canManageRelay: b
476478
operationError,
477479
reconcileCloudState,
478480
} = useCloudLinkController();
481+
const { openAuthPrompt } = useT3ConnectAuthPrompt();
479482
const [isUpdating, setIsUpdating] = useState(false);
480483
const [isUpdatingPreference, setIsUpdatingPreference] = useState(false);
481484

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;
485+
const disabledReason = canManageRelay
486+
? null
487+
: "Your session does not have permission to manage T3 Connect access.";
487488
const isBusy = isUpdating || isUpdatingPreference;
489+
const switchDisabled =
490+
!canManageRelay ||
491+
!isSignedIn ||
492+
primaryCloudLinkState.data === null ||
493+
primaryCloudLinkState.isPending ||
494+
isBusy;
495+
// `isSignedIn` is undefined until Clerk loads. Signed out, one row shows a
496+
// sign-in button instead of its switch; the onboarding dialog that opens after
497+
// a fresh sign-in offers both linking and publishing.
498+
const signedOut = isSignedIn === false;
499+
const signInButton = (
500+
<Button size="sm" variant="outline" onClick={openAuthPrompt}>
501+
Sign in
502+
</Button>
503+
);
488504
const refreshLinkState = useEffectEvent(primaryCloudLinkState.refresh);
489505
// The server rechecks reachability when the tunnel's 30 s readiness poll changes.
490506
// Poll while mounted, so a failed read does not stop later ones.
@@ -579,36 +595,36 @@ function ConfiguredCloudLinkRow({ canManageRelay }: { readonly canManageRelay: b
579595

580596
return (
581597
<>
582-
{window.desktopBridge ? (
598+
{isElectron ? (
583599
<SettingsRow
584600
title={searchableSetting("t3-connect").title}
585601
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."
602+
signedOut
603+
? "Sign in to make this environment available to your other devices through T3 Connect."
604+
: linkRevoked
605+
? "This environment was removed from T3 Connect. Turn it on to link it again."
606+
: managedTunnelActive
607+
? reachability?.status === "unreachable"
608+
? "T3 Connect is on, but other devices cannot reach this environment."
609+
: reachability?.status === "reachable"
610+
? "This environment is available to your other devices through T3 Connect."
611+
: "T3 Connect is on. Reachability has not been checked yet."
612+
: managedTunnelOutOfSync
613+
? "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."
614+
: "Make this environment available to your other devices through T3 Connect."
597615
}
598616
status={operationError ?? primaryCloudLinkState.error ?? reachabilityStatus}
599617
control={
600-
<CloudLinkSwitch
601-
checked={managedTunnelActive}
602-
disabled={
603-
!canManageRelay ||
604-
!isSignedIn ||
605-
primaryCloudLinkState.data === null ||
606-
primaryCloudLinkState.isPending ||
607-
isBusy
608-
}
609-
disabledReason={disabledReason}
610-
onCheckedChange={(enabled) => void updateManagedTunnel(enabled)}
611-
/>
618+
signedOut ? (
619+
signInButton
620+
) : (
621+
<CloudLinkSwitch
622+
checked={managedTunnelActive}
623+
disabled={switchDisabled}
624+
disabledReason={disabledReason}
625+
onCheckedChange={(enabled) => void updateManagedTunnel(enabled)}
626+
/>
627+
)
612628
}
613629
/>
614630
) : linkRevoked ? (
@@ -617,34 +633,38 @@ function ConfiguredCloudLinkRow({ canManageRelay }: { readonly canManageRelay: b
617633
description="This environment was removed from T3 Connect. Run `t3 connect link` on the host to link it again."
618634
/>
619635
) : null}
620-
<SettingsRow
621-
title={searchableSetting("publish-agent-activity").title}
622-
description="Send activity to mobile notifications and Live Activities without T3 Connect."
623-
control={
624-
<CloudLinkSwitch
625-
ariaLabel="Publish agent activity to mobile clients"
626-
checked={publishAgentActivity}
627-
disabled={
628-
!canManageRelay ||
629-
!isSignedIn ||
630-
primaryCloudLinkState.data === null ||
631-
primaryCloudLinkState.isPending ||
632-
isBusy
633-
}
634-
disabledReason={disabledReason}
635-
onCheckedChange={(enabled) => void updatePublishAgentActivity(enabled)}
636-
/>
637-
}
638-
/>
639-
{managedTunnelActive ? (
636+
{signedOut && isElectron ? null : (
637+
<SettingsRow
638+
title={searchableSetting("publish-agent-activity").title}
639+
description={
640+
signedOut
641+
? "Sign in to send activity to mobile notifications and Live Activities."
642+
: "Send activity to mobile notifications and Live Activities without T3 Connect."
643+
}
644+
control={
645+
signedOut ? (
646+
signInButton
647+
) : (
648+
<CloudLinkSwitch
649+
ariaLabel="Publish agent activity to mobile clients"
650+
checked={publishAgentActivity}
651+
disabled={switchDisabled}
652+
disabledReason={disabledReason}
653+
onCheckedChange={(enabled) => void updatePublishAgentActivity(enabled)}
654+
/>
655+
)
656+
}
657+
/>
658+
)}
659+
{managedTunnelActive && !signedOut ? (
640660
<SettingsRow
641661
title={searchableSetting("hold-webhooks-while-offline").title}
642662
description="Keep webhook requests for up to 24 hours while this environment is offline, then deliver them. Off: T3 Connect only forwards requests and stores nothing."
643663
control={
644664
<CloudLinkSwitch
645665
ariaLabel="Hold webhook requests while this environment is offline"
646666
checked={holdWebhooksWhileOffline}
647-
disabled={!canManageRelay || !isSignedIn || primaryCloudLinkState.isPending || isBusy}
667+
disabled={switchDisabled}
648668
disabledReason={disabledReason}
649669
onCheckedChange={(enabled) => void updateHoldWebhooks(enabled)}
650670
/>

0 commit comments

Comments
 (0)