mirror of
https://github.com/anomalyco/opentui.git
synced 2026-04-25 13:06:00 +03:00
[PR #331] [MERGED] fix: stdin handling on suspend/resume #1241
Labels
No labels
bug
core
documentation
feature
good first issue
help wanted
pull-request
question
react
solid
tmux
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/opentui#1241
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/anomalyco/opentui/pull/331
Author: @veracioux
Created: 11/21/2025
Status: ✅ Merged
Merged: 11/22/2025
Merged by: @kommander
Base:
main← Head:fix/suspend-resume-stdin📝 Commits (5)
af3e768fix: stdin handling on suspend/resumecd8a76bfix: Prevent consuming first keystroke after resume14576catest: Fix tests9820514style: Fix formatting78d67e3test: Fix palette tests📊 Changes
3 files changed (+21 additions, -10 deletions)
View changed files
📝
packages/core/src/renderer.ts(+9 -3)📝
packages/core/src/tests/renderer.control.test.ts(+5 -2)📝
packages/core/src/tests/renderer.palette.test.ts(+7 -5)📄 Description
Fixes https://github.com/sst/opencode/issues/4586.
Fixes https://github.com/sst/opencode/issues/4209.
Cause
When the editor is running in opencode, both it and opencode are reading from stdin, because stdin.pause() was removed from renderer.suspend. This means that the editor and opencode compete to receive keystrokes.
Fix
Do stdin.pause() like before, but to prevent buffered input on resume, consume everything synchronously before reattaching renderer's stdin listener. I believe this is a universal and foolproof fix.
Testing
I tested this change in opencode, using this development version of opentui.
Scenario 1
Open the editor using
/editoror keybind and it should work as expected, receiving all inputScenario 2
Replace the logic in opencode that opens the editor with an `await new Promise(r => setTimeout(r, 2000)). While the renderer is suspended, type characters into the terminal - they should be printed. When the renderer resumes, those characters should not be added to the prompt.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.