@@ -122,6 +122,156 @@ for (const compact of [true, false]) {
122122 } ) ;
123123}
124124
125+ /**
126+ * FOUND IN DOGFOODING (2026-12-02). Send while dictating did nothing: the button was off until the
127+ * person pressed Stop. Send now stops listening, waits for the last words, and sends them, in one
128+ * press, as Claude Code does. Enter still only stops (above), so the person can read what was heard.
129+ */
130+ for ( const compact of [ true , false ] ) {
131+ test ( `${ compact ? "compact" : "default" } desktop: Send while listening stops, waits for the last words, and sends them in one press` , async ( ) => {
132+ noProvider ( ) ;
133+ const { calls } = installDesktopShell ( desktop ) ;
134+ const sent : string [ ] = [ ] ;
135+ const { view, box } = renderComposer ( compact , sent ) ;
136+ fireEvent . click (
137+ await view . findByRole ( "button" , { name : "Dictate a message" } ) ,
138+ ) ;
139+ await waitFor ( ( ) =>
140+ expect ( box ( ) . textContent ) . toBe ( "Existing draft book a table for two" ) ,
141+ ) ;
142+ const send = view . getByRole ( "button" , {
143+ name : "Send message" ,
144+ } ) as HTMLButtonElement ;
145+ expect ( send . disabled ) . toBe ( false ) ;
146+
147+ fireEvent . click ( send ) ;
148+ // "tonight" is the desktop's last word, handed over only once it was asked to stop.
149+ await waitFor ( ( ) =>
150+ expect ( sent ) . toEqual ( [ "Existing draft book a table for two tonight" ] ) ,
151+ ) ;
152+ await view . findByRole ( "button" , { name : "Dictate a message" } ) ;
153+ expect ( view . queryByRole ( "button" , { name : "Stop dictation" } ) ) . toBeNull ( ) ;
154+ expect ( calls . map ( ( call ) => call . command ) ) . toContain (
155+ "plugin:openbot-desktop|speech_stop" ,
156+ ) ;
157+ expect ( box ( ) . textContent ) . toBe ( "" ) ;
158+ } ) ;
159+ }
160+
161+ test ( "desktop: Send while listening sends the last words even when the Desktop window's channel delivers them out of order" , async ( ) => {
162+ noProvider ( ) ;
163+ const { calls } = installDesktopShell ( { ...desktop , reorder : true } ) ;
164+ const sent : string [ ] = [ ] ;
165+ const { view, box } = renderComposer ( true , sent ) ;
166+ fireEvent . click (
167+ await view . findByRole ( "button" , { name : "Dictate a message" } ) ,
168+ ) ;
169+ await waitFor ( ( ) =>
170+ expect ( box ( ) . textContent ) . toBe ( "Existing draft book a table for two" ) ,
171+ ) ;
172+ fireEvent . click ( view . getByRole ( "button" , { name : "Send message" } ) ) ;
173+ await waitFor ( ( ) =>
174+ expect ( sent ) . toEqual ( [ "Existing draft book a table for two tonight" ] ) ,
175+ ) ;
176+ await view . findByRole ( "button" , { name : "Dictate a message" } ) ;
177+ expect ( calls . map ( ( call ) => call . command ) ) . toEqual ( [
178+ "plugin:openbot-desktop|speech_available" ,
179+ "plugin:openbot-desktop|speech_start" ,
180+ "plugin:openbot-desktop|speech_stop" ,
181+ ] ) ;
182+ } ) ;
183+
184+ test ( "web: Send while Chrome's Web Speech API listens stops it and sends the words" , async ( ) => {
185+ noProvider ( ) ;
186+ installChrome ( null ) ;
187+ const sent : string [ ] = [ ] ;
188+ const { view, box } = renderComposer ( false , sent ) ;
189+ fireEvent . click (
190+ await view . findByRole ( "button" , { name : "Dictate a message" } ) ,
191+ ) ;
192+ await waitFor ( ( ) =>
193+ expect ( box ( ) . textContent ) . toBe (
194+ "Existing draft I am opening the expenses page" ,
195+ ) ,
196+ ) ;
197+ fireEvent . click ( view . getByRole ( "button" , { name : "Send message" } ) ) ;
198+ await waitFor ( ( ) =>
199+ expect ( sent ) . toEqual ( [ "Existing draft I am opening the expenses page" ] ) ,
200+ ) ;
201+ await view . findByRole ( "button" , { name : "Dictate a message" } ) ;
202+ } ) ;
203+
204+ test ( "desktop: Send while listening sends nothing when dictation fails, and says why" , async ( ) => {
205+ noProvider ( ) ;
206+ installDesktopShell ( {
207+ ...desktop ,
208+ atStop : [ { type : "error" , error : "audio-capture" } ] ,
209+ } ) ;
210+ const sent : string [ ] = [ ] ;
211+ const { view, box } = renderComposer ( true , sent ) ;
212+ fireEvent . click (
213+ await view . findByRole ( "button" , { name : "Dictate a message" } ) ,
214+ ) ;
215+ await waitFor ( ( ) =>
216+ expect ( box ( ) . textContent ) . toBe ( "Existing draft book a table for two" ) ,
217+ ) ;
218+ fireEvent . click ( view . getByRole ( "button" , { name : "Send message" } ) ) ;
219+ const alert = await view . findByRole ( "alert" ) ;
220+ expect ( alert . textContent ) . toBe ( liveProblem ( "audio-capture" , "mac" ) ?? "" ) ;
221+ expect ( box ( ) . textContent ) . toBe ( "Existing draft book a table for two" ) ;
222+ await new Promise ( ( resolve ) => setTimeout ( resolve , 20 ) ) ;
223+ expect ( sent ) . toEqual ( [ ] ) ;
224+ } ) ;
225+
226+ test ( "desktop: Send while listening sends nothing when nothing was heard and the box is empty, and says why" , async ( ) => {
227+ noProvider ( ) ;
228+ installDesktopShell ( { heard : [ said ( 0 , "um" ) ] , atStop : [ said ( 0 , "" , true ) ] } ) ;
229+ const sent : string [ ] = [ ] ;
230+ const view = render (
231+ < Composer
232+ compact
233+ onSubmit = { ( draft ) => {
234+ sent . push ( draft . text ) ;
235+ } }
236+ /> ,
237+ ) ;
238+ const box = ( ) => view . getByRole ( "textbox" , { name : "Message" } ) ;
239+ fireEvent . click (
240+ await view . findByRole ( "button" , { name : "Dictate a message" } ) ,
241+ ) ;
242+ await waitFor ( ( ) => expect ( box ( ) . textContent ) . toBe ( "um" ) ) ;
243+ fireEvent . click ( view . getByRole ( "button" , { name : "Send message" } ) ) ;
244+ const alert = await view . findByRole ( "alert" ) ;
245+ expect ( alert . textContent ) . toBe (
246+ "No words were heard, so nothing was sent. Try again." ,
247+ ) ;
248+ await new Promise ( ( resolve ) => setTimeout ( resolve , 20 ) ) ;
249+ expect ( sent ) . toEqual ( [ ] ) ;
250+ } ) ;
251+
252+ test ( "desktop: Send while the system still asks for permission stops waiting and sends the box as it is" , async ( ) => {
253+ noProvider ( ) ;
254+ const { calls } = installDesktopShell ( {
255+ ...desktop ,
256+ availability : "downloading" ,
257+ } ) ;
258+ const sent : string [ ] = [ ] ;
259+ const { view } = renderComposer ( true , sent ) ;
260+ fireEvent . click (
261+ await view . findByRole ( "button" , { name : "Dictate a message" } ) ,
262+ ) ;
263+ await view . findByText (
264+ "Waiting for permission to use the microphone and speech recognition." ,
265+ ) ;
266+ fireEvent . click ( view . getByRole ( "button" , { name : "Send message" } ) ) ;
267+ await waitFor ( ( ) => expect ( sent ) . toEqual ( [ "Existing draft" ] ) ) ;
268+ await view . findByRole ( "button" , { name : "Dictate a message" } ) ;
269+ expect ( view . queryByRole ( "alert" ) ) . toBeNull ( ) ;
270+ expect ( calls . some ( ( call ) => call . command . endsWith ( "|speech_start" ) ) ) . toBe (
271+ false ,
272+ ) ;
273+ } ) ;
274+
125275test ( "desktop: Stop keeps the words in the box and sends nothing" , async ( ) => {
126276 noProvider ( ) ;
127277 installDesktopShell ( desktop ) ;
0 commit comments