@@ -223,6 +223,9 @@ async function startMockModelServer(
223223 stop : async ( ) => {
224224 await new Promise < void > ( ( resolve , reject ) => {
225225 server . close ( ( error ) => ( error ? reject ( error ) : resolve ( ) ) ) ;
226+ // Aborted local runs can leave a provider keep-alive open. Force-close
227+ // test-owned connections so cleanup does not wait for idle expiry.
228+ server . closeAllConnections ( ) ;
226229 } ) ;
227230 } ,
228231 } ;
@@ -378,7 +381,7 @@ async function startGatewayModeTui(params: {
378381 const tempDir = await mkdtemp ( path . join ( tmpdir ( ) , "openclaw-tui-pty-gateway-" ) ) ;
379382 const workspaceDir = path . join ( tempDir , "workspace" ) ;
380383 const mockModel = await startMockModelServer ( params . firstReplyText ?? "FIRST_RUN_ACTIVE" , {
381- firstResponseDelayMs : params . firstResponseDelayMs ?? 2_500 ,
384+ firstResponseDelayMs : params . firstResponseDelayMs ?? 1_500 ,
382385 followupReplyText : "FOLLOWUP_RUN_COMPLETE" ,
383386 invalidEditLoop : params . invalidEditLoop ,
384387 } ) ;
@@ -750,7 +753,7 @@ describe("TUI PTY real backends", () => {
750753 async ( ) => {
751754 const fixture = await startGatewayModeTui ( {
752755 queueMode : "followup" ,
753- firstResponseDelayMs : 3_000 ,
756+ firstResponseDelayMs : 1_500 ,
754757 } ) ;
755758 try {
756759 await fixture . run . waitForOutput ( "gateway connected" , LOCAL_STARTUP_TIMEOUT_MS ) ;
@@ -765,7 +768,7 @@ describe("TUI PTY real backends", () => {
765768 await sleep ( 150 ) ;
766769 await fixture . run . write ( "\u001b" , { delay : false } ) ;
767770 await fixture . run . waitForOutput ( "aborted" ) ;
768- await sleep ( 3_250 ) ;
771+ await sleep ( 1_750 ) ;
769772
770773 expect ( fixture . mockModel . requests ( ) ) . toHaveLength ( 1 ) ;
771774 expect ( fixture . run . output ( ) ) . not . toContain ( "FOLLOWUP_RUN_COMPLETE" ) ;
@@ -784,8 +787,8 @@ describe("TUI PTY real backends", () => {
784787 async ( ) => {
785788 const fixture = await startGatewayModeTui ( {
786789 queueMode : "collect" ,
787- firstResponseDelayMs : 4_000 ,
788- queueDebounceMs : 1_000 ,
790+ firstResponseDelayMs : 1_500 ,
791+ queueDebounceMs : 250 ,
789792 } ) ;
790793 const queueClient = new GatewayChatClient ( {
791794 url : fixture . gateway . url ,
@@ -804,7 +807,7 @@ describe("TUI PTY real backends", () => {
804807 read : ( ) => ( queueClientConnected ? true : null ) ,
805808 onTimeout : ( ) => new Error ( "TUI Gateway client did not connect" ) ,
806809 } ) ;
807- await fixture . run . write ( "/queue collect debounce:1s \r" , { delay : false } ) ;
810+ await fixture . run . write ( "/queue collect debounce:250ms \r" , { delay : false } ) ;
808811 await fixture . run . waitForOutput ( "Queue mode set to collect." ) ;
809812 await fixture . run . write ( "slow collect parent\r" ) ;
810813 await waitFor ( {
@@ -818,7 +821,7 @@ describe("TUI PTY real backends", () => {
818821 message : "collect prompt alpha" ,
819822 runId : "collect-alpha" ,
820823 } ) ;
821- await sleep ( 100 ) ;
824+ await sleep ( 50 ) ;
822825 const betaSend = queueClient . sendChat ( {
823826 sessionKey : "agent:main:main" ,
824827 message : "collect prompt beta" ,
@@ -834,7 +837,7 @@ describe("TUI PTY real backends", () => {
834837 `collected prompt did not reach the model\n${ fixture . gateway . logs ( ) } \n${ fixture . run . output ( ) } ` ,
835838 ) ,
836839 } ) ;
837- await sleep ( 1_000 ) ;
840+ await sleep ( 500 ) ;
838841
839842 const requests = fixture . mockModel . requests ( ) ;
840843 expect (
0 commit comments