[GH-ISSUE #564] Bun.spawn() into an editor is extremely slow and drops inputs #153

Open
opened 2026-03-02 23:44:55 +03:00 by kerem · 1 comment
Owner

Originally created by @tspader on GitHub (Jan 21, 2026).
Original GitHub issue: https://github.com/anomalyco/opentui/issues/564

Shelling out to an editor makes the editor extremely slow. I've experienced this in opencode in the past, but it got fixed -- I'm not 100% sure, but I think with this commit, and between version 0.1.47 and 0.1.49 of opentui / 1.0.115 and 1.0.116 of opencode.

I'm writing a TUI which also shells out to an editor, and I noticed the same behavior: extremely slow/laggy keys, inputs getting eaten. Interestingly, opencode does not currently have this behavior on my setup. I made sure that I was pinned to the exact opentui versions they use (core + solid), and i made sure that I was setting everything up exactly like they do in the prompt widget.

opencode stuff:
https://github.com/anomalyco/opencode/blob/dev/packages/opencode/src/cli/cmd/tui/util/editor.ts

minimal repro:

#!/usr/bin/env bun
import { createCliRenderer } from "@opentui/core"
async function main() {
  const renderer = await createCliRenderer({
    exitOnCtrlC: false,
    useKittyKeyboard: {},
  })

  renderer.start()

  // Wait 1 second
  await new Promise(r => setTimeout(r, 1000))

  console.log("Suspending...")
  renderer.suspend()
  renderer.currentRenderBuffer.clear()

  console.log("Spawning vim...")
  const proc = Bun.spawn({
    cmd: ["vim", "/tmp/test.txt"],
    stdin: "inherit",
    stdout: "inherit",
    stderr: "inherit",
  })
  await proc.exited

  renderer.destroy()
}

main()

run this against 0.1.74 of opentui; my program uses solid but the repro just uses core, still is broken for me

here's my environment; this is consistent across every terminal emulator i've tried (ghostty, alacritty, wezterm + bash, zsh + vim, nvim). my bash/nvim have configurations, but zsh/plain vim are completely stock. all of my terminal emulators are completely stock.

OS: Arch Linux x86_64
Host: MS-7E70 2.0
Kernel: 6.18.5-arch1-1
Shell: bash 5.3.9
Terminal: ghostty
bun: 1.2.21
Originally created by @tspader on GitHub (Jan 21, 2026). Original GitHub issue: https://github.com/anomalyco/opentui/issues/564 Shelling out to an editor makes the editor extremely slow. I've experienced this in opencode in the past, but it got fixed -- I'm not 100% sure, but I think with [this commit](https://github.com/anomalyco/opentui/commit/3f9fedb3c46ff841443b70154f80aa788671556e), and between version 0.1.47 and 0.1.49 of opentui / 1.0.115 and 1.0.116 of opencode. I'm writing a TUI which also shells out to an editor, and I noticed the same behavior: extremely slow/laggy keys, inputs getting eaten. Interestingly, opencode does _not_ currently have this behavior on my setup. I made sure that I was pinned to the _exact_ opentui versions they use (core + solid), and i made sure that I was setting everything up _exactly_ like they do in the prompt widget. opencode stuff: https://github.com/anomalyco/opencode/blob/dev/packages/opencode/src/cli/cmd/tui/util/editor.ts minimal repro: ```ts #!/usr/bin/env bun import { createCliRenderer } from "@opentui/core" async function main() { const renderer = await createCliRenderer({ exitOnCtrlC: false, useKittyKeyboard: {}, }) renderer.start() // Wait 1 second await new Promise(r => setTimeout(r, 1000)) console.log("Suspending...") renderer.suspend() renderer.currentRenderBuffer.clear() console.log("Spawning vim...") const proc = Bun.spawn({ cmd: ["vim", "/tmp/test.txt"], stdin: "inherit", stdout: "inherit", stderr: "inherit", }) await proc.exited renderer.destroy() } main() ``` run this against 0.1.74 of opentui; my program uses solid but the repro just uses core, still is broken for me here's my environment; this is consistent across every terminal emulator i've tried (ghostty, alacritty, wezterm + bash, zsh + vim, nvim). my bash/nvim have configurations, but zsh/plain vim are completely stock. all of my terminal emulators are completely stock. ``` OS: Arch Linux x86_64 Host: MS-7E70 2.0 Kernel: 6.18.5-arch1-1 Shell: bash 5.3.9 Terminal: ghostty bun: 1.2.21 ```
Author
Owner

@kommander commented on GitHub (Jan 24, 2026):

Is Bun.spawn fast enough/error free standalone without opentui? Mhh, it might be the stdout capture, but afaik renderer.suspend pauses stdout capture. Needs checking.

<!-- gh-comment-id:3795236214 --> @kommander commented on GitHub (Jan 24, 2026): Is `Bun.spawn` fast enough/error free standalone without opentui? Mhh, it might be the stdout capture, but afaik `renderer.suspend` pauses stdout capture. Needs checking.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#153
No description provided.