TypeScript
perf(web): the server update action compiles with the React Compiler (#20478)
Julius Marmingeb27c686298be
diff --git a/apps/web/reactCompiledFiles.ts b/apps/web/reactCompiledFiles.tsindex ddfb3b27e62..dc46d2f1767 100644--- a/apps/web/reactCompiledFiles.ts+++ b/apps/web/reactCompiledFiles.ts@@ -53,4 +53,5 @@ export const REACT_COMPILED_FILES = ["apps/web/src/components/chat/QueuedRunsControl.tsx","apps/web/src/components/preview/PreviewView.tsx","apps/web/src/components/CommandPalette.tsx",+ "apps/web/src/components/ServerUpdateAction.tsx",] as const;diff --git a/apps/web/src/components/ServerUpdateAction.tsx b/apps/web/src/components/ServerUpdateAction.tsxindex c2a20aa64d2..3d809655e28 100644--- a/apps/web/src/components/ServerUpdateAction.tsx+++ b/apps/web/src/components/ServerUpdateAction.tsx@@ -14,6 +14,7 @@ import type {import type { ServerUpdateStage, ServerUpdateState } from "@t3tools/client-runtime/state/server";import {isAtomCommandInterrupted,+ settlePromise,squashAtomCommandFailure,} from "@t3tools/client-runtime/state/runtime";import { CircleArrowUpIcon } from "lucide-react";@@ -79,33 +80,19 @@ export function useServerUpdate() {)return { status: "skipped" };pendingUpdateEnvironmentIds.add(environmentId);- try {- const result = await updateServer({- environmentId,- input: {- targetVersion,- ...(target.threadContinuation && target.continueThreadsAfterServerUpdate- ? { continueRunningThreads: true }- : {}),- },- });- if (result._tag === "Failure") {- if (isAtomCommandInterrupted(result)) return { status: "skipped" };- throw squashAtomCommandFailure(result);- }- if (!quiet) {- toastManager.add({- type: "success",- title: `${serverLabel} updated`,- description:- selfUpdate === "desktop-managed"- ? `Desktop app relaunched on ${result.value.targetVersion}.`- : `Reconnected on t3@${result.value.targetVersion}.`,- });- }- return { status: "updated" };- } catch (error) {- const message = updateFailureMessage(error);+ const result = await updateServer({+ environmentId,+ input: {+ targetVersion,+ ...(target.threadContinuation && target.continueThreadsAfterServerUpdate+ ? { continueRunningThreads: true }+ : {}),+ },+ });+ pendingUpdateEnvironmentIds.delete(environmentId);+ if (result._tag === "Failure") {+ if (isAtomCommandInterrupted(result)) return { status: "skipped" };+ const message = updateFailureMessage(squashAtomCommandFailure(result));if (!quiet) {toastManager.add({type: "error",@@ -114,9 +101,18 @@ export function useServerUpdate() {});}return { status: "failed", message };- } finally {- pendingUpdateEnvironmentIds.delete(environmentId);}+ if (!quiet) {+ toastManager.add({+ type: "success",+ title: `${serverLabel} updated`,+ description:+ selfUpdate === "desktop-managed"+ ? `Desktop app relaunched on ${result.value.targetVersion}.`+ : `Reconnected on t3@${result.value.targetVersion}.`,+ });+ }+ return { status: "updated" };};}@@ -141,7 +137,7 @@ export function ServerUpdatesAction({if (pending.current) return;pending.current = true;setIsPending(true);- try {+ await settlePromise(async () => {const available = eligible.filter((target) => !pendingUpdateEnvironmentIds.has(target.environmentId),);@@ -154,10 +150,9 @@ export function ServerUpdatesAction({if (!confirmed) return;}await Promise.all(available.map((target) => update(target)));- } finally {- pending.current = false;- setIsPending(false);- }+ });+ pending.current = false;+ setIsPending(false);};return (<Button@@ -355,30 +350,26 @@ export function OutdatedServerUpdateAction({const handleUpdate = async () => {if (pendingUpdateEnvironmentIds.has(environmentId)) return;pendingUpdateEnvironmentIds.add(environmentId);- try {- const result = await update({- environmentId,- input: { targetVersion },- ...(fromVersion === undefined ? {} : { fromVersion }),- });- if (result._tag === "Failure") {- if (isAtomCommandInterrupted(result)) return;- throw squashAtomCommandFailure(result);- }- toastManager.add({- type: "success",- title: `${serverLabel} updated`,- description: `Reconnected on t3@${result.value.targetVersion}.`,- });- } catch (error) {+ const result = await update({+ environmentId,+ input: { targetVersion },+ ...(fromVersion === undefined ? {} : { fromVersion }),+ });+ pendingUpdateEnvironmentIds.delete(environmentId);+ if (result._tag === "Failure") {+ if (isAtomCommandInterrupted(result)) return;toastManager.add({type: "error",title: `${serverLabel} update failed`,- description: updateFailureMessage(error),+ description: updateFailureMessage(squashAtomCommandFailure(result)),});- } finally {- pendingUpdateEnvironmentIds.delete(environmentId);+ return;}+ toastManager.add({+ type: "success",+ title: `${serverLabel} updated`,+ description: `Reconnected on t3@${result.value.targetVersion}.`,+ });};return (<Button size="xs" variant="outline" onClick={() => void handleUpdate()}>