Skip to content
TypeScript

fix(web): signed-out T3 Connect shows a Sign in button (#24636)

Theo Browne6548c006d429
diff --git a/apps/web/src/components/settings/SavedEnvironmentRows.tsx b/apps/web/src/components/settings/SavedEnvironmentRows.tsx
index dbb7c3b9482..5a331193bca 100644
--- a/apps/web/src/components/settings/SavedEnvironmentRows.tsx
+++ b/apps/web/src/components/settings/SavedEnvironmentRows.tsx
@@ -48,6 +48,7 @@ import {
supportsServerUpdateThreadContinuation,
} from "~/versionSkew";
import { hasCloudPublicConfig } from "~/cloud/publicConfig";
+import { isElectron } from "~/env";
import { useCloudLinkController } from "~/cloud/useCloudLinkController";
import { environmentCatalog } from "~/connection/catalog";
import { readEnvironmentScope } from "~/state/session";
@@ -65,6 +66,7 @@ import {
ServerUpdateProgress,
} from "../ServerUpdateAction";
import { CloudEnvironmentConnectRows } from "../cloud/CloudEnvironmentConnectList";
+import { useT3ConnectAuthPrompt } from "../clerk/useT3ConnectAuthPrompt";
type SavedBackendListRowProps = {
environment: EnvironmentPresentation;
@@ -476,15 +478,29 @@ function ConfiguredCloudLinkRow({ canManageRelay }: { readonly canManageRelay: b
operationError,
reconcileCloudState,
} = useCloudLinkController();
+ const { openAuthPrompt } = useT3ConnectAuthPrompt();
const [isUpdating, setIsUpdating] = useState(false);
const [isUpdatingPreference, setIsUpdatingPreference] = useState(false);
- const disabledReason = !isSignedIn
- ? "Sign in to T3 Connect to manage this environment."
- : !canManageRelay
- ? "Your session does not have permission to manage T3 Connect access."
- : null;
+ const disabledReason = canManageRelay
+ ? null
+ : "Your session does not have permission to manage T3 Connect access.";
const isBusy = isUpdating || isUpdatingPreference;
+ const switchDisabled =
+ !canManageRelay ||
+ !isSignedIn ||
+ primaryCloudLinkState.data === null ||
+ primaryCloudLinkState.isPending ||
+ isBusy;
+ // `isSignedIn` is undefined until Clerk loads. Signed out, one row shows a
+ // sign-in button instead of its switch; the onboarding dialog that opens after
+ // a fresh sign-in offers both linking and publishing.
+ const signedOut = isSignedIn === false;
+ const signInButton = (
+ <Button size="sm" variant="outline" onClick={openAuthPrompt}>
+ Sign in
+ </Button>
+ );
const refreshLinkState = useEffectEvent(primaryCloudLinkState.refresh);
// The server rechecks reachability when the tunnel's 30 s readiness poll changes.
// Poll while mounted, so a failed read does not stop later ones.
@@ -579,36 +595,36 @@ function ConfiguredCloudLinkRow({ canManageRelay }: { readonly canManageRelay: b
return (
<>
- {window.desktopBridge ? (
+ {isElectron ? (
<SettingsRow
title={searchableSetting("t3-connect").title}
description={
- linkRevoked
- ? "This environment was removed from T3 Connect. Turn it on to link it again."
- : managedTunnelActive
- ? reachability?.status === "unreachable"
- ? "T3 Connect is on, but other devices cannot reach this environment."
- : reachability?.status === "reachable"
- ? "This environment is available to your other devices through T3 Connect."
- : "T3 Connect is on. Reachability has not been checked yet."
- : managedTunnelOutOfSync
- ? "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."
- : "Make this environment available to your other devices through T3 Connect."
+ signedOut
+ ? "Sign in to make this environment available to your other devices through T3 Connect."
+ : linkRevoked
+ ? "This environment was removed from T3 Connect. Turn it on to link it again."
+ : managedTunnelActive
+ ? reachability?.status === "unreachable"
+ ? "T3 Connect is on, but other devices cannot reach this environment."
+ : reachability?.status === "reachable"
+ ? "This environment is available to your other devices through T3 Connect."
+ : "T3 Connect is on. Reachability has not been checked yet."
+ : managedTunnelOutOfSync
+ ? "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."
+ : "Make this environment available to your other devices through T3 Connect."
}
status={operationError ?? primaryCloudLinkState.error ?? reachabilityStatus}
control={
- <CloudLinkSwitch
- checked={managedTunnelActive}
- disabled={
- !canManageRelay ||
- !isSignedIn ||
- primaryCloudLinkState.data === null ||
- primaryCloudLinkState.isPending ||
- isBusy
- }
- disabledReason={disabledReason}
- onCheckedChange={(enabled) => void updateManagedTunnel(enabled)}
- />
+ signedOut ? (
+ signInButton
+ ) : (
+ <CloudLinkSwitch
+ checked={managedTunnelActive}
+ disabled={switchDisabled}
+ disabledReason={disabledReason}
+ onCheckedChange={(enabled) => void updateManagedTunnel(enabled)}
+ />
+ )
}
/>
) : linkRevoked ? (
@@ -617,26 +633,30 @@ function ConfiguredCloudLinkRow({ canManageRelay }: { readonly canManageRelay: b
description="This environment was removed from T3 Connect. Run `t3 connect link` on the host to link it again."
/>
) : null}
- <SettingsRow
- title={searchableSetting("publish-agent-activity").title}
- description="Send activity to mobile notifications and Live Activities without T3 Connect."
- control={
- <CloudLinkSwitch
- ariaLabel="Publish agent activity to mobile clients"
- checked={publishAgentActivity}
- disabled={
- !canManageRelay ||
- !isSignedIn ||
- primaryCloudLinkState.data === null ||
- primaryCloudLinkState.isPending ||
- isBusy
- }
- disabledReason={disabledReason}
- onCheckedChange={(enabled) => void updatePublishAgentActivity(enabled)}
- />
- }
- />
- {managedTunnelActive ? (
+ {signedOut && isElectron ? null : (
+ <SettingsRow
+ title={searchableSetting("publish-agent-activity").title}
+ description={
+ signedOut
+ ? "Sign in to send activity to mobile notifications and Live Activities."
+ : "Send activity to mobile notifications and Live Activities without T3 Connect."
+ }
+ control={
+ signedOut ? (
+ signInButton
+ ) : (
+ <CloudLinkSwitch
+ ariaLabel="Publish agent activity to mobile clients"
+ checked={publishAgentActivity}
+ disabled={switchDisabled}
+ disabledReason={disabledReason}
+ onCheckedChange={(enabled) => void updatePublishAgentActivity(enabled)}
+ />
+ )
+ }
+ />
+ )}
+ {managedTunnelActive && !signedOut ? (
<SettingsRow
title={searchableSetting("hold-webhooks-while-offline").title}
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."
@@ -644,7 +664,7 @@ function ConfiguredCloudLinkRow({ canManageRelay }: { readonly canManageRelay: b
<CloudLinkSwitch
ariaLabel="Hold webhook requests while this environment is offline"
checked={holdWebhooksWhileOffline}
- disabled={!canManageRelay || !isSignedIn || primaryCloudLinkState.isPending || isBusy}
+ disabled={switchDisabled}
disabledReason={disabledReason}
onCheckedChange={(enabled) => void updateHoldWebhooks(enabled)}
/>