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 24, 16:30 UTC
fix(web): clarify desktop update status (#6504)
Wout Stiens committed
Aug 14, 2026 at 17:58 UTC
1a6599437b6ad77330923819613cc28be3b33945
2 files changed
+217
-22
apps/web/src/components/sidebar/DesktopUpdateStatusIcon.tsx
new
+126
@@ -0,0 +1,126 @@
1
+import { CheckIcon, DownloadIcon, RefreshCwIcon, RotateCwIcon } from "lucide-react";
2
+import type { AnimationEventHandler } from "react";
3
+
4
+import { cn } from "../../lib/utils";
5
+
6
+const DOWNLOAD_PROGRESS_RADIUS = 14;
7
+const DOWNLOAD_PROGRESS_CIRCUMFERENCE = 2 * Math.PI * DOWNLOAD_PROGRESS_RADIUS;
8
+
9
+export type DesktopUpdateStatusIconState =
10
+ | "idle"
11
+ | "checking"
12
+ | "available"
13
+ | "downloading"
14
+ | "downloaded";
15
+
16
+function normalizeDesktopUpdateDownloadPercent(percent: number | null): number {
17
+ if (percent === null || !Number.isFinite(percent)) return 0;
18
+ return Math.min(100, Math.max(0, percent));
19
+}
20
+
21
+export function shouldShowDesktopUpdateCheckIcon({
22
+ isAnimationLatched,
23
+ isChecking,
24
+ prefersReducedMotion,
25
+}: {
26
+ readonly isAnimationLatched: boolean;
27
+ readonly isChecking: boolean;
28
+ readonly prefersReducedMotion: boolean;
29
+}): boolean {
30
+ return isChecking || (isAnimationLatched && !prefersReducedMotion);
31
+}
32
+
33
+export function shouldContinueDesktopUpdateCheckAnimation({
34
+ isChecking,
35
+ prefersReducedMotion,
36
+}: {
37
+ readonly isChecking: boolean;
38
+ readonly prefersReducedMotion: boolean;
39
+}): boolean {
40
+ return isChecking && !prefersReducedMotion;
41
+}
42
+
43
+function DesktopUpdateAvailableIcon() {
44
+ return (
45
+ <span className="relative grid size-4 place-items-center">
46
+ <DownloadIcon className="size-4" />
47
+ <span
48
+ aria-hidden="true"
49
+ className="absolute -top-0.5 -right-0.5 size-1.5 rounded-full bg-update-foreground ring-2 ring-update-surface"
50
+ />
51
+ </span>
52
+ );
53
+}
54
+
55
+function DesktopUpdateDownloadingIcon({ percent }: { readonly percent: number | null }) {
56
+ const normalizedPercent = normalizeDesktopUpdateDownloadPercent(percent);
57
+ const progressOffset = DOWNLOAD_PROGRESS_CIRCUMFERENCE * (1 - normalizedPercent / 100);
58
+
59
+ return (
60
+ <span className="relative grid size-8 place-items-center">
61
+ <svg
62
+ aria-hidden="true"
63
+ className="pointer-events-none absolute inset-0 size-full -rotate-90"
64
+ viewBox="0 0 32 32"
65
+ >
66
+ <circle
67
+ cx="16"
68
+ cy="16"
69
+ r={DOWNLOAD_PROGRESS_RADIUS}
70
+ fill="none"
71
+ stroke="color-mix(in srgb, currentColor 22%, transparent)"
72
+ strokeWidth="1.5"
73
+ />
74
+ <circle
75
+ cx="16"
76
+ cy="16"
77
+ r={DOWNLOAD_PROGRESS_RADIUS}
78
+ fill="none"
79
+ stroke="currentColor"
80
+ strokeDasharray={DOWNLOAD_PROGRESS_CIRCUMFERENCE}
81
+ strokeDashoffset={progressOffset}
82
+ strokeLinecap="round"
83
+ strokeWidth="1.5"
84
+ className="transition-[stroke-dashoffset] duration-300 ease-out motion-reduce:transition-none"
85
+ />
86
+ </svg>
87
+ <DownloadIcon className="size-4" />
88
+ </span>
89
+ );
90
+}
91
+
92
+function DesktopUpdateDownloadedIcon() {
93
+ return (
94
+ <span className="relative grid size-4 place-items-center">
95
+ <RotateCwIcon className="size-4" />
96
+ <span className="absolute -right-1 -bottom-1 grid size-2.5 place-items-center rounded-full bg-update-foreground text-background ring-2 ring-background">
97
+ <CheckIcon className="size-2" strokeWidth={3} />
98
+ </span>
99
+ </span>
100
+ );
101
+}
102
+
103
+export function DesktopUpdateStatusIcon({
104
+ downloadPercent,
105
+ isCheckAnimating,
106
+ onCheckAnimationIteration,
107
+ status,
108
+}: {
109
+ readonly downloadPercent?: number | null;
110
+ readonly isCheckAnimating?: boolean;
111
+ readonly onCheckAnimationIteration?: AnimationEventHandler<SVGSVGElement>;
112
+ readonly status: DesktopUpdateStatusIconState;
113
+}) {
114
+ if (status === "available") return <DesktopUpdateAvailableIcon />;
115
+ if (status === "downloading") {
116
+ return <DesktopUpdateDownloadingIcon percent={downloadPercent ?? null} />;
117
+ }
118
+ if (status === "downloaded") return <DesktopUpdateDownloadedIcon />;
119
+
120
+ return (
121
+ <RefreshCwIcon
122
+ className={cn("size-4", status === "checking" && isCheckAnimating && "animate-spin")}
123
+ onAnimationIteration={onCheckAnimationIteration}
124
+ />
125
+ );
126
+}
apps/web/src/components/sidebar/SidebarUpdatePill.tsx
+91
-22
@@ -1,6 +1,7 @@
1
-import { DownloadIcon, RefreshCwIcon, RotateCwIcon, TriangleAlertIcon } from "lucide-react";
2
-import { useCallback, useState } from "react";
1
+import { TriangleAlertIcon } from "lucide-react";
2
+import { useCallback, useEffect, useState } from "react";
3
import { isElectron } from "../../env";
4
+import { useMediaQuery } from "../../hooks/useMediaQuery";
5
import { cn } from "../../lib/utils";
6
import { ensureLocalApi } from "../../localApi";
7
import { useDesktopUpdateState } from "../../state/desktopUpdate";
@@ -21,6 +22,38 @@ import { Alert, AlertDescription, AlertTitle } from "../ui/alert";
22
import { Separator } from "../ui/separator";
23
import { SidebarMenuItem } from "../ui/sidebar";
24
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
25
+import {
26
+ DesktopUpdateStatusIcon,
27
+ shouldContinueDesktopUpdateCheckAnimation,
28
+ shouldShowDesktopUpdateCheckIcon,
29
+} from "./DesktopUpdateStatusIcon";
30
+
31
+function resolveSidebarUpdatePresentation({
32
+ action,
33
+ isDownloading,
34
+ showCheckIcon,
35
+}: {
36
+ readonly action: ReturnType<typeof resolveDesktopUpdateButtonAction>;
37
+ readonly isDownloading: boolean;
38
+ readonly showCheckIcon: boolean;
39
+}) {
40
+ const showUpdateDetails = action !== "none" || isDownloading;
41
+ const iconStatus = showCheckIcon
42
+ ? "checking"
43
+ : action === "install"
44
+ ? "downloaded"
45
+ : isDownloading
46
+ ? "downloading"
47
+ : action === "download"
48
+ ? "available"
49
+ : "idle";
50
+
51
+ return {
52
+ iconStatus,
53
+ showUpdateDetails,
54
+ showUpdateIconState: showUpdateDetails && !showCheckIcon,
55
+ } as const;
56
+}
57
58
function keyReleaseNoteItems(items: ReadonlyArray<string>) {
59
const occurrences = new Map<string, number>();
@@ -110,18 +143,42 @@ export function SidebarUpdatePill() {
143
function SidebarUpdateControl() {
144
const state = useDesktopUpdateState();
145
const [isActionPending, setIsActionPending] = useState(false);
146
+ const [checkAnimationKey, setCheckAnimationKey] = useState(0);
147
+ const [isCheckAnimationLatched, setIsCheckAnimationLatched] = useState(false);
148
+ const prefersReducedMotion = useMediaQuery("(prefers-reduced-motion: reduce)");
149
+
150
+ useEffect(() => {
151
+ if (prefersReducedMotion) {
152
+ setIsCheckAnimationLatched(false);
153
+ } else if (state?.status === "checking") {
154
+ setIsCheckAnimationLatched(true);
155
+ }
156
+ }, [prefersReducedMotion, state?.status]);
157
158
const action = state ? resolveDesktopUpdateButtonAction(state) : "none";
159
const isDownloading = state?.status === "downloading";
116
- const isUpdateState = action !== "none" || isDownloading;
117
- const tooltip = isUpdateState
160
+ const showCheckIcon = shouldShowDesktopUpdateCheckIcon({
161
+ isAnimationLatched: isCheckAnimationLatched,
162
+ isChecking: state?.status === "checking",
163
+ prefersReducedMotion,
164
+ });
165
+ const { iconStatus, showUpdateDetails, showUpdateIconState } = resolveSidebarUpdatePresentation({
166
+ action,
167
+ isDownloading,
168
+ showCheckIcon,
169
+ });
170
+ const tooltip = showUpdateDetails
171
? state
172
? getDesktopUpdateButtonTooltip(state)
173
: "Update available"
121
- : state?.status === "checking"
174
+ : showCheckIcon
175
? "Checking for updates…"
176
: "Check for updates";
124
- const disabled = isUpdateState ? isDesktopUpdateButtonDisabled(state) : !canCheckForUpdate(state);
177
+ const disabled = showCheckIcon
178
+ ? true
179
+ : showUpdateDetails
180
+ ? isDesktopUpdateButtonDisabled(state)
181
+ : !canCheckForUpdate(state);
182
183
const handleAction = useCallback(async () => {
184
const bridge = window.desktopBridge;
@@ -209,6 +266,10 @@ function SidebarUpdateControl() {
266
return;
267
}
268
269
+ if (!prefersReducedMotion) {
270
+ setIsCheckAnimationLatched(true);
271
+ setCheckAnimationKey((key) => key + 1);
272
+ }
273
void bridge
274
.checkForUpdate()
275
.then((result) => {
@@ -232,7 +293,16 @@ function SidebarUpdateControl() {
293
);
294
})
295
.finally(() => setIsActionPending(false));
235
- }, [action, disabled, isActionPending, state]);
296
+ }, [action, disabled, isActionPending, prefersReducedMotion, state]);
297
+
298
+ const handleCheckAnimationIteration = useCallback(() => {
299
+ setIsCheckAnimationLatched(
300
+ shouldContinueDesktopUpdateCheckAnimation({
301
+ isChecking: state?.status === "checking",
302
+ prefersReducedMotion,
303
+ }),
304
+ );
305
+ }, [prefersReducedMotion, state?.status]);
306
307
return (
308
<SidebarMenuItem className="ml-auto shrink-0">
@@ -245,29 +315,28 @@ function SidebarUpdateControl() {
315
aria-disabled={disabled || isActionPending || undefined}
316
disabled={disabled || isActionPending}
317
className={cn(
248
- "inline-flex size-8 items-center justify-center rounded-full outline-hidden ring-ring transition-colors enabled:cursor-pointer focus-visible:ring-2 disabled:cursor-not-allowed disabled:opacity-60",
249
- isUpdateState
318
+ "inline-flex size-8 items-center justify-center rounded-full outline-hidden ring-ring transition-colors enabled:cursor-pointer focus-visible:ring-2 disabled:cursor-not-allowed",
319
+ showUpdateIconState
320
? "bg-update-surface text-update-foreground enabled:hover:bg-update/12"
321
: "text-[var(--sidebar-icon-color)] enabled:hover:bg-sidebar-row-hover enabled:hover:text-sidebar-foreground",
322
+ disabled && !showUpdateIconState && "opacity-60",
323
)}
324
onClick={handleAction}
325
>
255
- {action === "install" ? (
256
- <RotateCwIcon className="size-4" />
257
- ) : isUpdateState ? (
258
- <DownloadIcon className="size-4" />
259
- ) : (
260
- <RefreshCwIcon
261
- className={cn("size-4", state?.status === "checking" && "animate-spin")}
262
- />
263
- )}
326
+ <DesktopUpdateStatusIcon
327
+ key={showCheckIcon ? checkAnimationKey : iconStatus}
328
+ downloadPercent={state?.downloadPercent ?? null}
329
+ isCheckAnimating={showCheckIcon && !prefersReducedMotion}
330
+ onCheckAnimationIteration={handleCheckAnimationIteration}
331
+ status={iconStatus}
332
+ />
333
</button>
334
}
335
/>
336
<TooltipPopup
337
align="center"
338
className={
270
- isUpdateState && state?.channel === "nightly" && state.releaseNotes.length > 0
339
+ showUpdateDetails && state?.channel === "nightly" && state.releaseNotes.length > 0
340
? // pointer-events-auto overrides the positioner's pointer-events-none so the
341
// release notes stay open (and scrollable) when the cursor moves into them.
342
"pointer-events-auto max-w-none text-balance"
@@ -275,7 +344,7 @@ function SidebarUpdateControl() {
344
}
345
side="top"
346
style={
278
- isUpdateState
347
+ showUpdateDetails
348
? {
349
background:
350
"color-mix(in srgb, var(--update) 18%, color-mix(in srgb, var(--popover) var(--glass-opacity), transparent))",
@@ -283,9 +352,9 @@ function SidebarUpdateControl() {
352
}
353
: undefined
354
}
286
- variant={isUpdateState ? "glass" : "default"}
355
+ variant={showUpdateDetails ? "glass" : "default"}
356
>
288
- {isUpdateState && state ? (
357
+ {showUpdateDetails && state ? (
358
<SidebarUpdateReleaseNotesTooltip state={state} tooltip={tooltip} />
359
) : (
360
tooltip