The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 23, 05:30 UTC
perf(web): the provider update launch notification compiles with the React Compiler (#20577)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 16, 2026 at 22:40 UTC
825450508452a60a0446378a67daa192be9d99f5
1 file changed
+25
-30
apps/web/src/components/ProviderUpdateLaunchNotification.tsx
+25
-30
@@ -1,7 +1,8 @@
1
import { useNavigate } from "@tanstack/react-router";
2
import { DownloadIcon } from "lucide-react";
3
-import { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
+import { useEffect, useRef, useState } from "react";
4
5
+import { useStableCallback } from "~/hooks/useStableCallback";
6
import { useEnvironments } from "~/state/environments";
7
import { isDesktopLocalConnectionTarget } from "~/connection/desktopLocal";
8
import { useDismissedProviderUpdateNotificationKeys } from "../providerUpdateDismissal";
@@ -18,10 +19,8 @@ import { stackedThreadToast, toastManager } from "./ui/toast";
19
20
function useHasLocalSecondaryEnvironment(): boolean {
21
const { environments } = useEnvironments();
21
- return useMemo(
22
- () =>
23
- environments.some((environment) => isDesktopLocalConnectionTarget(environment.entry.target)),
24
- [environments],
22
+ return environments.some((environment) =>
23
+ isDesktopLocalConnectionTarget(environment.entry.target),
24
);
25
}
26
@@ -53,7 +52,6 @@ function ProviderUpdateEnvironmentsNotification() {
52
readonly toastId: ProviderUpdateToastId;
53
readonly key: string;
54
} | null>(null);
56
- const notificationKeyRef = useRef<string | null>(null);
55
// Whether the user has triggered an update from the current toast. Until they
56
// do, the prompt is replaced when the available updates change; afterward it
57
// is kept so in-progress rows are not torn down.
@@ -68,36 +66,41 @@ function ProviderUpdateEnvironmentsNotification() {
66
};
67
}, []);
68
71
- const updateGroups = useMemo(() => environmentGroupsWithUpdates(groups), [groups]);
72
- const notificationKey = useMemo(() => localEnvironmentUpdateNotificationKey(groups), [groups]);
73
- useEffect(() => {
74
- notificationKeyRef.current = notificationKey;
75
- }, [notificationKey]);
76
-
77
- const candidateUnion = useMemo(
78
- () => collectProviderUpdateCandidates(updateGroups.flatMap((group) => group.candidates)),
79
- [updateGroups],
69
+ const updateGroups = environmentGroupsWithUpdates(groups);
70
+ const notificationKey = localEnvironmentUpdateNotificationKey(groups);
71
+ const candidateUnion = collectProviderUpdateCandidates(
72
+ updateGroups.flatMap((group) => group.candidates),
73
);
74
75
const [settleGraceElapsed, setSettleGraceElapsed] = useState(false);
76
+ // The grace period restarts with the next settling phase.
77
+ if (!isAnySettling && settleGraceElapsed) {
78
+ setSettleGraceElapsed(false);
79
+ }
80
useEffect(() => {
84
- if (!isAnySettling) {
85
- setSettleGraceElapsed(false);
86
- return;
87
- }
81
+ if (!isAnySettling) return;
82
const timer = setTimeout(() => setSettleGraceElapsed(true), SETTLING_GRACE_MS);
83
return () => clearTimeout(timer);
84
}, [isAnySettling]);
85
const isGated = isAnySettling && !settleGraceElapsed;
86
93
- const openProviderSettings = useCallback(() => {
87
+ const openProviderSettings = () => {
88
const active = activeToastRef.current;
89
if (active !== null) {
90
toastManager.close(active.toastId);
91
activeToastRef.current = null;
92
}
93
void navigate({ to: "/settings/providers" });
100
- }, [navigate]);
94
+ };
95
+
96
+ // The toast closes long after the effect that opened it, so it dismisses the key
97
+ // the updates have moved to by then.
98
+ const dismissPrompt = useStableCallback(() => {
99
+ if (notificationKey) {
100
+ dismissNotificationKey(notificationKey);
101
+ }
102
+ activeToastRef.current = null;
103
+ });
104
105
useEffect(() => {
106
const canShowPrompt =
@@ -124,14 +127,6 @@ function ProviderUpdateEnvironmentsNotification() {
127
seenProviderUpdateNotificationKeys.add(notificationKey);
128
hasInteractedRef.current = false;
129
127
- const dismissPrompt = () => {
128
- const liveKey = notificationKeyRef.current;
129
- if (liveKey) {
130
- dismissNotificationKey(liveKey);
131
- }
132
- activeToastRef.current = null;
133
- };
134
-
130
const toastId = toastManager.add(
131
stackedThreadToast({
132
type: "warning",
@@ -165,7 +160,7 @@ function ProviderUpdateEnvironmentsNotification() {
160
isGated,
161
candidateUnion,
162
dismissedNotificationKeys,
168
- dismissNotificationKey,
163
+ dismissPrompt,
164
openProviderSettings,
165
]);
166