[CRIPPLING BUG^2] Pressing backspace deletes two chars #3212

Closed
opened 2026-02-16 17:39:08 -05:00 by yindo · 23 comments
Owner

Originally created by @DamianB-BitFlipper on GitHub (Nov 30, 2025).

Originally assigned to: @kommander on GitHub.

Description

Thanks for the hardwork, however I fear there is a weird bug in opencode where when I press backspace, it deletes two chars. v1.0.122 on macos

This isn't a problem in ANY other of my apps, so it isn't my keyboard or something

OpenCode version

1.0.122

Steps to reproduce

Just press backspace.

Screenshot and/or share link

https://github.com/user-attachments/assets/ab655129-49de-4051-b425-c8d4fc77a25f

Operating System

macos 15.6.1

Terminal

Kitty

Originally created by @DamianB-BitFlipper on GitHub (Nov 30, 2025). Originally assigned to: @kommander on GitHub. ### Description Thanks for the hardwork, however I fear there is a weird bug in opencode where when I press backspace, it deletes two chars. v1.0.122 on macos This isn't a problem in ANY other of my apps, so it isn't my keyboard or something ### OpenCode version 1.0.122 ### Steps to reproduce Just press backspace. ### Screenshot and/or share link https://github.com/user-attachments/assets/ab655129-49de-4051-b425-c8d4fc77a25f ### Operating System macos 15.6.1 ### Terminal Kitty
yindo added the opentuibug labels 2026-02-16 17:39:08 -05:00
yindo closed this issue 2026-02-16 17:39:08 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Nov 30, 2025):

This issue might be a duplicate of or related to existing issues. Please check:

  • #3301: Discusses deletion overshoot when holding backspace/alt+backspace for long press (characters deleted after key release)
  • #4906: Arrow keys not repeating in prompt input on macOS (v1.0.120) - similar key handling issue
  • #4911: Key repeat issues in main chat view on macOS (v1.0.121) - related key handling problem

These may all stem from the same underlying key event handling issue in the recent opentui updates. Feel free to ignore if your issue is distinctly different.

@github-actions[bot] commented on GitHub (Nov 30, 2025): This issue might be a duplicate of or related to existing issues. Please check: - #3301: Discusses deletion overshoot when holding backspace/alt+backspace for long press (characters deleted after key release) - #4906: Arrow keys not repeating in prompt input on macOS (v1.0.120) - similar key handling issue - #4911: Key repeat issues in main chat view on macOS (v1.0.121) - related key handling problem These may all stem from the same underlying key event handling issue in the recent opentui updates. Feel free to ignore if your issue is distinctly different.
Author
Owner

@mgrachten commented on GitHub (Dec 4, 2025):

I have the same issue on linux (Alacritty terminal). Tab fires twice as well, and command menu navigation doesn't work.

Downgrading to 1.0.119 fixes the issue for me. But the funny thing is: on a fresh user account the issue doesn't happen on any versions I tried (also >= 1.0.120), so I suppose it may be due to caching/secondary files stored somewhere but I can't figure out which. Before reinstalling I removed all of:

  • .opencode
  • .cache/opencode
  • .config/opencode
  • .local/share/opencode
  • .local/state/opencode
  • .bun

None of this prevents the issue from happening again after installing opencode >=1.0.120.

@mgrachten commented on GitHub (Dec 4, 2025): I have the same issue on linux (Alacritty terminal). Tab fires twice as well, and command menu navigation doesn't work. Downgrading to 1.0.119 fixes the issue for me. But the funny thing is: on a fresh user account the issue doesn't happen on any versions I tried (also >= 1.0.120), so I suppose it may be due to caching/secondary files stored somewhere but I can't figure out which. Before reinstalling I removed all of: * .opencode * .cache/opencode * .config/opencode * .local/share/opencode * .local/state/opencode * .bun None of this prevents the issue from happening again after installing opencode >=1.0.120.
Author
Owner

@kommander commented on GitHub (Dec 5, 2025):

Could you please download and execute the opentui-examples from https://github.com/sst/opentui/releases/tag/v0.1.57 or via curl as described in the opentui readme and choose the Keypress Debug Tool at the bottom of the list. Then press the keys and combos that are causing issues multiple times, then press shift+s to store the logs in the cwd and share these logs.

The examples also have an Editor Demo, are the issues reproducible there? Are you using any plugins/extensions/customizations?

@kommander commented on GitHub (Dec 5, 2025): Could you please download and execute the opentui-examples from [https://github.com/sst/opentui/releases/tag/v0.1.57](https://github.com/sst/opentui/releases/tag/v0.1.57) or via `curl` as described in the [opentui readme](https://github.com/sst/opentui?tab=readme-ov-file#try-examples) and choose the *Keypress Debug Tool* at the bottom of the list. Then press the keys and combos that are causing issues multiple times, then press `shift+s` to store the logs in the `cwd` and share these logs. <br><br>The examples also have an *Editor Demo*, are the issues reproducible there? Are you using any plugins/extensions/customizations?
Author
Owner

@mgrachten commented on GitHub (Dec 6, 2025):

I can reproduce the issue in the Editor Demo: One Backspace press deletes two characters, and Enter inserts two newlines. Tab (the other key that fires twice in the opencode UI) did not produce any visible effect in the Editor Demo, so can't test.

Here's the log from the Keypress Debug Tool:
keypress-debug-2025-12-06T11-58-10-882Z.json

@mgrachten commented on GitHub (Dec 6, 2025): I can reproduce the issue in the Editor Demo: One Backspace press deletes two characters, and Enter inserts two newlines. Tab (the other key that fires twice in the opencode UI) did not produce any visible effect in the Editor Demo, so can't test. Here's the log from the Keypress Debug Tool: [keypress-debug-2025-12-06T11-58-10-882Z.json](https://github.com/user-attachments/files/23982009/keypress-debug-2025-12-06T11-58-10-882Z.json)
Author
Owner

@joshanne commented on GitHub (Dec 7, 2025):

I'm also experiencing a similar thing with duplicate keypresses and alacritty.

See: alacritty-only-keypress-debug-2025-12-07T22-20-12-781Z.json

I can say that when I launch the Keypress Debug Tool (or opencode) through alacritty on its own, the duplicate keys are seen (see log above). When I launch alacritty → tmux → Keypress Debug Tool (or opencode) then the keypresses are only singles.

See: alacritty-tmux-keypress-debug-2025-12-07T22-25-24-180Z.json

@joshanne commented on GitHub (Dec 7, 2025): I'm also experiencing a similar thing with duplicate keypresses and `alacritty`. See: [alacritty-only-keypress-debug-2025-12-07T22-20-12-781Z.json](https://github.com/user-attachments/files/24020261/alacritty-only-keypress-debug-2025-12-07T22-20-12-781Z.json) I can say that when I launch the `Keypress Debug Tool` (or `opencode`) through `alacritty` on its own, the duplicate keys are seen (see log above). When I launch `alacritty → tmux → Keypress Debug Tool (or opencode)` then the keypresses are only singles. See: [alacritty-tmux-keypress-debug-2025-12-07T22-25-24-180Z.json](https://github.com/user-attachments/files/24020264/alacritty-tmux-keypress-debug-2025-12-07T22-25-24-180Z.json)
Author
Owner

@kommander commented on GitHub (Dec 7, 2025):

I need your help debugging this as I cannot reproduce. Can you get the pre-built example app from this pre-release https://github.com/sst/opentui/releases/tag/v0.1.57-dry.1 - I added some guards and debug logs. Run the "Keypress Debug Tool" again, press the keys that are doubled, then press "`" (backtick) to bring up the console and then ctrl+s directly to save the console contents to a file in the cwd as well. Either share the saved logs or a screenshot of the console with details if any.

Note: if you download the example exectuable via the browser on macos, it will put it in quarantine and it won't be exectuable, so you need to do xattr -d com.apple.quarantine ./path/to/opentui-examples to lift the quarantine.

@kommander commented on GitHub (Dec 7, 2025): I need your help debugging this as I cannot reproduce. Can you get the pre-built example app from this pre-release [https://github.com/sst/opentui/releases/tag/v0.1.57-dry.1](https://github.com/sst/opentui/releases/tag/v0.1.57-dry.1) - I added some guards and debug logs. Run the "Keypress Debug Tool" again, press the keys that are doubled, then press "\`" (backtick) to bring up the console and then `ctrl+s` directly to save the console contents to a file in the cwd as well. Either share the saved logs or a screenshot of the console with details if any. Note: if you download the example exectuable via the browser on macos, it will put it in quarantine and it won't be exectuable, so you need to do `xattr -d com.apple.quarantine ./path/to/opentui-examples` to lift the quarantine.
Author
Owner

@joshanne commented on GitHub (Dec 8, 2025):

As requested - this is with ubuntu 22.04 LTS with alacritty. As before, when running in the tmux session, it all appears to work.

console log after backtick then ctrl+s: _console_1765186980923.log

standard save: keypress-debug-2025-12-08T09-43-02-465Z.json

@joshanne commented on GitHub (Dec 8, 2025): As requested - this is with ubuntu 22.04 LTS with alacritty. As before, when running in the tmux session, it all appears to work. console log after backtick then ctrl+s: [_console_1765186980923.log](https://github.com/user-attachments/files/24029060/_console_1765186980923.log) standard save: [keypress-debug-2025-12-08T09-43-02-465Z.json](https://github.com/user-attachments/files/24029061/keypress-debug-2025-12-08T09-43-02-465Z.json)
Author
Owner

@kommander commented on GitHub (Dec 8, 2025):

@joshanne thank you. However the console logs you should see when opening the console at the bottom of the are saved with ctrl+s and create a separate log file. But from the logs I can see the double events happen at bun/system level somehow. This is very confusing.

@kommander commented on GitHub (Dec 8, 2025): @joshanne thank you. However the console logs you should see when opening the console at the bottom of the are saved with `ctrl+s` and create a separate log file. But from the logs I can see the double events happen at bun/system level somehow. This is very confusing.
Author
Owner

@kommander commented on GitHub (Dec 8, 2025):

Does any of this happen with a minimal example ran with bun directly?

// minimal.ts

process.stdin.setRawMode(true);
process.stdin.resume();
process.stdin.setEncoding("utf8");

let count = 0;

process.stdin.on("data", (chunk) => {
  if (chunk === "\u0003" || chunk === "\u0004") {
    console.log("Exiting.");
    process.exit(0);
  }

  console.log("event", ++count, "bytes:", [...Buffer.from(chunk)]);
});
@kommander commented on GitHub (Dec 8, 2025): Does any of this happen with a minimal example ran with bun directly? ```ts // minimal.ts process.stdin.setRawMode(true); process.stdin.resume(); process.stdin.setEncoding("utf8"); let count = 0; process.stdin.on("data", (chunk) => { if (chunk === "\u0003" || chunk === "\u0004") { console.log("Exiting."); process.exit(0); } console.log("event", ++count, "bytes:", [...Buffer.from(chunk)]); }); ```
Author
Owner

@joshanne commented on GitHub (Dec 8, 2025):

Running bun with a minimal example:

$ bun run minimal.ts
event 1 bytes: [ 127 ]
event 2 bytes: [ 9 ]
event 3 bytes: [ 13 ]
@joshanne commented on GitHub (Dec 8, 2025): Running bun with a minimal example: ```bash $ bun run minimal.ts event 1 bytes: [ 127 ] event 2 bytes: [ 9 ] event 3 bytes: [ 13 ] ```
Author
Owner

@joshanne commented on GitHub (Dec 8, 2025):

owever the console logs you should see when opening the console at the bottom of the are saved with ctrl+s and create a separate log file.

Both log files are uploaded above, _console.log only contains one line:

[20:42:50] [DEBUG] '[CliRenderer] Adding stdin listener in setupInput()'

I don't know if i can provide arguments to bun to run it in a more verbose mode to log more.

@joshanne commented on GitHub (Dec 8, 2025): > owever the console logs you should see when opening the console at the bottom of the are saved with `ctrl+s` and create a separate log file. Both log files are uploaded above, `_console.log` only contains one line: ``` [20:42:50] [DEBUG] '[CliRenderer] Adding stdin listener in setupInput()' ``` I don't know if i can provide arguments to bun to run it in a more verbose mode to log more.
Author
Owner

@kommander commented on GitHub (Dec 8, 2025):

Ah missed that. Thanks for the details. So the system/bun itself does not send multiple input bytes and the event listener is only attached once. Not sure what to make of this yet, eludes me currently. I'll keep digging.

@kommander commented on GitHub (Dec 8, 2025): Ah missed that. Thanks for the details. So the system/bun itself does not send multiple input bytes and the event listener is only attached once. Not sure what to make of this yet, eludes me currently. I'll keep digging.
Author
Owner

@joshanne commented on GitHub (Dec 8, 2025):

For me, I've just confirmed this duplicate key press issue began in v1.0.120.

  • If I downgrade to v1.0.119, opencode works as expected.
  • If I upgrade to v1.0.120, opencode starts processing duplicate keys.
@joshanne commented on GitHub (Dec 8, 2025): For me, I've just confirmed this duplicate key press issue began in `v1.0.120`. * If I downgrade to `v1.0.119`, opencode works as expected. * If I upgrade to `v1.0.120`, opencode starts processing duplicate keys.
Author
Owner

@joshanne commented on GitHub (Dec 8, 2025):

So googling alacritty double enter tab backspace and clicking through some neovim issues, stumbled across this: https://github.com/neovim/neovim/issues/31806#issuecomment-2831627317

If i launch an alacritty window with the alacritty-wrapper mentioned in that comment, it seems to work better?

(EDIT: It turns out that when i launched alacritty with this wrapper, I was actually launching with the newer install of alacritty from my path, rather than x-terminal-emulator which launches a system install of alacritty. I suspect that actual fix was the newer version of alacritty, rather than the wrapper itself.)

_console_1765225595761.log

keypress-debug-2025-12-08T20-26-37-708Z.json

These logs are from launching alacritty through the alacritty-wrapper that sets the environment variable $TERM explicitly.

@joshanne commented on GitHub (Dec 8, 2025): So googling `alacritty double enter tab backspace` and clicking through some `neovim` issues, stumbled across this: https://github.com/neovim/neovim/issues/31806#issuecomment-2831627317 If i launch an alacritty window with the `alacritty-wrapper` mentioned in that comment, it seems to work better? (EDIT: It turns out that when i launched alacritty with this wrapper, I was actually launching with the newer install of alacritty from my path, rather than x-terminal-emulator which launches a system install of alacritty. I suspect that actual fix was the newer version of alacritty, rather than the wrapper itself.) [_console_1765225595761.log](https://github.com/user-attachments/files/24040986/_console_1765225595761.log) [keypress-debug-2025-12-08T20-26-37-708Z.json](https://github.com/user-attachments/files/24040988/keypress-debug-2025-12-08T20-26-37-708Z.json) These logs are from launching alacritty through the alacritty-wrapper that sets the environment variable `$TERM` explicitly.
Author
Owner

@mgrachten commented on GitHub (Dec 9, 2025):

Good find @joshanne! Upgrading alacritty (from 0.13 to 0.16) fixes it for me. This issue can be closed as far as I'm concerned.

@mgrachten commented on GitHub (Dec 9, 2025): Good find @joshanne! Upgrading alacritty (from 0.13 to 0.16) fixes it for me. This issue can be closed as far as I'm concerned.
Author
Owner

@kommander commented on GitHub (Dec 9, 2025):

Is the issue still present for other terminal emulators? If so, can you try running with bunx opencode-ai@snapshot-kmdr-debug please and let me know if that works better? I defaulted kitty keyboard flags back to alternate keys only, without events being reported, which can be activated optionally, but we don't make use of them in opencode anyway.

@kommander commented on GitHub (Dec 9, 2025): Is the issue still present for other terminal emulators? If so, can you try running with `bunx opencode-ai@snapshot-kmdr-debug` please and let me know if that works better? I defaulted kitty keyboard flags back to alternate keys only, without events being reported, which can be activated optionally, but we don't make use of them in opencode anyway.
Author
Owner

@mgrachten commented on GitHub (Dec 9, 2025):

I don't think the issue was ever happening on terminals other than alacritty. Just tried opencode 1.0.137 on konsole and xterm, and neither has the issue.

@mgrachten commented on GitHub (Dec 9, 2025): I don't think the issue was ever happening on terminals other than alacritty. Just tried opencode 1.0.137 on konsole and xterm, and neither has the issue.
Author
Owner

@kommander commented on GitHub (Dec 9, 2025):

OP @DamianB-BitFlipper mentioned Kitty.

@kommander commented on GitHub (Dec 9, 2025): OP @DamianB-BitFlipper mentioned Kitty.
Author
Owner

@kommander commented on GitHub (Dec 9, 2025):

OP @DamianB-BitFlipper mentioned Kitty.

@kommander commented on GitHub (Dec 9, 2025): OP @DamianB-BitFlipper mentioned Kitty.
Author
Owner

@kommander commented on GitHub (Dec 9, 2025):

OP @DamianB-BitFlipper mentioned Kitty.

@kommander commented on GitHub (Dec 9, 2025): OP @DamianB-BitFlipper mentioned Kitty.
Author
Owner

@joshanne commented on GitHub (Dec 9, 2025):

facepalm It turns out my update-alternatives x-terminal-emulator pointed to a different version of alacritty than what was launched from my path when manually running alacritty from terminal.

x-terminal-emulator pointed to an alacritty v0.13.2
~/.local/bin/alacritty runs alacritty v0.16.1

It's unclear why opentui/opencode behaviour changes between .119 and .120 (see: comment here)

sicnce fixing my default terminal and alacritty install, I can confirm that v0.16.1 resolves the issue.

I cannot speak for the OP who originally mentioned Kitty.

@joshanne commented on GitHub (Dec 9, 2025): *facepalm* It turns out my `update-alternatives x-terminal-emulator` pointed to a different version of `alacritty` than what was launched from my path when manually running `alacritty` from terminal. `x-terminal-emulator` pointed to an `alacritty v0.13.2` `~/.local/bin/alacritty` runs `alacritty v0.16.1` It's unclear why `opentui`/`opencode` behaviour changes between `.119` and `.120` (see: [comment here](https://github.com/sst/opencode/issues/4920#issuecomment-3628851143)) sicnce fixing my default terminal and alacritty install, I can confirm that `v0.16.1` resolves the issue. I cannot speak for the OP who originally mentioned `Kitty`.
Author
Owner

@kommander commented on GitHub (Dec 9, 2025):

Well older alacritty versions did not handle kitty keyboard and other modes correctly and there was an addtional keyboard mode introduced from .119 to .120, I suspect that to be the culprit. It is not activated by default anymore running bunx opencode-ai@snapshot-kmdr-debug and I'll be removing the event mode default in upcoming opencode versions as well.

@kommander commented on GitHub (Dec 9, 2025): Well older alacritty versions did not handle kitty keyboard and other modes correctly and there was an addtional keyboard mode introduced from .119 to .120, I suspect that to be the culprit. It is not activated by default anymore running `bunx opencode-ai@snapshot-kmdr-debug` and I'll be removing the event mode default in upcoming opencode versions as well.
Author
Owner

@joshanne commented on GitHub (Dec 9, 2025):

Thanks for the info @kommander !

Also, thanks for helping with this - it ultimately uncovered an issue in my setup I wasn't aware of!

@joshanne commented on GitHub (Dec 9, 2025): Thanks for the info @kommander ! Also, thanks for helping with this - it ultimately uncovered an issue in my setup I wasn't aware of!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3212