diff --git a/apps/web/src/components/sidebar/DesktopUpdateCheckIcon.tsx b/apps/web/src/components/sidebar/DesktopUpdateCheckIcon.tsx index 8d04de8086..3a92f704ae 100644 --- a/apps/web/src/components/sidebar/DesktopUpdateCheckIcon.tsx +++ b/apps/web/src/components/sidebar/DesktopUpdateCheckIcon.tsx @@ -1,7 +1,27 @@ import { RefreshCwIcon } from "lucide-react"; +import type { AnimationEventHandler } from "react"; import { cn } from "../../lib/utils"; -export function DesktopUpdateCheckIcon({ isAnimating }: { readonly isAnimating: boolean }) { - return ; +export function shouldContinueDesktopUpdateCheckAnimation({ + isChecking, +}: { + readonly isChecking: boolean; +}) { + return isChecking; +} + +export function DesktopUpdateCheckIcon({ + isAnimating, + onAnimationIteration, +}: { + readonly isAnimating: boolean; + readonly onAnimationIteration?: AnimationEventHandler; +}) { + return ( + + ); } diff --git a/apps/web/src/components/sidebar/SidebarUpdatePill.test.tsx b/apps/web/src/components/sidebar/SidebarUpdatePill.test.tsx index c52861979c..8e59521306 100644 --- a/apps/web/src/components/sidebar/SidebarUpdatePill.test.tsx +++ b/apps/web/src/components/sidebar/SidebarUpdatePill.test.tsx @@ -1,18 +1,37 @@ import { renderToStaticMarkup } from "react-dom/server"; import { describe, expect, it } from "vite-plus/test"; -import { DesktopUpdateCheckIcon } from "./DesktopUpdateCheckIcon"; +import { + DesktopUpdateCheckIcon, + shouldContinueDesktopUpdateCheckAnimation, +} from "./DesktopUpdateCheckIcon"; describe("DesktopUpdateCheckIcon", () => { it("keeps the refresh icon spinning while a fast update check settles", () => { const markup = renderToStaticMarkup(); - expect(markup).toContain("animate-spin-once"); + expect(markup).toContain("animate-spin"); }); it("does not animate while idle", () => { const markup = renderToStaticMarkup(); - expect(markup).not.toContain("animate-spin-once"); + expect(markup).not.toContain("animate-spin"); + }); + + it("keeps status-driven checks spinning across rotations", () => { + expect( + shouldContinueDesktopUpdateCheckAnimation({ + isChecking: true, + }), + ).toBe(true); + }); + + it("releases the manual animation latch after one rotation", () => { + expect( + shouldContinueDesktopUpdateCheckAnimation({ + isChecking: false, + }), + ).toBe(false); }); }); diff --git a/apps/web/src/components/sidebar/SidebarUpdatePill.tsx b/apps/web/src/components/sidebar/SidebarUpdatePill.tsx index f586b4e56a..92fa267a8e 100644 --- a/apps/web/src/components/sidebar/SidebarUpdatePill.tsx +++ b/apps/web/src/components/sidebar/SidebarUpdatePill.tsx @@ -1,5 +1,5 @@ import { DownloadIcon, RotateCwIcon, TriangleAlertIcon } from "lucide-react"; -import { useCallback, useState } from "react"; +import { useCallback, useEffect, useState } from "react"; import { isElectron } from "../../env"; import { cn } from "../../lib/utils"; import { ensureLocalApi } from "../../localApi"; @@ -21,7 +21,10 @@ import { Alert, AlertDescription, AlertTitle } from "../ui/alert"; import { Separator } from "../ui/separator"; import { SidebarMenuItem } from "../ui/sidebar"; import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip"; -import { DesktopUpdateCheckIcon } from "./DesktopUpdateCheckIcon"; +import { + DesktopUpdateCheckIcon, + shouldContinueDesktopUpdateCheckAnimation, +} from "./DesktopUpdateCheckIcon"; function keyReleaseNoteItems(items: ReadonlyArray) { const occurrences = new Map(); @@ -111,7 +114,11 @@ export function SidebarUpdatePill() { function SidebarUpdateControl() { const state = useDesktopUpdateState(); const [isActionPending, setIsActionPending] = useState(false); - const [checkAnimationKey, setCheckAnimationKey] = useState(0); + const [isCheckIconAnimating, setIsCheckIconAnimating] = useState(false); + + useEffect(() => { + if (state?.status === "checking") setIsCheckIconAnimating(true); + }, [state?.status]); const action = state ? resolveDesktopUpdateButtonAction(state) : "none"; const isDownloading = state?.status === "downloading"; @@ -211,7 +218,7 @@ function SidebarUpdateControl() { return; } - setCheckAnimationKey((key) => key + 1); + setIsCheckIconAnimating(true); void bridge .checkForUpdate() .then((result) => { @@ -237,6 +244,12 @@ function SidebarUpdateControl() { .finally(() => setIsActionPending(false)); }, [action, disabled, isActionPending, state]); + const handleCheckAnimationIteration = useCallback(() => { + setIsCheckIconAnimating( + shouldContinueDesktopUpdateCheckAnimation({ isChecking: state?.status === "checking" }), + ); + }, [state?.status]); + return ( @@ -261,8 +274,8 @@ function SidebarUpdateControl() { ) : ( 0 || state?.status === "checking"} + isAnimating={isCheckIconAnimating} + onAnimationIteration={handleCheckAnimationIteration} /> )} diff --git a/apps/web/src/index.css b/apps/web/src/index.css index 20f1a00c9d..340a94d00c 100644 --- a/apps/web/src/index.css +++ b/apps/web/src/index.css @@ -140,7 +140,6 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil } @theme inline { - --animate-spin-once: spin 1s linear 1; --color-zinc-25: oklch(99.2% 0 0); --animate-skeleton: skeleton 2s infinite linear; /* Duty-cycled indicator animations: long holds with stepped ramps, so the