Skip to content
TypeScript

perf(web): the provider updates action compiles with the React Compiler (#20485)

Julius Marminge5cc75e8cb5e6
diff --git a/apps/web/reactCompiledFiles.ts b/apps/web/reactCompiledFiles.ts
index c38e1b43bab..10b27275560 100644
--- a/apps/web/reactCompiledFiles.ts
+++ b/apps/web/reactCompiledFiles.ts
@@ -60,4 +60,5 @@ export const REACT_COMPILED_FILES = [
"apps/web/src/components/files/useDirectoryEntries.ts",
"apps/web/src/components/files/FileBrowserPanel.tsx",
"apps/web/src/components/sidebar/SidebarUpdatePill.tsx",
+ "apps/web/src/components/ProviderUpdatesAction.tsx",
] as const;
diff --git a/apps/web/src/components/ProviderUpdatesAction.tsx b/apps/web/src/components/ProviderUpdatesAction.tsx
index b7dbd9eb220..7244b8e683a 100644
--- a/apps/web/src/components/ProviderUpdatesAction.tsx
+++ b/apps/web/src/components/ProviderUpdatesAction.tsx
@@ -1,5 +1,6 @@
import { PROVIDER_DISPLAY_NAMES } from "@t3tools/contracts";
-import { useMemo, useRef, useState } from "react";
+import { settlePromise } from "@t3tools/client-runtime/state/runtime";
+import { useRef, useState } from "react";
import { useEnvironments } from "~/state/environments";
import { serverEnvironment } from "~/state/server";
@@ -19,22 +20,18 @@ export function useProviderUpdates() {
const updateProvider = useAtomCommand(serverEnvironment.updateProvider, {
reportFailure: false,
});
- const machines = useMemo(
- () =>
- environments.flatMap((environment) => {
- const providers = environment.serverConfig?.providers ?? [];
- if (environment.connection.phase !== "connected") {
- return [];
- }
- const candidates = collectProviderUpdateCandidates(providers).filter((candidate) =>
- canOneClickUpdateProviderCandidate(candidate, providers),
- );
- return candidates.length > 0
- ? [{ environmentId: environment.environmentId, label: environment.label, candidates }]
- : [];
- }),
- [environments],
- );
+ const machines = environments.flatMap((environment) => {
+ const providers = environment.serverConfig?.providers ?? [];
+ if (environment.connection.phase !== "connected") {
+ return [];
+ }
+ const candidates = collectProviderUpdateCandidates(providers).filter((candidate) =>
+ canOneClickUpdateProviderCandidate(candidate, providers),
+ );
+ return candidates.length > 0
+ ? [{ environmentId: environment.environmentId, label: environment.label, candidates }]
+ : [];
+ });
const updateAll = async ({ quiet = false }: { readonly quiet?: boolean } = {}) => {
const runs = await Promise.all(
@@ -78,12 +75,9 @@ export function ProviderUpdatesAction() {
if (pending.current) return;
pending.current = true;
setIsPending(true);
- try {
- await updateAll();
- } finally {
- pending.current = false;
- setIsPending(false);
- }
+ await settlePromise(() => updateAll());
+ pending.current = false;
+ setIsPending(false);
};
return (