Skip to content

Commit 3eb7e2f

Browse files
committed
feat(debug): re-add console.log for CI PTY debugging
1 parent 021b49a commit 3eb7e2f

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/plugin/pty/SessionLifecycle.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/plugin/pty/manager.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,36 @@ class PTYManager {
4141
}
4242

4343
spawn(opts: SpawnOptions): PTYSessionInfo {
44+
console.log('Manager spawn called with opts:', opts)
4445
const session = this.lifecycleManager.spawn(
4546
opts,
4647
(id, data) => {
48+
console.log('Manager onData callback for id:', id, 'data length:', data.length)
4749
notifyRawOutput(id, data)
4850
},
4951
async (id, exitCode) => {
52+
console.log('Manager onExit callback for id:', id, 'exitCode:', exitCode)
5053
if (onSessionUpdate) onSessionUpdate()
5154
const session = this.lifecycleManager.getSession(id)
5255
if (session && session.notifyOnExit) {
5356
await this.notificationManager.sendExitNotification(session, exitCode || 0)
5457
}
5558
}
5659
)
60+
console.log('Manager spawn returning session:', session)
5761
if (onSessionUpdate) onSessionUpdate()
5862
return session
5963
}
6064

6165
write(id: string, data: string): boolean {
66+
console.log('Manager write called for id:', id, 'data:', data)
6267
const result = withSession(
6368
this.lifecycleManager,
6469
id,
6570
(session) => this.outputManager.write(session, data),
6671
false
6772
)
73+
console.log('Manager write result:', result)
6874
return result
6975
}
7076

@@ -96,6 +102,7 @@ class PTYManager {
96102
id,
97103
(session) => {
98104
const info = this.lifecycleManager.toInfo(session)
105+
console.log('Manager get returning info:', info)
99106
return info
100107
},
101108
null

0 commit comments

Comments
 (0)