fix(session): separate PTY write from screen -X stuff

Regular user input should go through PTY, only respawn controller
should use screen -X stuff. Added writeViaScreen() method for
programmatic input that needs reliable Enter key delivery.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-01-19 15:35:41 +01:00
co-authored by Claude Opus 4.5
parent a0fc82222f
commit 391438bb22
2 changed files with 18 additions and 15 deletions
+14 -11
View File
@@ -898,23 +898,26 @@ export class Session extends EventEmitter {
}
// Send input to the PTY (for interactive sessions)
// When using screen, prefers screen -X stuff for reliable input delivery
write(data: string): void {
// Try screen -X stuff first if we have a screen session
// This is more reliable for sending Enter key to Claude CLI
if (this._screenManager && this._screenSession) {
const success = this._screenManager.sendInput(this.id, data);
if (success) {
return;
}
// Fall through to PTY write if screen command failed
}
if (this.ptyProcess) {
this.ptyProcess.write(data);
}
}
// Send input via screen -X stuff (for programmatic input like respawn controller)
// This bypasses PTY and sends directly to screen, more reliable for Enter key
writeViaScreen(data: string): boolean {
if (this._screenManager && this._screenSession) {
return this._screenManager.sendInput(this.id, data);
}
// Fallback to PTY write
if (this.ptyProcess) {
this.ptyProcess.write(data);
return true;
}
return false;
}
// Resize the PTY
resize(cols: number, rows: number): void {
if (this.ptyProcess) {