Skip to content

Commit 8ecfca2

Browse files
perf(web): device hosts settings compile with the React Compiler
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent fcfd6d2 commit 8ecfca2

2 files changed

Lines changed: 50 additions & 60 deletions

File tree

‎apps/web/reactCompiledFiles.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,5 @@ export const REACT_COMPILED_FILES = [
8383
"apps/web/src/components/settings/ProviderSetupSection.tsx",
8484
"apps/web/src/components/settings/StorageSettings.tsx",
8585
"apps/web/src/components/settings/DiagnosticsSettings.tsx",
86+
"apps/web/src/components/settings/DeviceHostsSettings.tsx",
8687
] as const;

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

Lines changed: 49 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { AppleIcon, AndroidIcon } from "../Icons";
1010
import { Spinner } from "../ui/spinner";
1111
import type { EnvironmentId, SshDeviceHostConfig } from "@t3tools/contracts";
1212
import { randomUUID } from "../../lib/utils";
13-
import { useMemo, useState } from "react";
13+
import { useState } from "react";
1414
import { deviceEnvironment } from "../../state/device";
1515
import { serverEnvironment } from "../../state/server";
1616
import { useAtomCommand } from "../../state/use-atom-command";
@@ -55,59 +55,52 @@ export function DeviceHostsSettings(props: { environmentId: EnvironmentId | null
5555
connected: environment.connection.phase === "connected",
5656
}));
5757
const { checks, testConnection } = useHostConnectionChecks(targets);
58-
const hostEnvironments = useMemo(
59-
() =>
60-
connectedEnvironments.map((environment) => ({
61-
environmentId: environment.environmentId,
62-
label: environment.label,
63-
labels: settingsScopeEnvironmentLabels(environment, connectedEnvironments),
64-
hosts: environment.serverConfig?.settings.deviceHosts ?? [],
65-
})),
66-
[connectedEnvironments],
67-
);
68-
const groupedHosts = useMemo(() => groupDeviceHosts(hostEnvironments), [hostEnvironments]);
58+
const hostEnvironments = connectedEnvironments.map((environment) => ({
59+
environmentId: environment.environmentId,
60+
label: environment.label,
61+
labels: settingsScopeEnvironmentLabels(environment, connectedEnvironments),
62+
hosts: environment.serverConfig?.settings.deviceHosts ?? [],
63+
}));
64+
const groupedHosts = groupDeviceHosts(hostEnvironments);
6965
const save = async (host: SshDeviceHostConfig, remove = false, original = host) => {
7066
if (!props.environmentId || projectScope) return;
7167
setBusy(true);
72-
try {
73-
const results = await Promise.allSettled(
74-
environments.map(async (environment) => {
75-
if (environment.connection.phase !== "connected" || !environment.serverConfig) {
76-
throw new Error("Environment disconnected");
77-
}
78-
if (!readEnvironmentScope(environment.environmentId, AuthSettingsWriteScope)) {
79-
throw new Error("This connection cannot change device settings.");
80-
}
81-
return update({
82-
environmentId: environment.environmentId,
83-
input: {
84-
patch: {
85-
deviceHosts: updateDeviceHosts(
86-
environment.serverConfig.settings.deviceHosts,
87-
host,
88-
remove,
89-
original,
90-
),
91-
},
68+
const results = await Promise.allSettled(
69+
environments.map(async (environment) => {
70+
if (environment.connection.phase !== "connected" || !environment.serverConfig) {
71+
throw new Error("Environment disconnected");
72+
}
73+
if (!readEnvironmentScope(environment.environmentId, AuthSettingsWriteScope)) {
74+
throw new Error("This connection cannot change device settings.");
75+
}
76+
return update({
77+
environmentId: environment.environmentId,
78+
input: {
79+
patch: {
80+
deviceHosts: updateDeviceHosts(
81+
environment.serverConfig.settings.deviceHosts,
82+
host,
83+
remove,
84+
original,
85+
),
9286
},
93-
});
94-
}),
95-
);
96-
const failed = environments.filter((_, index) => {
97-
const result = results[index];
98-
return result?.status !== "fulfilled" || result.value._tag === "Failure";
99-
});
100-
if (failed.length === 0) {
101-
setEditing(null);
102-
} else {
103-
toastManager.add({
104-
type: "error",
105-
title: "Device hosts not saved on all environments",
106-
description: `Could not update ${failed.map((environment) => environment.label).join(", ")}.`,
87+
},
10788
});
108-
}
109-
} finally {
110-
setBusy(false);
89+
}),
90+
);
91+
setBusy(false);
92+
const failed = environments.filter((_, index) => {
93+
const result = results[index];
94+
return result?.status !== "fulfilled" || result.value._tag === "Failure";
95+
});
96+
if (failed.length === 0) {
97+
setEditing(null);
98+
} else {
99+
toastManager.add({
100+
type: "error",
101+
title: "Device hosts not saved on all environments",
102+
description: `Could not update ${failed.map((environment) => environment.label).join(", ")}.`,
103+
});
111104
}
112105
};
113106
const listActions = {
@@ -246,18 +239,14 @@ function DeviceHostList({
246239
]),
247240
);
248241
const states = useAtomValue(
249-
useMemo(
250-
() =>
251-
Atom.make(
252-
(get) =>
253-
new Map(
254-
environments.map(({ environmentId }) => {
255-
const result = get(deviceEnvironment.state({ environmentId, input: {} }));
256-
return [environmentId, Option.getOrUndefined(AsyncResult.value(result))] as const;
257-
}),
258-
),
242+
Atom.make(
243+
(get) =>
244+
new Map(
245+
environments.map(({ environmentId }) => {
246+
const result = get(deviceEnvironment.state({ environmentId, input: {} }));
247+
return [environmentId, Option.getOrUndefined(AsyncResult.value(result))] as const;
248+
}),
259249
),
260-
[environments],
261250
),
262251
);
263252
const retry = useAtomCommand(deviceEnvironment.list);

0 commit comments

Comments
 (0)