From 2f46fde3f51db2db1cb0854ce1bd2b5c07c16a0d Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Tue, 30 Jun 2026 04:27:22 -0500 Subject: [PATCH] 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. --- .../chat/composer/hooks/use-composer-queue.ts | 23 ++++++++++++++----- ui-tui/node_modules | 1 - 2 files changed, 17 insertions(+), 7 deletions(-) delete mode 120000 ui-tui/node_modules diff --git a/apps/desktop/src/app/chat/composer/hooks/use-composer-queue.ts b/apps/desktop/src/app/chat/composer/hooks/use-composer-queue.ts index 7b02cd955ac..c40d56a4826 100644 --- a/apps/desktop/src/app/chat/composer/hooks/use-composer-queue.ts +++ b/apps/desktop/src/app/chat/composer/hooks/use-composer-queue.ts @@ -69,6 +69,14 @@ export function useComposerQueue({ const [queueEdit, setQueueEdit] = useState(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, diff --git a/ui-tui/node_modules b/ui-tui/node_modules deleted file mode 120000 index 001f2a89107..00000000000 --- a/ui-tui/node_modules +++ /dev/null @@ -1 +0,0 @@ -/Users/brooklyn/www/hermes-agent/ui-tui/node_modules \ No newline at end of file