mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-01 12:02:05 +00:00
fix(desktop): keep queued composer edit ref in sync
Update the shared queued-edit ref synchronously with React state so draft persistence sees the correct edit mode while loading and restoring queued prompts. Also drop the accidental node_modules symlink from the PR.
This commit is contained in:
parent
94d70dee54
commit
2f46fde3f5
2 changed files with 17 additions and 7 deletions
|
|
@ -69,6 +69,14 @@ export function useComposerQueue({
|
|||
const [queueEdit, setQueueEdit] = useState<QueueEditState | null>(null)
|
||||
queueEditRef.current = queueEdit
|
||||
|
||||
const setQueueEditSnapshot = useCallback(
|
||||
(next: QueueEditState | null) => {
|
||||
queueEditRef.current = next
|
||||
setQueueEdit(next)
|
||||
},
|
||||
[queueEditRef]
|
||||
)
|
||||
|
||||
const editingQueuedPrompt = queueEdit ? (queuedPrompts.find(entry => entry.id === queueEdit.entryId) ?? null) : null
|
||||
|
||||
const prevQueueKeyRef = useRef(activeQueueSessionKey)
|
||||
|
|
@ -80,7 +88,7 @@ export function useComposerQueue({
|
|||
return
|
||||
}
|
||||
|
||||
setQueueEdit({
|
||||
setQueueEditSnapshot({
|
||||
attachments: cloneAttachments(attachments),
|
||||
draft: draftRef.current,
|
||||
entryId: entry.id,
|
||||
|
|
@ -114,10 +122,10 @@ export function useComposerQueue({
|
|||
const next = queuedPrompts[target]
|
||||
|
||||
if (next) {
|
||||
setQueueEdit({ ...queueEdit, entryId: next.id })
|
||||
setQueueEditSnapshot({ ...queueEdit, entryId: next.id })
|
||||
loadIntoComposer(next.text, next.attachments)
|
||||
} else {
|
||||
setQueueEdit(null)
|
||||
setQueueEditSnapshot(null)
|
||||
loadIntoComposer(queueEdit.draft, queueEdit.attachments)
|
||||
}
|
||||
|
||||
|
|
@ -146,8 +154,8 @@ export function useComposerQueue({
|
|||
triggerHaptic('cancel')
|
||||
}
|
||||
|
||||
setQueueEditSnapshot(null)
|
||||
loadIntoComposer(queueEdit.draft, queueEdit.attachments)
|
||||
setQueueEdit(null)
|
||||
focusInput()
|
||||
|
||||
return true
|
||||
|
|
@ -319,11 +327,14 @@ export function useComposerQueue({
|
|||
return
|
||||
}
|
||||
|
||||
setQueueEditSnapshot(null)
|
||||
loadIntoComposer(queueEdit.draft, queueEdit.attachments)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
setQueueEdit(null)
|
||||
}, [activeQueueSessionKey, editingQueuedPrompt, queueEdit]) // eslint-disable-line react-hooks/exhaustive-deps
|
||||
setQueueEditSnapshot(null)
|
||||
}, [activeQueueSessionKey, editingQueuedPrompt, queueEdit, setQueueEditSnapshot]) // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
return {
|
||||
beginQueuedEdit,
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
/Users/brooklyn/www/hermes-agent/ui-tui/node_modules
|
||||
Loading…
Add table
Add a link
Reference in a new issue