mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-05 23:19:43 +02:00
fix(respawn): use screen -X stuff for reliable input delivery
When writing to an attached PTY connected to screen, the input doesn't reliably reach Claude CLI. This fix uses `screen -X stuff` command to send input directly to the screen session, bypassing the PTY attachment. Research findings: - Claude CLI uses Ink (React for CLI) for terminal UI - Ink's parseKeypress detects \r as key.return (Enter) - screen -X stuff with $'...' syntax reliably sends literal characters Changes: - Add ScreenManager.sendInput() using screen -X stuff - Modify Session.write() to prefer screen -X stuff when available - Keep \r as Enter key (what Ink expects for key.return) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -457,4 +457,26 @@ export class ScreenManager extends EventEmitter {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Send input directly to screen session using screen -X stuff
|
||||
// This bypasses the attached PTY and sends input directly to the screen
|
||||
sendInput(sessionId: string, input: string): boolean {
|
||||
const screen = this.screens.get(sessionId);
|
||||
if (!screen) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
// Use screen -X stuff with $'...' syntax to send literal characters
|
||||
// \r (carriage return) is what Claude CLI expects for Enter
|
||||
execSync(`screen -S ${screen.screenName} -X stuff $'${input.replace(/'/g, "'\\''")}'`, {
|
||||
encoding: 'utf-8',
|
||||
timeout: 5000
|
||||
});
|
||||
return true;
|
||||
} catch (err) {
|
||||
console.error('[ScreenManager] Failed to send input:', err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user