@@ -310,12 +310,31 @@ describe("TTY bridge", () => {
310310 assert . equal ( ws . sent . at ( - 1 ) . type , "disconnect" ) ;
311311 } ) ;
312312
313- it ( "treats raw Ctrl-D as local EOF after sending EOT to the remote session" , async ( ) => {
313+ it ( "forwards raw Ctrl-D without locally closing the active session" , async ( ) => {
314+ const { bridge, ws, stdin } = bridgeFixture ( ) ;
315+ bridge . start ( ) ;
316+ ws . emit ( "open" ) ;
317+
318+ stdin . write ( Buffer . from ( [ 0x04 ] ) ) ;
319+ await flushImmediate ( ) ;
320+
321+ assert . equal ( bridge . closed , false ) ;
322+ assert . deepEqual ( ws . sent . slice ( 1 ) , [
323+ { type : "input" , data : "\x04" } ,
324+ ] ) ;
325+ assert . deepEqual ( stdin . rawModes , [ true ] ) ;
326+ assert . equal ( stdin . pauseCalls , 0 ) ;
327+
328+ bridge . finish ( 0 ) ;
329+ } ) ;
330+
331+ it ( "exits after Ctrl-D when the remote shell ends the session" , async ( ) => {
314332 const { bridge, ws, stdin } = bridgeFixture ( ) ;
315333 const done = bridge . start ( ) ;
316334 ws . emit ( "open" ) ;
317335
318336 stdin . write ( Buffer . from ( [ 0x04 ] ) ) ;
337+ ws . serverMessage ( { type : "session_ended" , code : 0 } ) ;
319338
320339 assert . equal ( await done , 0 ) ;
321340 assert . deepEqual ( ws . sent . slice ( 1 ) , [
0 commit comments