@@ -191,6 +191,7 @@ describe('InputPrompt', () => {
191191 setCleanUiDetailsVisible : mockSetCleanUiDetailsVisible ,
192192 toggleCleanUiDetailsVisible : mockToggleCleanUiDetailsVisible ,
193193 revealCleanUiDetailsTemporarily : mockRevealCleanUiDetailsTemporarily ,
194+ addMessage : vi . fn ( ) ,
194195 } ;
195196
196197 beforeEach ( ( ) => {
@@ -352,6 +353,8 @@ describe('InputPrompt', () => {
352353 vi . mocked ( clipboardy . read ) . mockResolvedValue ( '' ) ;
353354
354355 props = {
356+ onQueueMessage : vi . fn ( ) ,
357+
355358 buffer : mockBuffer ,
356359 onSubmit : vi . fn ( ) ,
357360 userMessages : [ ] ,
@@ -1099,6 +1102,76 @@ describe('InputPrompt', () => {
10991102 unmount ( ) ;
11001103 } ) ;
11011104
1105+ it ( 'queues a message when Tab is pressed during generation' , async ( ) => {
1106+ props . buffer . setText ( 'A new prompt' ) ;
1107+ props . streamingState = StreamingState . Responding ;
1108+
1109+ const { stdin, unmount } = await renderWithProviders (
1110+ < InputPrompt { ...props } /> ,
1111+ {
1112+ uiActions,
1113+ } ,
1114+ ) ;
1115+
1116+ await act ( async ( ) => {
1117+ stdin . write ( '\t' ) ;
1118+ } ) ;
1119+
1120+ await waitFor ( ( ) => {
1121+ expect ( props . onQueueMessage ) . toHaveBeenCalledWith ( 'A new prompt' ) ;
1122+ expect ( props . buffer . text ) . toBe ( '' ) ;
1123+ } ) ;
1124+ unmount ( ) ;
1125+ } ) ;
1126+
1127+ it ( 'shows an error when attempting to queue a slash command' , async ( ) => {
1128+ props . buffer . setText ( '/clear' ) ;
1129+ props . streamingState = StreamingState . Responding ;
1130+
1131+ const { stdin, unmount } = await renderWithProviders (
1132+ < InputPrompt { ...props } /> ,
1133+ {
1134+ uiActions,
1135+ } ,
1136+ ) ;
1137+
1138+ await act ( async ( ) => {
1139+ stdin . write ( '\t' ) ;
1140+ } ) ;
1141+
1142+ await waitFor ( ( ) => {
1143+ expect ( props . setQueueErrorMessage ) . toHaveBeenCalledWith (
1144+ 'Slash commands cannot be queued' ,
1145+ ) ;
1146+ expect ( props . onQueueMessage ) . not . toHaveBeenCalled ( ) ;
1147+ } ) ;
1148+ unmount ( ) ;
1149+ } ) ;
1150+
1151+ it ( 'shows an error when attempting to queue a shell command' , async ( ) => {
1152+ props . shellModeActive = true ;
1153+ props . buffer . setText ( 'ls' ) ;
1154+ props . streamingState = StreamingState . Responding ;
1155+
1156+ const { stdin, unmount } = await renderWithProviders (
1157+ < InputPrompt { ...props } /> ,
1158+ {
1159+ uiActions,
1160+ } ,
1161+ ) ;
1162+
1163+ await act ( async ( ) => {
1164+ stdin . write ( '\t' ) ;
1165+ } ) ;
1166+
1167+ await waitFor ( ( ) => {
1168+ expect ( props . setQueueErrorMessage ) . toHaveBeenCalledWith (
1169+ 'Shell commands cannot be queued' ,
1170+ ) ;
1171+ expect ( props . onQueueMessage ) . not . toHaveBeenCalled ( ) ;
1172+ } ) ;
1173+ unmount ( ) ;
1174+ } ) ;
11021175 it ( 'should not submit on Enter when the buffer is empty or only contains whitespace' , async ( ) => {
11031176 props . buffer . setText ( ' ' ) ; // Set buffer to whitespace
11041177
0 commit comments