@@ -88,6 +88,7 @@ describe("executeCommandTool", () => {
8888 recordToolUsage : vitest . fn ( ) . mockReturnValue ( { } as ToolUsage ) ,
8989 recordToolError : vitest . fn ( ) ,
9090 supersedePendingAsk : vitest . fn ( ) ,
91+ processQueuedMessages : vitest . fn ( ) ,
9192 providerRef : {
9293 deref : vitest . fn ( ) . mockResolvedValue ( {
9394 contextProxy : {
@@ -497,6 +498,74 @@ describe("executeCommandTool", () => {
497498 } )
498499 } )
499500
501+ describe ( "Queued message processing" , ( ) => {
502+ it ( "processes queued messages after the command completes" , async ( ) => {
503+ mockToolUse . params . command = "echo test"
504+ mockToolUse . nativeArgs = { command : "echo test" }
505+
506+ await executeCommandTool . handle ( mockCline as unknown as Task , mockToolUse , {
507+ askApproval : mockAskApproval as unknown as AskApproval ,
508+ handleError : mockHandleError as unknown as HandleError ,
509+ pushToolResult : mockPushToolResult as unknown as PushToolResult ,
510+ } )
511+
512+ expect ( mockPushToolResult ) . toHaveBeenCalled ( )
513+ expect ( mockCline . processQueuedMessages ) . toHaveBeenCalledTimes ( 1 )
514+ } )
515+
516+ it ( "processes queued messages after the execa fallback retry completes" , async ( ) => {
517+ const shellError = new executeCommandModule . ShellIntegrationError ( "startup failed" , false )
518+ const failedProcess = Object . assign ( Promise . reject ( shellError ) , {
519+ continue : vitest . fn ( ) ,
520+ abort : vitest . fn ( ) ,
521+ } )
522+ const successfulProcess = Object . assign ( Promise . resolve ( ) , {
523+ continue : vitest . fn ( ) ,
524+ abort : vitest . fn ( ) ,
525+ } )
526+ const successfulTerminalProcess = successfulProcess as unknown as RooTerminalProcess
527+
528+ vitest
529+ . mocked ( TerminalRegistry . getOrCreateTerminal )
530+ . mockResolvedValueOnce ( {
531+ runCommand : vitest . fn ( ) . mockReturnValue ( failedProcess ) ,
532+ getCurrentWorkingDirectory : vitest . fn ( ) . mockReturnValue ( "/test/workspace" ) ,
533+ } as never )
534+ . mockResolvedValueOnce ( {
535+ runCommand : vitest . fn ( ) . mockImplementation ( ( _command : string , callbacks : RooTerminalCallbacks ) => {
536+ void callbacks . onCompleted ?.( "" , successfulTerminalProcess )
537+ callbacks . onShellExecutionComplete ?.( { exitCode : 0 } , successfulTerminalProcess )
538+ return successfulProcess
539+ } ) ,
540+ getCurrentWorkingDirectory : vitest . fn ( ) . mockReturnValue ( "/test/workspace" ) ,
541+ } as never )
542+
543+ await executeCommandTool . handle ( mockCline as unknown as Task , mockToolUse , {
544+ askApproval : mockAskApproval as unknown as AskApproval ,
545+ handleError : mockHandleError as unknown as HandleError ,
546+ pushToolResult : mockPushToolResult as unknown as PushToolResult ,
547+ } )
548+
549+ expect ( mockPushToolResult ) . toHaveBeenCalled ( )
550+ expect ( mockCline . processQueuedMessages ) . toHaveBeenCalledTimes ( 1 )
551+ } )
552+
553+ it ( "does not process queued messages when the user rejects the command" , async ( ) => {
554+ mockAskApproval . mockResolvedValue ( false )
555+ mockToolUse . params . command = "echo test"
556+ mockToolUse . nativeArgs = { command : "echo test" }
557+
558+ await executeCommandTool . handle ( mockCline as unknown as Task , mockToolUse , {
559+ askApproval : mockAskApproval as unknown as AskApproval ,
560+ handleError : mockHandleError as unknown as HandleError ,
561+ pushToolResult : mockPushToolResult as unknown as PushToolResult ,
562+ } )
563+
564+ expect ( mockPushToolResult ) . not . toHaveBeenCalled ( )
565+ expect ( mockCline . processQueuedMessages ) . not . toHaveBeenCalled ( )
566+ } )
567+ } )
568+
500569 describe ( "Command execution timeout configuration" , ( ) => {
501570 it ( "should include timeout parameter in ExecuteCommandOptions" , ( ) => {
502571 // This test verifies that the timeout configuration is properly typed
0 commit comments