Merge pull request #3790 from salioglu/fix/3718-sessions-stdin-cleanup

fix(cli): clean up stdin after sessions command readline interface closes
This commit is contained in:
Jeremy McSpadden 2026-04-12 20:18:09 -05:00 committed by GitHub
commit 5c271e72e7

View file

@ -282,6 +282,14 @@ if (cliFlags.messages[0] === 'sessions') {
})
rl.close()
// Clean up stdin state left by readline.createInterface().
// Without this, downstream TUI initialization gets corrupted listeners and exhibits
// duplicate terminal I/O. Match the pattern used after onboarding cleanup.
process.stdin.removeAllListeners('data')
process.stdin.removeAllListeners('keypress')
if (process.stdin.setRawMode) process.stdin.setRawMode(false)
process.stdin.pause()
const choice = parseInt(answer, 10)
if (isNaN(choice) || choice < 1 || choice > toShow.length) {
process.stderr.write(chalk.dim('Cancelled.\n'))