The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(desktop): cover the busy empty-Enter double-send
Brooklyn Nicholsonac8310bcc296
diff --git a/apps/desktop/src/app/chat/composer/enter-submit-dom-race.test.tsx b/apps/desktop/src/app/chat/composer/enter-submit-dom-race.test.tsxindex ff01bf6fd37..5e914dc194b 100644--- a/apps/desktop/src/app/chat/composer/enter-submit-dom-race.test.tsx+++ b/apps/desktop/src/app/chat/composer/enter-submit-dom-race.test.tsx@@ -29,7 +29,8 @@ function Harness({onSubmit,onQueue,onCancel,- onDrain+ onDrain,+ onSendNow}: {busy?: booleandisabled?: boolean@@ -38,6 +39,7 @@ function Harness({onQueue: (text: string) => voidonCancel: () => voidonDrain: () => void+ onSendNow?: (id: string) => void}) {const editorRef = useRef<HTMLDivElement>(null)const draftRef = useRef('')@@ -103,6 +105,12 @@ function Harness({}if (busy && !hasLivePayload) {+ const head = queued[0]++ if (head) {+ onSendNow?.(head)+ }+return}@@ -167,13 +175,21 @@ describe('composer Enter submit — live DOM vs stale composer state (#39630)',expect(onCancel).not.toHaveBeenCalled()})- it('treats an empty Enter while busy as a no-op (never an accidental Stop)', async () => {+ it('treats an empty Enter while busy with nothing queued as a no-op (never an accidental Stop)', async () => {const onCancel = vi.fn()const onSubmit = vi.fn()const onQueue = vi.fn()+ const onSendNow = vi.fn()const { getByTestId } = render(- <Harness busy onCancel={onCancel} onDrain={vi.fn()} onQueue={onQueue} onSubmit={onSubmit} />+ <Harness+ busy+ onCancel={onCancel}+ onDrain={vi.fn()}+ onQueue={onQueue}+ onSendNow={onSendNow}+ onSubmit={onSubmit}+ />)const editor = getByTestId('editor')@@ -186,6 +202,35 @@ describe('composer Enter submit — live DOM vs stale composer state (#39630)',expect(onCancel).not.toHaveBeenCalled()expect(onSubmit).not.toHaveBeenCalled()expect(onQueue).not.toHaveBeenCalled()+ expect(onSendNow).not.toHaveBeenCalled()+ })++ it('double-send: an empty Enter while busy with a queued turn sends that turn now', async () => {+ const onCancel = vi.fn()+ const onSendNow = vi.fn()++ const { getByTestId } = render(+ <Harness+ busy+ onCancel={onCancel}+ onDrain={vi.fn()}+ onQueue={vi.fn()}+ onSendNow={onSendNow}+ onSubmit={vi.fn()}+ queued={['queued-1', 'queued-2']}+ />+ )++ const editor = getByTestId('editor')++ await act(async () => {+ editor.textContent = ''+ fireEvent.keyDown(editor, { key: 'Enter' })+ })++ // Head of the queue, and NOT a bare cancel — send-now promotes + interrupts.+ expect(onSendNow).toHaveBeenCalledWith('queued-1')+ expect(onCancel).not.toHaveBeenCalled()})it('drains the next queued prompt on Enter when idle with a truly empty editor', async () => {