Skip to content

Commit d43289f

Browse files
perf(web): the server update action compiles with the React Compiler
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent a150481 commit d43289f

2 files changed

Lines changed: 45 additions & 53 deletions

File tree

‎apps/web/reactCompiledFiles.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,5 @@ export const REACT_COMPILED_FILES = [
5353
"apps/web/src/components/chat/QueuedRunsControl.tsx",
5454
"apps/web/src/components/preview/PreviewView.tsx",
5555
"apps/web/src/components/CommandPalette.tsx",
56+
"apps/web/src/components/ServerUpdateAction.tsx",
5657
] as const;

‎apps/web/src/components/ServerUpdateAction.tsx‎

Lines changed: 44 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type {
1414
import type { ServerUpdateStage, ServerUpdateState } from "@t3tools/client-runtime/state/server";
1515
import {
1616
isAtomCommandInterrupted,
17+
settlePromise,
1718
squashAtomCommandFailure,
1819
} from "@t3tools/client-runtime/state/runtime";
1920
import { CircleArrowUpIcon } from "lucide-react";
@@ -79,33 +80,19 @@ export function useServerUpdate() {
7980
)
8081
return { status: "skipped" };
8182
pendingUpdateEnvironmentIds.add(environmentId);
82-
try {
83-
const result = await updateServer({
84-
environmentId,
85-
input: {
86-
targetVersion,
87-
...(target.threadContinuation && target.continueThreadsAfterServerUpdate
88-
? { continueRunningThreads: true }
89-
: {}),
90-
},
91-
});
92-
if (result._tag === "Failure") {
93-
if (isAtomCommandInterrupted(result)) return { status: "skipped" };
94-
throw squashAtomCommandFailure(result);
95-
}
96-
if (!quiet) {
97-
toastManager.add({
98-
type: "success",
99-
title: `${serverLabel} updated`,
100-
description:
101-
selfUpdate === "desktop-managed"
102-
? `Desktop app relaunched on ${result.value.targetVersion}.`
103-
: `Reconnected on t3@${result.value.targetVersion}.`,
104-
});
105-
}
106-
return { status: "updated" };
107-
} catch (error) {
108-
const message = updateFailureMessage(error);
83+
const result = await updateServer({
84+
environmentId,
85+
input: {
86+
targetVersion,
87+
...(target.threadContinuation && target.continueThreadsAfterServerUpdate
88+
? { continueRunningThreads: true }
89+
: {}),
90+
},
91+
});
92+
pendingUpdateEnvironmentIds.delete(environmentId);
93+
if (result._tag === "Failure") {
94+
if (isAtomCommandInterrupted(result)) return { status: "skipped" };
95+
const message = updateFailureMessage(squashAtomCommandFailure(result));
10996
if (!quiet) {
11097
toastManager.add({
11198
type: "error",
@@ -114,9 +101,18 @@ export function useServerUpdate() {
114101
});
115102
}
116103
return { status: "failed", message };
117-
} finally {
118-
pendingUpdateEnvironmentIds.delete(environmentId);
119104
}
105+
if (!quiet) {
106+
toastManager.add({
107+
type: "success",
108+
title: `${serverLabel} updated`,
109+
description:
110+
selfUpdate === "desktop-managed"
111+
? `Desktop app relaunched on ${result.value.targetVersion}.`
112+
: `Reconnected on t3@${result.value.targetVersion}.`,
113+
});
114+
}
115+
return { status: "updated" };
120116
};
121117
}
122118

@@ -141,7 +137,7 @@ export function ServerUpdatesAction({
141137
if (pending.current) return;
142138
pending.current = true;
143139
setIsPending(true);
144-
try {
140+
await settlePromise(async () => {
145141
const available = eligible.filter(
146142
(target) => !pendingUpdateEnvironmentIds.has(target.environmentId),
147143
);
@@ -154,10 +150,9 @@ export function ServerUpdatesAction({
154150
if (!confirmed) return;
155151
}
156152
await Promise.all(available.map((target) => update(target)));
157-
} finally {
158-
pending.current = false;
159-
setIsPending(false);
160-
}
153+
});
154+
pending.current = false;
155+
setIsPending(false);
161156
};
162157
return (
163158
<Button
@@ -355,30 +350,26 @@ export function OutdatedServerUpdateAction({
355350
const handleUpdate = async () => {
356351
if (pendingUpdateEnvironmentIds.has(environmentId)) return;
357352
pendingUpdateEnvironmentIds.add(environmentId);
358-
try {
359-
const result = await update({
360-
environmentId,
361-
input: { targetVersion },
362-
...(fromVersion === undefined ? {} : { fromVersion }),
363-
});
364-
if (result._tag === "Failure") {
365-
if (isAtomCommandInterrupted(result)) return;
366-
throw squashAtomCommandFailure(result);
367-
}
368-
toastManager.add({
369-
type: "success",
370-
title: `${serverLabel} updated`,
371-
description: `Reconnected on t3@${result.value.targetVersion}.`,
372-
});
373-
} catch (error) {
353+
const result = await update({
354+
environmentId,
355+
input: { targetVersion },
356+
...(fromVersion === undefined ? {} : { fromVersion }),
357+
});
358+
pendingUpdateEnvironmentIds.delete(environmentId);
359+
if (result._tag === "Failure") {
360+
if (isAtomCommandInterrupted(result)) return;
374361
toastManager.add({
375362
type: "error",
376363
title: `${serverLabel} update failed`,
377-
description: updateFailureMessage(error),
364+
description: updateFailureMessage(squashAtomCommandFailure(result)),
378365
});
379-
} finally {
380-
pendingUpdateEnvironmentIds.delete(environmentId);
366+
return;
381367
}
368+
toastManager.add({
369+
type: "success",
370+
title: `${serverLabel} updated`,
371+
description: `Reconnected on t3@${result.value.targetVersion}.`,
372+
});
382373
};
383374
return (
384375
<Button size="xs" variant="outline" onClick={() => void handleUpdate()}>

0 commit comments

Comments
 (0)