From 614eb4d24653647e4f98dbe5409552c2f872f72b Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Tue, 15 Sep 2026 08:47:05 -0400 Subject: [PATCH] fix(desktop): remember the manual update-check result across Settings open/close The status was component state in the settings tab, so closing Settings threw away "update available" and forced another check. Move it to a module-level atom shared by the settings panel and the update toast. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA --- src/app/hooks/useTauriUpdater.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/app/hooks/useTauriUpdater.ts b/src/app/hooks/useTauriUpdater.ts index 051a40d6a..0ae050145 100644 --- a/src/app/hooks/useTauriUpdater.ts +++ b/src/app/hooks/useTauriUpdater.ts @@ -1,4 +1,5 @@ -import { useState, useCallback } from 'react'; +import { useCallback } from 'react'; +import { atom, useAtom } from 'jotai'; type TauriInternals = { invoke: (cmd: string, args?: Record) => Promise }; const tauriInvoke = (): TauriInternals['invoke'] | undefined => @@ -12,9 +13,16 @@ type UpdateStatus = | { state: 'installing' } | { state: 'error'; message: string }; +// Module-level so the result of a manual "Check for updates" survives closing +// and reopening Settings (it used to be component state, so the "update +// available" answer was thrown away with the tab and had to be re-checked). +// A transient 'checking'/'installing' state is reset if the tab unmounts +// mid-request by the resolve/reject below, so nothing gets stuck. +const updateStatusAtom = atom({ state: 'idle' }); + export function useTauriUpdater() { const isTauri = !!tauriInvoke(); - const [status, setStatus] = useState({ state: 'idle' }); + const [status, setStatus] = useAtom(updateStatusAtom); const check = useCallback(async () => { const invoke = tauriInvoke(); @@ -30,7 +38,7 @@ export function useTauriUpdater() { } catch (e) { setStatus({ state: 'error', message: String(e) }); } - }, []); + }, [setStatus]); const install = useCallback(async () => { const invoke = tauriInvoke(); @@ -45,7 +53,7 @@ export function useTauriUpdater() { } catch (e) { setStatus({ state: 'error', message: String(e) }); } - }, []); + }, [setStatus]); return { isTauri, status, check, install }; }