opencode icon indicating copy to clipboard operation
opencode copied to clipboard

OpenTUI: ctrl-z background controls are broken

Open goniz opened this issue 2 months ago • 6 comments

Description

Since OpenTUI got merged, the ctrl-z background controls functionality got masked by the text box undo feature

OpenCode version

1.0.11

Steps to reproduce

  1. open tui session
  2. write some prompt
  3. press ctrl-z
  4. text is undo'ed instead of going to background

Screenshot and/or share link

https://github.com/user-attachments/assets/3dc13815-5139-48c5-a9cd-d7ede26fb85b

Operating System

macOS 26.0.1

Terminal

Ghostty

goniz avatar Nov 02 '25 09:11 goniz

Opencode needs to re-map the undo for the Textarea to not collide with other mappings.

kommander avatar Nov 04 '25 14:11 kommander

Could I take this up?

I was thinking ctrl + Z can be undo and ctrl + shift + z can be suspend?

aymuos15 avatar Nov 04 '25 15:11 aymuos15

I've started to look into it.

https://github.com/goniz/opencode/commit/949f037d5ad60856aea25f0efe6343ff5f110cdd

Wdyt about this approach? It's not done yet but the suspend part works

@kommander

goniz avatar Nov 04 '25 15:11 goniz

Could I take this up?

I was thinking ctrl + Z can be undo and ctrl + shift + z can be suspend?

In my opinion the terminal's native behaviors should take priority over the textarea editing behavior.

goniz avatar Nov 04 '25 15:11 goniz

In warp, it is undo in its "text area" hence my suggestion but yeah, I get that.

aymuos15 avatar Nov 04 '25 15:11 aymuos15

In warp, it is undo in its "text area" hence my suggestion but yeah, I get that.

So annoying 😂😵 But yeah, that's my own preference

goniz avatar Nov 04 '25 16:11 goniz

ctrl+z should not be mapped by default anymore

kommander avatar Nov 17 '25 16:11 kommander

As of 1.0.74 it's still not working on MacOS (in iTerm2 at least).

BrianVandenberg-vivint avatar Nov 18 '25 17:11 BrianVandenberg-vivint

As of 1.0.74 it's still not working on MacOS (in iTerm2 at least).

I have a PR open at https://github.com/sst/opencode/pull/3983

It's working but still has some artifacts due to incomplete shutdown sequence in opentui. I still haven't had the time to figure out and fix

goniz avatar Nov 18 '25 17:11 goniz

If it matters, my 2¢: that's what /editor is for; get rid of undo & let ^Z do its default thing -> add an optional keybind for people who really really want undo in the TUI.

BrianVandenberg-vivint avatar Nov 18 '25 18:11 BrianVandenberg-vivint

If it matters, my 2¢: that's what /editor is for; get rid of undo & let ^Z do its default thing -> add an optional keybind for people who really really want undo in the TUI.

It's already implemented as you described. Undo&redo were mapped to alternative key bindings by @kommander and my PR implements the default terminal behavior to enable background and foreground terminal controls

goniz avatar Nov 18 '25 18:11 goniz