Skip to content

fix: Manage raw mode for stdin in editor function - #4595

Closed
bowmanjd wants to merge 1 commit into
anomalyco:devfrom
bowmanjd:dev
Closed

bowmanjd wants to merge 1 commit into
anomalyco:devfrom
bowmanjd:dev

Conversation

@bowmanjd

@bowmanjd bowmanjd commented Nov 21, 2025 •

Copy link
Copy Markdown

Toggle raw mode for stdin before and after launching the editor, so that input handling does not interfere with functionality of console-based editors like Vim.

I love Bun and love raw input mode, but this seems like a case where we should totally delegate keyboard control to the external editor, correct?

Solves #4209 and #4586

Toggle raw mode for stdin before and after launching the editor, so that input handling does not interfere with functionality of console-based editors like Vim
@veracioux

veracioux commented Nov 21, 2025 •

Copy link
Copy Markdown
Contributor

I tried this fix and it doesn't work for me. This is an issue in opentui, which I created a fix for: anomalyco/opentui#331

Anyhow, I don't see how this would fix it since the editor itself enables raw mode on stdin.

@bowmanjd

Copy link
Copy Markdown
Author

I tried this fix and it doesn't work for me. This is an issue in opentui, which I created a fix for: sst/opentui#331

Anyhow, I don't see how this would fix it since the editor itself enables raw mode on stdin.

Interesting, @veracioux . Thanks for your work on that opentui change. Surprised the raw input toggle doesn't work for you, but perhaps our situations are entirely different.

When you say "the editor itself enables raw mode on stdin" -- what do you mean? I agree that Neovim or other editors may likely be using raw mode -- wouldn't that be an argument in favor of disabling raw mode (Opencode or OpenTUI conceding keypress handling) before transitioning to the editor?

Whatever works that fixes this. I am just trying to understand the functionality better.

@veracioux

Copy link
Copy Markdown
Contributor

@bowmanjd Well, based on my understanding of ttys (based on experience with linux, are you on windows perhaps?), the raw mode setting applies per tty, not per process per tty.

Since stdin is inherited from opencode by the editor, these two pretty much cancel each other out:

// pseudo code
opencode:stdin.setRawMode(false)
editor:stdin.setRawMode(true)

In the end there is only one stdin and it will have the last of those values active.

Also, if you look at the opentui source code, it already disables raw mode in renderer.suspend(): https://github.com/sst/opentui/blob/main/packages/core/src/renderer.ts#L1289

I'm not sure why we have different behaviors. Are you sure you are able to reproduce the issue reliably?

@bowmanjd

Copy link
Copy Markdown
Author

I'm not sure why we have different behaviors. Are you sure you are able to reproduce the issue reliably?

Always a good question! I, too, am on Linux (NixOS) and am using Neovim 0.11.5. I have tried two things that fix the issue immediately:

  1. Downgrading to Opencode v1.0.78
  2. or making the edits from my PR.

Both of the above worked a few hours ago.

And yet, of course, now that I try to replicate the issue, I cannot. I am on v1.0.85 and, with or without the changes from my PR, the editor is working just fine. I just changed to v1.0.86, as well, and it is also working fine there.

Sorry, without being able to replicate, I now distrust that I am able to reproduce the issue reliably. The only thing I can think that has changed is a rebuild of my NixOS installation.

@veracioux

Copy link
Copy Markdown
Contributor

@bowmanjd Make sure that the actual installed version of @opentui/core and @opentui/solid is 0.1.47 (since that is the version that introduces the regression).

@bowmanjd

Copy link
Copy Markdown
Author

Correct. According to my bun.lock file, both are at 0.1.47.

@bowmanjd

Copy link
Copy Markdown
Author

Closing this because it was not effective. The ephemeral nature of the issue on my machine caused me to incorrectly think this change had fixed the problem.

@bowmanjd bowmanjd closed this Nov 22, 2025
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.

2 participants