feat: buffer stdin during TUI startup so early input is preserved#20934
feat: buffer stdin during TUI startup so early input is preserved#20934JosXa wants to merge 1 commit into
Conversation
cd15643 to
0faad97
Compare
0faad97 to
2dba8b5
Compare
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
While well meaning I don't think this is the way, "This PR adds a preload-phase stdin buffer " This is an additive solution, while there exist a subtractive solution. Temrinals naturally buffer input, there is something in the stack that is silently consuming the input buffer. In the issue I used a simple example in python that naturally buffers input, an even simpler example in C could be used to further the point. There's something consuming the buffer and it needs to be removed, rather than adding another buffer. |
2dba8b5 to
bf84d00
Compare
Well, yes, it's the theme detection mechanism that this PR works around. Don't ask me what we even need it for, I'm in favor of getting rid of that |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #20933
Closes #14415
Type of change
What does this PR do?
Keystrokes typed while the TUI is booting were silently dropped. This PR adds a preload-phase stdin buffer that captures raw bytes from the moment the process starts, then replays them into the prompt once it mounts.
Replay splits at control/escape boundaries so each chunk gets a separate push/drain cycle in opentui's StdinParser, preserving cursor position for mid-input paste events. Bracketed paste is enabled early so startup pastes are properly tagged.
Theme detection (
getTerminalBackgroundColor) queries OSC 11 via stdout and listens for the response on stdin. The buffer's patchedemitforwards all events to existing listeners, so theme detection still receives the terminal response normally. The response bytes also land in the buffer, but opentui's StdinParser classifies them as inert "response" events that are silently ignored.How did you verify your code works?
keyboard-buffer.test.ts) sends input before the TUI renders and asserts it appears in the promptChecklist