The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: retain newer composer scope across delayed queue acknowledgements
Teknium4b39a5fd64d3
diff --git a/apps/desktop/src/app/chat/composer/hooks/use-composer-queue.test.tsx b/apps/desktop/src/app/chat/composer/hooks/use-composer-queue.test.tsxindex 065ce1b6507..5bdd3ee0334 100644--- a/apps/desktop/src/app/chat/composer/hooks/use-composer-queue.test.tsx+++ b/apps/desktop/src/app/chat/composer/hooks/use-composer-queue.test.tsx@@ -94,6 +94,25 @@ describe('useComposerQueue park integration', () => {} finally { $connection.set(null) }})+ it('does not clear the next session draft when a queue ACK arrives after navigation', async () => {+ $connection.set({ mode: 'local', wsUrl: 'ws://localhost/api/ws?native_dial=unminted' } as HermesConnection)+ let accept!: (value: boolean) => void+ const clearDraft = vi.fn()+ const draftRef = { current: 'same text' }+ const hook = renderHook(({ key }) => useComposerQueue({+ activeQueueSessionKey: key, attachments: [], busy: true, clearDraft, draftRef,+ focusInput: () => undefined, loadIntoComposer: () => undefined, onCancel: vi.fn(), onSteer: undefined,+ onSubmit: () => new Promise<boolean>(resolve => { accept = resolve }), queueEditRef: { current: null }, queueSessionKey: key, sessionId: key+ }), { initialProps: { key: 'outgoing' } })+ try {+ let pending: boolean | Promise<boolean> = false+ act(() => { pending = hook.result.current.queueCurrentDraft() })+ hook.rerender({ key: 'incoming' })+ await act(async () => { accept(true); await pending })+ expect(clearDraft).not.toHaveBeenCalled()+ } finally { $connection.set(null) }+ })+it('reschedules rejected foreground drains to a bounded stop and keeps manual recovery', async () => {vi.useFakeTimers()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.tsindex bfc0aa1fdb4..19a6e57989c 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@@ -95,6 +95,8 @@ export function useComposerQueue({const editingQueuedPrompt = queueEdit ? (queuedPrompts.find(entry => entry.id === queueEdit.entryId) ?? null) : null+ const currentQueueKeyRef = useRef(activeQueueSessionKey)+ currentQueueKeyRef.current = activeQueueSessionKeyconst prevQueueKeyRef = useRef(activeQueueSessionKey)const drainingQueueRef = useRef(false)const drainFailuresRef = useRef(new Map<string, number>())@@ -193,7 +195,10 @@ export function useComposerQueue({sessionId: sessionId ?? null, storedSessionId: activeQueueSessionKey})).then(accepted => {if (accepted !== true) { return false }- if (draftRef.current === text) { clearDraft(); scope.attachments.clear() }+ if (currentQueueKeyRef.current === activeQueueSessionKey && draftRef.current === text) {+ clearDraft()+ scope.attachments.removeOccurrences(attachments)+ }return true}).catch(() => false)}