Repository navigation
fix(tui): contain stray stdio writes - #43065
spiatrenka wants to merge 2 commits into
Conversation
|
Scope note: this guards the JavaScript It does not contain writes made by native code straight to the file descriptor — e.g. the ALSA diagnostics block in #41763 / #41770. Same class of bug, but that needs fd-level redirection ( The same mechanism is what makes this safe: opentui writes frames natively, so frame output never passes through these wrappers. Verified — a guard installed before |
7ad6e4d to
9e4da24
Compare
— AI code review (automated) |
|
|
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 #43064
Type of change
What does this PR do?
If a plugin or the server logs with
process.stderr.write, the text goes straight to the terminal and paints over the TUI. The screen stays broken until the next full repaint. opentui capturesconsole.*, but nothing captures raw stream writes, so there was no way to stop this from the app side.The TUI runs on the main thread and the server runs in a worker. Each has its own
processobject but they share the same terminal, so both need covering. This swapsstdout.write/stderr.writefor the renderer's lifetime and sends that output tolog/stdio-main.logandlog/stdio-worker.loginstead, restoring the originals on teardown so crash output still reaches the terminal.Frames are unaffected because opentui writes them natively, below the JS wrappers. I confirmed that by installing the guard before
createCliRendererand checking it captured no frame bytes while rendering stayed correct.This only covers JS-level writes. Native code writing to the fd directly (the ALSA block in #41763 / #41770) still gets through and would need
dup2.How did you verify your code works?
--print-logsis the easiest repro, since the log writer usesprocess.stderr.write(packages/core/src/observability/logging.ts:54):Before, the log lines overwrite the composer. After, the frame is clean and the same lines land in
~/.local/share/opencode/log/stdio-worker.log.Also: 204 tests and typecheck pass in
packages/tui, typecheck passes inpackages/opencode.Screenshots / recordings
Before, on
dev:After, on this branch:
Checklist