Merge pull request #423 from chriswritescode-dev/feat/mobile-dictate-with-send

feat(composer): keep the mobile send button and move dictation into the tools menu
This commit is contained in:
Chris Scott authored and GitHub committed 2026-10-12 10:29:26 -04:00
commit bc958a56a5
4 files changed
+73 -3

No files matched your search

@@ -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)
})
})
@@ -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({
<DropdownMenuItem onSelect={onAttachFile} className="pl-8">
<ToolMenuItemContent icon={<Paperclip className="h-4 w-4" />} title="Attach image or PDF" />
</DropdownMenuItem>
{onDictate ? (
<DropdownMenuItem onSelect={onDictate} className="pl-8">
<ToolMenuItemContent icon={<Mic className="h-4 w-4" />} title="Dictate" />
</DropdownMenuItem>
) : null}
</DropdownMenuContent>
</DropdownMenu>
)
@@ -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()
})
})
})
@@ -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 && (
<button
data-submit-prompt
onClick={hasPendingPermissionForSession ? () => setShowDialog(true) : handleSubmit}
disabled={hasPendingPermissionForSession ? false : (!isModelReady || (!prompt.trim() && imageAttachments.length === 0) || (isPromptSubmitPending && !isStreamingResponse))}
disabled={hasPendingPermissionForSession ? false : (!isModelReady || !hasPromptContent || (isPromptSubmitPending && !isStreamingResponse))}
className={`px-4 md:px-5 py-1.5 md:py-2 rounded-lg text-sm font-medium transition-colors dark:border flex-shrink-0 min-w-[52px] ${
hasPendingPermissionForSession
? 'bg-highlight hover:bg-highlight/90 border-highlight text-highlight-foreground ring-highlight/20'
@@ -1673,6 +1678,7 @@ return (
>
<span className="whitespace-nowrap">{hasPendingPermissionForSession ? 'View' : (isStreamingResponse ? 'Queue' : 'Send')}</span>
</button>
)}
</div>
</div>