Skip to content

Commit b8de014

Browse files
fix(connect): keep the approval switch with the other T3 Connect settings
The "Require approval for new devices" switch now sits under "Hold webhooks while offline" in the T3 Connect rows. The T3 Connect devices section only appears when there are waiting requests or trusted devices. The phone's approval prompt no longer styles Deny as destructive, which showed a trash icon on Android. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent bf0583f commit b8de014

5 files changed

Lines changed: 54 additions & 30 deletions

File tree

‎apps/mobile/src/features/connection/ConnectDeviceApprovalCoordinator.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ function EnvironmentApprovalWatcher(props: {
5757
Dialog.alert(prompt.title, prompt.message, [
5858
{
5959
text: "Deny",
60-
style: "destructive",
6160
onPress: () =>
6261
void deny({ environmentId: props.environmentId, input: { id: prompt.pairingLinkId } }),
6362
},

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

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,13 @@ import * as DateTime from "effect/DateTime";
77
import { useState } from "react";
88

99
import type { ServerPairingLinkRecord } from "~/environments/primary";
10-
import { useUpdateEnvironmentSettings } from "~/hooks/useSettings";
1110
import { authEnvironment } from "~/state/auth";
1211
import { useAtomCommand } from "~/state/use-atom-command";
1312
import { Button } from "../ui/button";
14-
import { Switch } from "../ui/switch";
1513
import { stackedThreadToast, toastManager } from "../ui/toast";
1614
import { describeConnectDeviceClient, formatAccessTimestamp } from "./ConnectionsSettings.logic";
1715
import { ITEM_ROW_CLASSNAME, ITEM_ROW_INNER_CLASSNAME } from "./itemRows";
18-
import { SettingsRow, SettingsSection } from "./settingsLayout";
19-
import { searchableSetting } from "./settingsSearch";
16+
import { SettingsSection } from "./settingsLayout";
2017

2118
function reportFailure(title: string, result: Parameters<typeof isAtomCommandInterrupted>[0]) {
2219
if (result._tag !== "Failure" || isAtomCommandInterrupted(result)) return;
@@ -32,23 +29,19 @@ function reportFailure(title: string, result: Parameters<typeof isAtomCommandInt
3229

3330
export function ConnectDeviceApprovalSettings({
3431
environmentId,
35-
requireApproval,
3632
requests,
3733
devices,
3834
canWrite,
3935
}: {
4036
readonly environmentId: EnvironmentId;
41-
readonly requireApproval: boolean;
4237
readonly requests: ReadonlyArray<ServerPairingLinkRecord>;
4338
readonly devices: ReadonlyArray<AuthConnectDevice>;
4439
readonly canWrite: boolean;
4540
}) {
46-
const updateSettings = useUpdateEnvironmentSettings(environmentId);
4741
const approve = useAtomCommand(authEnvironment.approveConnectDevice, { reportFailure: false });
4842
const deny = useAtomCommand(authEnvironment.revokePairingLink, { reportFailure: false });
4943
const revoke = useAtomCommand(authEnvironment.revokeConnectDevice, { reportFailure: false });
5044
const [busyId, setBusyId] = useState<string | null>(null);
51-
const setting = searchableSetting("connect-device-approval");
5245

5346
const run = async (id: string, action: () => Promise<void>) => {
5447
setBusyId(id);
@@ -57,21 +50,7 @@ export function ConnectDeviceApprovalSettings({
5750
};
5851

5952
return (
60-
<SettingsSection id={setting.id} title="T3 Connect devices">
61-
<SettingsRow
62-
title={setting.title}
63-
description="Devices that sign in to your T3 Connect account wait until someone already connected here approves them."
64-
control={
65-
<Switch
66-
aria-label={setting.title}
67-
checked={requireApproval}
68-
disabled={!canWrite}
69-
onCheckedChange={(enabled) =>
70-
updateSettings({ requireConnectDeviceApproval: Boolean(enabled) })
71-
}
72-
/>
73-
}
74-
/>
53+
<SettingsSection id="connect-devices" title="T3 Connect devices">
7554
{requests.map((request) => {
7655
const connectRequest = request.connectDeviceRequest;
7756
if (!connectRequest) return null;

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,14 @@ function ConnectionsSettingsContent({
12531253
environmentId={accessEnvironmentId}
12541254
canReadRelay={canReadRelay}
12551255
canManageRelay={canManageRelay}
1256+
connectDeviceApproval={
1257+
accessServerConfig?.settings.requireConnectDeviceApproval === undefined
1258+
? null
1259+
: {
1260+
required: accessServerConfig.settings.requireConnectDeviceApproval,
1261+
canManage: canWriteAccess,
1262+
}
1263+
}
12561264
/>
12571265
) : null}
12581266
{accessEnvironment ? (
@@ -1320,15 +1328,11 @@ function ConnectionsSettingsContent({
13201328
</ScrollArea>
13211329
</FoldedSettingsSection>
13221330
) : null}
1323-
{/* A host linked from its CLI is still managed from clients without T3 Connect. */}
13241331
{canReadAccess &&
13251332
connectDevices !== null &&
1326-
(hasCloudPublicConfig() ||
1327-
accessServerConfig?.settings.requireConnectDeviceApproval === true ||
1328-
connectDevices.length > 0) ? (
1333+
(connectDeviceRequests.length > 0 || connectDevices.length > 0) ? (
13291334
<ConnectDeviceApprovalSettings
13301335
environmentId={accessEnvironmentId}
1331-
requireApproval={accessServerConfig?.settings.requireConnectDeviceApproval ?? false}
13321336
requests={connectDeviceRequests}
13331337
devices={connectDevices}
13341338
canWrite={canWriteAccess}

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

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import { type EnvironmentPresentation, useRelayEnvironmentDiscovery } from "~/st
6060
import { APP_VERSION } from "~/branding";
6161
import { useManagedPolicy } from "~/state/managedPolicy";
6262
import { useAtomCommand } from "../../state/use-atom-command";
63+
import { useUpdateEnvironmentSettings } from "~/hooks/useSettings";
6364
import { serverEnvironment } from "~/state/server";
6465
import {
6566
OutdatedServerUpdateAction,
@@ -525,10 +526,13 @@ function T3ConnectTunnelUsage({ tunnelLimit }: { readonly tunnelLimit: number |
525526
function ConfiguredCloudLinkRow({
526527
environmentId,
527528
canManageRelay,
529+
connectDeviceApproval,
528530
}: {
529531
readonly environmentId: EnvironmentId;
530532
readonly canManageRelay: boolean;
533+
readonly connectDeviceApproval: ConnectDeviceApprovalControl | null;
531534
}) {
535+
const updateEnvironmentSettings = useUpdateEnvironmentSettings(environmentId);
532536
const {
533537
isSignedIn,
534538
linkState: cloudLinkState,
@@ -746,18 +750,48 @@ function ConfiguredCloudLinkRow({
746750
}
747751
/>
748752
) : null}
753+
{managedTunnelActive && !signedOut && connectDeviceApproval ? (
754+
<SettingsRow
755+
title={searchableSetting("connect-device-approval").title}
756+
description="Devices that sign in to your T3 Connect account wait until someone already connected here approves them."
757+
managed={connectDenial}
758+
control={
759+
<CloudLinkSwitch
760+
ariaLabel="Require approval for new T3 Connect devices"
761+
checked={connectDeviceApproval.required}
762+
disabled={!connectDeviceApproval.canManage}
763+
disabledReason={
764+
connectDeviceApproval.canManage
765+
? null
766+
: "Your session does not have permission to manage access."
767+
}
768+
onCheckedChange={(enabled) =>
769+
updateEnvironmentSettings({ requireConnectDeviceApproval: enabled })
770+
}
771+
/>
772+
}
773+
/>
774+
) : null}
749775
</>
750776
);
751777
}
752778

779+
/** Older servers have no device approval, so callers pass null and the row stays hidden. */
780+
export interface ConnectDeviceApprovalControl {
781+
readonly required: boolean;
782+
readonly canManage: boolean;
783+
}
784+
753785
export function CloudLinkRow({
754786
environmentId,
755787
canReadRelay,
756788
canManageRelay,
789+
connectDeviceApproval,
757790
}: {
758791
readonly environmentId: EnvironmentId;
759792
readonly canReadRelay: boolean;
760793
readonly canManageRelay: boolean;
794+
readonly connectDeviceApproval: ConnectDeviceApprovalControl | null;
761795
}) {
762796
if (!hasCloudPublicConfig()) return null;
763797
if (!canReadRelay) {
@@ -768,7 +802,13 @@ export function CloudLinkRow({
768802
/>
769803
);
770804
}
771-
return <ConfiguredCloudLinkRow environmentId={environmentId} canManageRelay={canManageRelay} />;
805+
return (
806+
<ConfiguredCloudLinkRow
807+
environmentId={environmentId}
808+
canManageRelay={canManageRelay}
809+
connectDeviceApproval={connectDeviceApproval}
810+
/>
811+
);
772812
}
773813

774814
function EmptyRemoteEnvironments({ cloudEnabled = true }: { readonly cloudEnabled?: boolean }) {

‎apps/web/src/components/settings/settingsSearch.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,8 +1286,10 @@ export const SETTINGS_SEARCH_ITEMS = [
12861286
id: "connect-device-approval",
12871287
title: "Require approval for new devices",
12881288
to: "/settings/access",
1289+
targetId: "connections-environment",
12891290
searchTerms: ["t3 connect devices approve deny trust revoke pairing code security account"],
12901291
cloudOnly: true,
1292+
managedTunnelOnly: true,
12911293
},
12921294
{
12931295
id: "hold-webhooks-while-offline",

0 commit comments

Comments
 (0)