mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-06 12:52:11 +00:00
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.
This commit is contained in:
parent
9998ff4cbe
commit
aa07400e1a
1 changed files with 5 additions and 3 deletions
|
|
@ -79,6 +79,8 @@ export function useComposerDraft({
|
|||
activeQueueSessionKeyRef.current = activeQueueSessionKey
|
||||
const sessionIdRef = useRef(sessionId)
|
||||
sessionIdRef.current = sessionId
|
||||
const queueEditStateRef = useRef<QueueEditState | null>(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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue