@@ -42,29 +42,39 @@ export class SessionLifecycleManager {
4242 }
4343
4444 private spawnProcess ( session : PTYSession ) : void {
45+ console . log ( 'Spawning PTY process for command:' , session . command , 'args:' , session . args )
4546 const env = { ...process . env , ...session . env } as Record < string , string >
46- const ptyProcess : IPty = spawn ( session . command , session . args , {
47- name : 'xterm-256color' ,
48- cols : DEFAULT_TERMINAL_COLS ,
49- rows : DEFAULT_TERMINAL_ROWS ,
50- cwd : session . workdir ,
51- env,
52- } )
53- session . process = ptyProcess
54- session . pid = ptyProcess . pid
47+ try {
48+ const ptyProcess : IPty = spawn ( session . command , session . args , {
49+ name : 'xterm-256color' ,
50+ cols : DEFAULT_TERMINAL_COLS ,
51+ rows : DEFAULT_TERMINAL_ROWS ,
52+ cwd : session . workdir ,
53+ env,
54+ } )
55+ console . log ( 'PTY process spawned with pid:' , ptyProcess . pid )
56+ session . process = ptyProcess
57+ session . pid = ptyProcess . pid
58+ } catch ( error ) {
59+ console . error ( 'Failed to spawn PTY process:' , error )
60+ throw error
61+ }
5562 }
5663
5764 private setupEventHandlers (
5865 session : PTYSession ,
5966 onData : ( id : string , data : string ) => void ,
6067 onExit : ( id : string , exitCode : number | null ) => void
6168 ) : void {
69+ console . log ( 'Setting up event handlers for session:' , session . id )
6270 session . process ! . onData ( ( data : string ) => {
71+ console . log ( 'PTY onData for session' , session . id , 'data length:' , data . length )
6372 session . buffer . append ( data )
6473 onData ( session . id , data )
6574 } )
6675
6776 session . process ! . onExit ( ( { exitCode } ) => {
77+ console . log ( 'PTY onExit for session' , session . id , 'exitCode:' , exitCode )
6878 // Flush any remaining incomplete line in the buffer
6979 session . buffer . flush ( )
7080
@@ -134,7 +144,16 @@ export class SessionLifecycleManager {
134144 }
135145
136146 getSession ( id : string ) : PTYSession | null {
137- return this . sessions . get ( id ) || null
147+ const session = this . sessions . get ( id ) || null
148+ console . log ( 'SessionLifecycle getSession for id:' , id , 'found:' , ! ! session )
149+ if ( session )
150+ console . log ( 'Session details:' , {
151+ id : session . id ,
152+ pid : session . pid ,
153+ status : session . status ,
154+ process : ! ! session . process ,
155+ } )
156+ return session
138157 }
139158
140159 listSessions ( ) : PTYSession [ ] {
0 commit comments