From a3269930cc60d6f8981a13e844a2e19db5108769 Mon Sep 17 00:00:00 2001 From: Chris Scott <> Date: Mon, 12 Oct 2026 13:54:36 +0000 Subject: [PATCH] feat(composer): keep the mobile send button and move dictation into the tools menu --- .../message/ComposerToolsMenu.test.tsx | 23 +++++++++++++ .../components/message/ComposerToolsMenu.tsx | 9 ++++- .../message/PromptInput.stt.test.tsx | 34 +++++++++++++++++++ .../src/components/message/PromptInput.tsx | 10 ++++-- 4 files changed, 73 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/message/ComposerToolsMenu.test.tsx b/frontend/src/components/message/ComposerToolsMenu.test.tsx index 053d4240..72140f0d 100644 --- a/frontend/src/components/message/ComposerToolsMenu.test.tsx +++ b/frontend/src/components/message/ComposerToolsMenu.test.tsx @@ -125,4 +125,27 @@ describe('ComposerToolsMenu', () => { expect(props.onAttachFile).toHaveBeenCalledTimes(1) }) + + it('omits the dictate item when onDictate is not provided', async () => { + const user = userEvent.setup() + mockPermissionMode() + renderMenu() + + await user.click(screen.getByRole('button', { name: 'Composer options' })) + await screen.findByRole('menuitem', { name: 'Attach image or PDF' }) + + expect(screen.queryByRole('menuitem', { name: 'Dictate' })).not.toBeInTheDocument() + }) + + it('starts dictation when onDictate is provided', async () => { + const user = userEvent.setup() + mockPermissionMode() + const onDictate = vi.fn() + renderMenu({ onDictate }) + + await user.click(screen.getByRole('button', { name: 'Composer options' })) + await user.click(await screen.findByRole('menuitem', { name: 'Dictate' })) + + expect(onDictate).toHaveBeenCalledTimes(1) + }) }) diff --git a/frontend/src/components/message/ComposerToolsMenu.tsx b/frontend/src/components/message/ComposerToolsMenu.tsx index fb93b8de..2eca8b33 100644 --- a/frontend/src/components/message/ComposerToolsMenu.tsx +++ b/frontend/src/components/message/ComposerToolsMenu.tsx @@ -1,5 +1,5 @@ import type { ReactNode } from 'react' -import { Paperclip, Plus, Shield, ShieldCheck, Target } from 'lucide-react' +import { Mic, Paperclip, Plus, Shield, ShieldCheck, Target } from 'lucide-react' import { DropdownMenu, DropdownMenuCheckboxItem, @@ -19,6 +19,7 @@ interface ComposerToolsMenuProps { goalLabel: string onToggleGoal: () => void onAttachFile: () => void + onDictate?: () => void } export function ComposerToolsMenu({ @@ -29,6 +30,7 @@ export function ComposerToolsMenu({ goalLabel, onToggleGoal, onAttachFile, + onDictate, }: ComposerToolsMenuProps) { const permission = usePermissionModeToggle(sessionID, directory) @@ -67,6 +69,11 @@ export function ComposerToolsMenu({ } title="Attach image or PDF" /> + {onDictate ? ( + + } title="Dictate" /> + + ) : null} ) diff --git a/frontend/src/components/message/PromptInput.stt.test.tsx b/frontend/src/components/message/PromptInput.stt.test.tsx index b7a786f3..a6314b7e 100644 --- a/frontend/src/components/message/PromptInput.stt.test.tsx +++ b/frontend/src/components/message/PromptInput.stt.test.tsx @@ -554,4 +554,38 @@ describe('PromptInput STT Gesture Tests', () => { expect(screen.getByText('Latest')).toBeInTheDocument() }) }) + + describe('mobile voice vs submit button', () => { + const queryMobileVoiceButton = () => { + const voiceButtons = screen.getAllByRole('button').filter((btn) => { + const title = (btn.getAttribute('title') || '').toLowerCase() + return title.includes('tap to speak') || title.includes('tap to transcribe') || title.includes('hold to speak') || title.includes('release') + }) + return voiceButtons.find((btn) => btn.className.includes('px-4') && btn.className.includes('py-2')) ?? null + } + + it('shows the mobile mic and no submit button when the prompt is empty', () => { + renderComponent() + + expect(queryMobileVoiceButton()).not.toBeNull() + expect(screen.queryByTitle('Send')).not.toBeInTheDocument() + }) + + it('shows the submit button and hides the mobile mic once the prompt has content', () => { + renderComponent() + + fireEvent.change(screen.getByPlaceholderText('Send a message...'), { target: { value: 'hello' } }) + + expect(screen.getByTitle('Send')).toBeInTheDocument() + expect(queryMobileVoiceButton()).toBeNull() + }) + + it('keeps the mobile mic visible while recording even with prompt content', () => { + renderComponent({ isRecording: true }) + + fireEvent.change(screen.getByPlaceholderText('Send a message...'), { target: { value: 'hello' } }) + + expect(queryMobileVoiceButton()).not.toBeNull() + }) + }) }) diff --git a/frontend/src/components/message/PromptInput.tsx b/frontend/src/components/message/PromptInput.tsx index 4612af3e..28916804 100644 --- a/frontend/src/components/message/PromptInput.tsx +++ b/frontend/src/components/message/PromptInput.tsx @@ -1366,6 +1366,9 @@ if (isIOS && isSecureContext && navigator.clipboard && navigator.clipboard.read) ? 'sending' : null const showVoiceFeedback = voiceFeedbackState !== null + const hasPromptContent = prompt.trim().length > 0 || imageAttachments.length > 0 + const canUseMobileVoice = isMobile && sttEnabled && sttSupported && !hasPendingPermissionForSession + const showMobileVoiceButton = canUseMobileVoice && (!hasPromptContent || showVoiceFeedback) const voiceFeedbackLabel = voiceFeedbackState === 'starting' ? 'Starting microphone...' : voiceFeedbackState === 'sending' @@ -1652,18 +1655,20 @@ return ( goalLabel={goalButtonLabel} onToggleGoal={toggleGoalArmed} onAttachFile={openFilePicker} + onDictate={canUseMobileVoice && hasPromptContent && !showVoiceFeedback ? () => void startVoiceRecording() : undefined} /> )} {sttEnabled && sttSupported && ( renderVoiceButton('desktop') )} - {isMobile && sttEnabled && sttSupported && !hasPendingPermissionForSession && ( + {showMobileVoiceButton && ( renderVoiceButton('mobile') )} + {!showMobileVoiceButton && ( + )}