@@ -16,6 +16,7 @@ export class SessionLifecycleManager {
1616 private sessions : Map < string , PTYSession > = new Map ( )
1717
1818 private createSessionObject ( opts : SpawnOptions ) : PTYSession {
19+ console . log ( 'Creating session object with opts:' , opts )
1920 const id = generateId ( )
2021 const args = opts . args ?? [ ]
2122 const workdir = opts . workdir ?? process . cwd ( )
@@ -39,10 +40,12 @@ export class SessionLifecycleManager {
3940 buffer,
4041 process : null , // will be set
4142 }
43+ console . log ( 'Session object created:' , session )
4244 return session
4345 }
4446
4547 private spawnProcess ( session : PTYSession ) : void {
48+ console . log ( 'Spawning PTY process for command:' , session . command , 'args:' , session . args )
4649 const env = { ...process . env , ...session . env } as Record < string , string >
4750 try {
4851 const ptyProcess : IPty = spawn ( session . command , session . args , {
@@ -52,8 +55,15 @@ export class SessionLifecycleManager {
5255 cwd : session . workdir ,
5356 env,
5457 } )
58+ console . log ( 'PTY process spawned with pid:' , ptyProcess . pid )
5559 session . process = ptyProcess
5660 session . pid = ptyProcess . pid
61+ console . log ( 'Session after spawn:' , {
62+ id : session . id ,
63+ pid : session . pid ,
64+ command : session . command ,
65+ status : session . status ,
66+ } )
5767 } catch ( error ) {
5868 console . error ( 'Failed to spawn PTY process:' , error )
5969 throw error
@@ -65,12 +75,15 @@ export class SessionLifecycleManager {
6575 onData : ( id : string , data : string ) => void ,
6676 onExit : ( id : string , exitCode : number | null ) => void
6777 ) : void {
78+ console . log ( 'Setting up event handlers for session:' , session . id )
6879 session . process ! . onData ( ( data : string ) => {
80+ console . log ( 'PTY onData for session' , session . id , 'data length:' , data . length )
6981 session . buffer . append ( data )
7082 onData ( session . id , data )
7183 } )
7284
7385 session . process ! . onExit ( ( { exitCode } ) => {
86+ console . log ( 'PTY onExit for session' , session . id , 'exitCode:' , exitCode )
7487 // Flush any remaining incomplete line in the buffer
7588 session . buffer . flush ( )
7689
@@ -141,6 +154,16 @@ export class SessionLifecycleManager {
141154
142155 getSession ( id : string ) : PTYSession | null {
143156 const session = this . sessions . get ( id ) || null
157+ console . log ( 'SessionLifecycle getSession for id:' , id , 'found:' , ! ! session )
158+ if ( session )
159+ console . log ( 'Session details:' , {
160+ id : session . id ,
161+ pid : session . pid ,
162+ status : session . status ,
163+ process : ! ! session . process ,
164+ command : session . command ,
165+ args : session . args ,
166+ } )
144167 return session
145168 }
146169
0 commit comments