From 3669fa3095332aac421b75adcf52ea99ea518a8a Mon Sep 17 00:00:00 2001 From: beplee Date: Tue, 25 Aug 2026 05:39:40 +0700 Subject: [PATCH] =?UTF-8?q?fix(desktop):=20satisfy=20lint=20=E2=80=94=20re?= =?UTF-8?q?ad=20busy=20atom=20directly=20in=20tile=20reconcile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI caught two lint issues in the tile-reconcile path: - no-restricted-syntax: don't mirror the $busy atom into a ref via useEffect (stale-read hazard); reconcileTileTranscripts now receives a live getter view so the loop reads the current value at tick time. - react-hooks/exhaustive-deps: add updateSessionState to the sessions.changed effect deps (stable useCallback from useSessionStateCache, so no extra re-subscription). No behavioral change: regression tests 2/2, adjacent hook suite 58/58, typecheck clean. --- .../src/app/contrib/hooks/use-background-sync.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/desktop/src/app/contrib/hooks/use-background-sync.ts b/apps/desktop/src/app/contrib/hooks/use-background-sync.ts index 33861a1deb..e3d48ae1b5 100644 --- a/apps/desktop/src/app/contrib/hooks/use-background-sync.ts +++ b/apps/desktop/src/app/contrib/hooks/use-background-sync.ts @@ -490,10 +490,10 @@ export function useBackgroundSync({ // transcript signatures, so no-change ticks and closed tiles cost nothing. const tileRequestSequenceRef = useRef(0) const tileSignatureRef = useRef(new Map()) - const activeTranscriptBusyRef = useRef(false) - useEffect(() => { - activeTranscriptBusyRef.current = activeTranscriptBusy - }, [activeTranscriptBusy]) + // Read $busy.get() directly inside the reconcile loop instead of mirroring + // the atom into a ref (lint: no-restricted-syntax — refs synced from atoms + // lag one render). The reconcile runs on tick, not render, so .get() is + // always current. const requestActiveTranscriptRefresh = useCallback( (preservePending: boolean) => { @@ -639,7 +639,7 @@ export function useBackgroundSync({ // (#93942 scenario A). Signature-gated per tile, so no-change ticks // cost nothing. void reconcileTileTranscripts({ - busyRef: activeTranscriptBusyRef, + busyRef: { get current() { return $busy.get() } }, requestSequenceRef: tileRequestSequenceRef, signatureRef: tileSignatureRef, updateSessionState @@ -666,7 +666,7 @@ export function useBackgroundSync({ window.clearTimeout(timer) } } - }, [changeEventsAvailable, gatewayState, refreshMessagingSessions, refreshSessions, requestActiveTranscriptRefresh]) + }, [changeEventsAvailable, gatewayState, refreshMessagingSessions, refreshSessions, requestActiveTranscriptRefresh, updateSessionState]) // Keep the cron-jobs section live without a user action (scheduler ticks in // the background). cron.changed (jobs.json moved: CRUD or a scheduler tick's