@@ -48,6 +48,7 @@ import type {
4848} from "@vegamo/deepcode-core" ;
4949import { SessionManager } from "@vegamo/deepcode-core" ;
5050import { getCompactPromptTokenThreshold } from "@vegamo/deepcode-core" ;
51+ import { writeStdout , writeStdoutLine } from "../../utils/stdio-helpers" ;
5152
5253type View = "chat" | "session-list" | "undo" | "mcp-status" ;
5354
@@ -145,8 +146,8 @@ function App({ projectRoot, initialPrompt, resumeSessionId, onRestart }: AppProp
145146 onAssistantMessage : ( message : SessionMessage ) => {
146147 setMessages ( ( prev ) => [ ...prev , message ] ) ;
147148 if ( rawModeRef . current === RawMode . Raw ) {
148- process . stdout . write ( "\n" ) ;
149- process . stdout . write ( renderMessageToStdout ( message , rawModeRef . current ) + "\n\n" ) ;
149+ writeStdoutLine ( "\n" ) ;
150+ writeStdoutLine ( renderMessageToStdout ( message , rawModeRef . current ) + "\n\n" ) ;
150151 }
151152 } ,
152153 onSessionEntryUpdated : ( entry ) => {
@@ -196,7 +197,7 @@ function App({ projectRoot, initialPrompt, resumeSessionId, onRestart }: AppProp
196197 const resetStaticView = useCallback (
197198 ( loadedMessages : SessionMessage [ ] , options ?: { clearScreen ?: boolean } ) : Promise < void > => {
198199 if ( options ?. clearScreen ) {
199- process . stdout . write ( ANSI_CLEAR_SCREEN ) ;
200+ writeStdout ( ANSI_CLEAR_SCREEN ) ;
200201 }
201202 setMessages ( [ ] ) ;
202203 setWelcomeNonce ( ( n ) => n + 1 ) ;
@@ -298,19 +299,19 @@ function App({ projectRoot, initialPrompt, resumeSessionId, onRestart }: AppProp
298299 const session = activeSessionId ? sessionManager . getSession ( activeSessionId ) : null ;
299300 const resumeHint = buildResumeHintText ( activeSessionId ?? undefined ) ;
300301
301- process . stdout . write ( "\n" ) ;
302+ writeStdoutLine ( "\n" ) ;
302303 if ( showCommand ) {
303- process . stdout . write ( chalk . rgb ( 34 , 154 , 195 ) ( "> /exit " ) ) ;
304- process . stdout . write ( "\n \n") ;
304+ writeStdoutLine ( chalk . rgb ( 34 , 154 , 195 ) ( " > /exit " ) ) ;
305+ writeStdoutLine ( " \n") ;
305306 }
306307 if ( showSummary ) {
307308 const summary = buildExitSummaryText ( { session, sessionId : activeSessionId ?? undefined } ) ;
308- process . stdout . write ( summary ) ;
309- process . stdout . write ( "\n \n") ;
309+ writeStdoutLine ( summary ) ;
310+ writeStdoutLine ( " \n") ;
310311 }
311312 if ( resumeHint ) {
312- process . stdout . write ( resumeHint ) ;
313- process . stdout . write ( "\n" ) ;
313+ writeStdoutLine ( resumeHint ) ;
314+ writeStdoutLine ( "\n" ) ;
314315 }
315316
316317 sessionManager . dispose ( ) ;
@@ -628,7 +629,7 @@ function App({ projectRoot, initialPrompt, resumeSessionId, onRestart }: AppProp
628629 setShowWelcome ( false ) ;
629630 setMessages ( [ ] ) ;
630631 // Clear screen to remove stale formatted text.
631- process . stdout . write ( ANSI_CLEAR_SCREEN ) ;
632+ writeStdout ( ANSI_CLEAR_SCREEN ) ;
632633
633634 setTimeout ( ( ) => {
634635 if ( nextMode === RawMode . Raw ) {
@@ -666,8 +667,8 @@ function App({ projectRoot, initialPrompt, resumeSessionId, onRestart }: AppProp
666667
667668 if ( mode === RawMode . Raw ) {
668669 // In raw mode, re-render all messages directly to stdout at the new width.
669- // Use process. stdout.write instead of writeRef to avoid Ink interference.
670- process . stdout . write ( ANSI_CLEAR_SCREEN ) ;
670+ // Use direct stdout instead of writeRef to avoid Ink interference.
671+ writeStdout ( ANSI_CLEAR_SCREEN ) ;
671672 const activeSessionId = sessionManager . getActiveSessionId ( ) ;
672673 const allMessages = activeSessionId ? loadVisibleMessages ( sessionManager , activeSessionId ) : [ ] ;
673674 renderRawModeMessages ( allMessages , mode ) ;
@@ -898,7 +899,7 @@ function App({ projectRoot, initialPrompt, resumeSessionId, onRestart }: AppProp
898899 ) ;
899900 } }
900901 </ Static >
901- { busy || statusLine ? < StatusLine busy = { busy } text = { statusLine } /> : null }
902+ { ( busy || statusLine ) && ! isExiting ? < StatusLine busy = { busy } text = { statusLine } /> : null }
902903 { errorLine ? (
903904 < Box >
904905 < Text color = "red" > Error: { errorLine } </ Text >
0 commit comments