Skip to content

fix: Buffer stdin before prompt UI appears#24412

Open
DSteve595 wants to merge 1 commit intoanomalyco:devfrom
DSteve595:startup-input-buffer
Open

fix: Buffer stdin before prompt UI appears#24412
DSteve595 wants to merge 1 commit intoanomalyco:devfrom
DSteve595:startup-input-buffer

Conversation

@DSteve595
Copy link
Copy Markdown

Issue for this PR

Closes #14415

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This addresses chars being dropped while typing between launching opencode and the prompt UI being rendered, by buffering stdin and seeding the prompt state with it later.
This takes a different approach to #20934, leveraging OpenTUI's StdinParser rather than parsing the input ourselves.

I attempted to address @TZubiri's concern, but couldn't find a subtractive solution that worked. That said, I'm not well versed in OpenTUI. It seems to take stdin ownership and set it to raw mode immediately in createCliRenderer(). I tried in a small repro project that delays before rendering a text box, and input was swallowed there too.

How did you verify your code works?

Manual testing on macOS 26's stock Terminal.app.

Screenshots / recordings

Before After
Screen.Recording.2026-04-25.at.5.37.57.PM.mov
Screen.Recording.2026-04-25.at.5.38.24.PM.mov

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found

PR #20934: feat: buffer stdin during TUI startup so early input is preserved

Why it's related: PR #24412 explicitly mentions that it "takes a different approach to #20934". Both PRs address the same issue (#14415) - preventing characters from being dropped while typing between launching opencode and the prompt UI being rendered. The main difference is that PR #24412 leverages OpenTUI's StdinParser instead of custom parsing logic.

Additional related PR:
PR #17083: fix: flush stdin on POSIX exit to prevent stale bytes leaking to shell

This is also stdin-related but appears to address cleanup rather than input buffering during startup.

Bojun-Vvibe added a commit to Bojun-Vvibe/oss-contributions that referenced this pull request Apr 26, 2026
- anomalyco/opencode#24411: structured-vs-string reasoning_details split for Kilo
- anomalyco/opencode#24412: startup-stdin side-buffer drain into TUI prompt
- openai/codex#19620: AsciiJsonFormatter for HTTP turn-metadata headers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text written during startup is dropped.

1 participant