@@ -151,7 +151,7 @@ process.on("uncaughtException", (error) => {
151151 Logger . shutdown ( ) ;
152152
153153 // Clear screen and show error
154- process . stdout . write ( '\x1bc' ) ; // Clear screen
154+ process . stdout . write ( "\x1b[?1049l" ) ; // Leave alternate screen buffer
155155 console . error ( "Fatal error:" , error . message ) ;
156156 console . error ( `Full stack trace saved to ${ ERROR_LOG_PATH } ` ) ;
157157 console . error ( `Exit details saved to ${ EXIT_LOG_PATH } ` ) ;
@@ -178,7 +178,7 @@ process.on("unhandledRejection", (reason) => {
178178 Logger . shutdown ( ) ;
179179
180180 // Clear screen and show error
181- process . stdout . write ( '\x1bc' ) ; // Clear screen
181+ process . stdout . write ( "\x1b[?1049l" ) ; // Leave alternate screen buffer
182182 console . error ( "Unhandled promise rejection:" , reason ) ;
183183 console . error ( `Full details saved to ${ EXIT_LOG_PATH } ` ) ;
184184
@@ -224,7 +224,7 @@ process.on("SIGTERM", () => {
224224 Logger . shutdown ( ) ;
225225 clearInterval ( heartbeatInterval ) ;
226226
227- process . stdout . write ( '\x1bc' ) ; // Clear screen
227+ process . stdout . write ( "\x1b[?1049l" ) ; // Leave alternate screen buffer
228228 process . exit ( 0 ) ;
229229} ) ;
230230
@@ -238,7 +238,7 @@ process.on("SIGINT", () => {
238238 Logger . shutdown ( ) ;
239239 clearInterval ( heartbeatInterval ) ;
240240
241- process . stdout . write ( '\x1bc' ) ; // Clear screen
241+ process . stdout . write ( "\x1b[?1049l" ) ; // Leave alternate screen buffer
242242 process . exit ( 0 ) ;
243243} ) ;
244244
@@ -252,7 +252,7 @@ process.on("SIGHUP", () => {
252252 Logger . shutdown ( ) ;
253253 clearInterval ( heartbeatInterval ) ;
254254
255- process . stdout . write ( '\x1bc' ) ; // Clear screen
255+ process . stdout . write ( "\x1b[?1049l" ) ; // Leave alternate screen buffer
256256 process . exit ( 0 ) ;
257257} ) ;
258258
@@ -271,7 +271,7 @@ process.on("exit", (code) => {
271271 Logger . shutdown ( ) ;
272272
273273 // Final clear screen
274- process . stdout . write ( '\x1bc' ) ;
274+ process . stdout . write ( "\x1b[?1049l" ) ;
275275} ) ;
276276
277277// Parse CLI arguments
@@ -482,6 +482,9 @@ db.setPacketRetentionLimit(packetLimit);
482482const packetStore = new PacketStore ( packetLimit ) ;
483483const nodeStore = new NodeStore ( ) ;
484484
485+ // Enter alternate screen buffer (prevents scroll contamination in tmux)
486+ process . stdout . write ( "\x1b[?1049h" ) ;
487+
485488const { waitUntilExit } = render (
486489 React . createElement ( App , {
487490 address,
@@ -510,7 +513,7 @@ waitUntilExit()
510513 isShuttingDown = true ;
511514 logExit ( "NORMAL_EXIT" , 0 , { reason : "User quit application" } ) ;
512515 clearInterval ( heartbeatInterval ) ;
513- process . stdout . write ( '\x1bc' ) ; // Clear screen
516+ process . stdout . write ( "\x1b[?1049l" ) ; // Leave alternate screen buffer
514517 }
515518 } )
516519 . catch ( ( e ) => {
@@ -527,7 +530,7 @@ waitUntilExit()
527530 Logger . error ( "Main" , "Application exit error" , error ) ;
528531 Logger . shutdown ( ) ;
529532
530- process . stdout . write ( '\x1bc' ) ; // Clear screen
533+ process . stdout . write ( "\x1b[?1049l" ) ; // Leave alternate screen buffer
531534 console . error ( "Application failed:" , error . message ) ;
532535 console . error ( `Full details saved to ${ EXIT_LOG_PATH } ` ) ;
533536
0 commit comments