From aa07400e1a8f37e835714d8a68c1b72e634e3793 Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Tue, 30 Jun 2026 04:33:08 -0500 Subject: [PATCH] chore(desktop): keep draft persist effect deps clean Replace direct queueEditRef reads in cleanup/pagehide with a mirrored local ref so hook deps stay stable and eslint-clean. --- .../src/app/chat/composer/hooks/use-composer-draft.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/desktop/src/app/chat/composer/hooks/use-composer-draft.ts b/apps/desktop/src/app/chat/composer/hooks/use-composer-draft.ts index 058155add2d..5f8bcf8e233 100644 --- a/apps/desktop/src/app/chat/composer/hooks/use-composer-draft.ts +++ b/apps/desktop/src/app/chat/composer/hooks/use-composer-draft.ts @@ -79,6 +79,8 @@ export function useComposerDraft({ activeQueueSessionKeyRef.current = activeQueueSessionKey const sessionIdRef = useRef(sessionId) sessionIdRef.current = sessionId + const queueEditStateRef = useRef(queueEditRef.current) + queueEditStateRef.current = queueEditRef.current const [focusRequestId, setFocusRequestId] = useState(0) @@ -288,7 +290,7 @@ export function useComposerDraft({ return () => { const latestText = syncDraftFromEditor() - const editing = queueEditRef.current + const editing = queueEditStateRef.current if (editing?.sessionKey === activeQueueSessionKey) { stashAt(activeQueueSessionKey, editing.draft, editing.attachments) @@ -303,7 +305,7 @@ export function useComposerDraft({ useEffect(() => { const flushPendingDraftPersist = () => { const scope = activeQueueSessionKeyRef.current - const editing = queueEditRef.current + const editing = queueEditStateRef.current if (editing?.sessionKey === scope || isBrowsingHistory(sessionIdRef.current)) { return @@ -320,7 +322,7 @@ export function useComposerDraft({ window.removeEventListener('pagehide', flushPendingDraftPersist) flushPendingDraftPersist() } - }, [queueEditRef, syncDraftFromEditor]) + }, [syncDraftFromEditor]) return { activeQueueSessionKeyRef,