@@ -36,6 +36,7 @@ export class PtyManager {
3636
3737 const state = {
3838 preferredModel : null ,
39+ verboseOutput : false ,
3940 currentWorkdir : this . config . runner . cwd ,
4041 recentWorkdirs : [ this . config . runner . cwd ] ,
4142 ptySupported : null ,
@@ -83,6 +84,18 @@ export class PtyManager {
8384 return args ;
8485 }
8586
87+ isVerbose ( chatId ) {
88+ const state = this . ensureChatState ( chatId ) ;
89+ return Boolean ( state . verboseOutput ) ;
90+ }
91+
92+ setVerbose ( chatId , enabled ) {
93+ const state = this . ensureChatState ( chatId ) ;
94+ state . verboseOutput = Boolean ( enabled ) ;
95+ this . onChange ?. ( this . exportState ( ) ) ;
96+ return state . verboseOutput ;
97+ }
98+
8699 getWorkdir ( chatId ) {
87100 const state = this . ensureChatState ( chatId ) ;
88101 return state . currentWorkdir || this . config . runner . cwd ;
@@ -305,12 +318,14 @@ export class PtyManager {
305318 this . onChange ?. ( this . exportState ( ) ) ;
306319
307320 this . enqueueFlush ( session . chatId ) ;
308- await this . bot . telegram
309- . sendMessage (
310- session . chatId ,
311- `Codex session exited (mode=${ session . mode } , code=${ exitCode } , signal=${ signal } ).`
312- )
313- . catch ( ( ) => { } ) ;
321+ if ( this . isVerbose ( session . chatId ) ) {
322+ await this . bot . telegram
323+ . sendMessage (
324+ session . chatId ,
325+ `Codex session exited (mode=${ session . mode } , code=${ exitCode } , signal=${ signal } ).`
326+ )
327+ . catch ( ( ) => { } ) ;
328+ }
314329 session . throttledFlush ?. cancel ( ) ;
315330 this . sessions . delete ( session . chatId ) ;
316331 } ) ;
@@ -480,7 +495,7 @@ export class PtyManager {
480495 trackConversation : false
481496 } ) ;
482497
483- if ( options . notice ) {
498+ if ( options . notice && this . isVerbose ( chatId ) ) {
484499 await this . bot . telegram . sendMessage ( chatId , options . notice ) ;
485500 }
486501
@@ -527,12 +542,14 @@ export class PtyManager {
527542 workdir : this . getWorkdir ( chatId ) ,
528543 resumeSessionId : projectState . lastSessionId || ""
529544 } ) ;
530- await this . bot . telegram . sendMessage (
531- chatId ,
532- projectState . lastSessionId
533- ? "PTY unavailable on this host. Restoring the current project's Codex conversation in `codex exec resume` mode."
534- : "PTY unavailable on this host. Falling back to `codex exec` mode for this request."
535- ) ;
545+ if ( this . isVerbose ( chatId ) ) {
546+ await this . bot . telegram . sendMessage (
547+ chatId ,
548+ projectState . lastSessionId
549+ ? "PTY unavailable on this host. Restoring the current project's Codex conversation in `codex exec resume` mode."
550+ : "PTY unavailable on this host. Falling back to `codex exec` mode for this request."
551+ ) ;
552+ }
536553 return {
537554 started : true ,
538555 mode : "exec" ,
@@ -541,7 +558,7 @@ export class PtyManager {
541558 } ;
542559 }
543560
544- if ( ! session . streamMessageIds . length ) {
561+ if ( ! session . streamMessageIds . length && this . isVerbose ( chatId ) ) {
545562 const sent = await this . bot . telegram . sendMessage (
546563 chatId ,
547564 projectState . lastSessionId
@@ -647,6 +664,7 @@ export class PtyManager {
647664
648665 chats [ chatId ] = {
649666 preferredModel : state . preferredModel ,
667+ verboseOutput : Boolean ( state . verboseOutput ) ,
650668 currentWorkdir : this . serializeWorkdir ( state . currentWorkdir ) ,
651669 recentWorkdirs : ( state . recentWorkdirs || [ ] ) . map ( ( workdir ) => this . serializeWorkdir ( workdir ) ) ,
652670 projects
@@ -704,6 +722,7 @@ export class PtyManager {
704722
705723 this . chatState . set ( String ( chatId ) , {
706724 preferredModel : rawState ?. preferredModel ?. trim ?. ( ) || null ,
725+ verboseOutput : Boolean ( rawState ?. verboseOutput ) ,
707726 currentWorkdir,
708727 recentWorkdirs : [ currentWorkdir , ...recentWorkdirs . filter ( ( workdir ) => workdir !== currentWorkdir ) ] . slice ( 0 , 6 ) ,
709728 ptySupported : null ,
@@ -726,6 +745,7 @@ export class PtyManager {
726745 lastExitSignal : projectState . lastExitSignal ,
727746 projectSessionId : projectState . lastSessionId || null ,
728747 preferredModel : state . preferredModel ,
748+ verboseOutput : Boolean ( state . verboseOutput ) ,
729749 ptySupported : state . ptySupported ,
730750 workdir : this . getWorkdir ( key ) ,
731751 relativeWorkdir : this . getRelativeWorkdir ( key ) ,
0 commit comments