Skip to content

fix: remove CSIuReader from tea.WithInput — breaks terminal raw mode#538

Merged
asheshgoplani merged 1 commit intoasheshgoplani:mainfrom
johnuopini:fix/csiu-reader-mouse-terminator
Apr 9, 2026
Merged

fix: remove CSIuReader from tea.WithInput — breaks terminal raw mode#538
asheshgoplani merged 1 commit intoasheshgoplani:mainfrom
johnuopini:fix/csiu-reader-mouse-terminator

Conversation

@johnuopini
Copy link
Copy Markdown
Contributor

@johnuopini johnuopini commented Apr 8, 2026

Summary

tea.WithInput(ui.NewCSIuReader(os.Stdin)) (added in #535) wraps stdin with a plain io.Reader, stripping the *os.File interface. Bubble Tea needs the file descriptor to set raw terminal mode. Without it, the terminal stays in cooked mode: escape sequences are processed by the terminal driver instead of reaching the app. Arrow keys, mouse events, and all CSI sequences appear as raw text.

Fix: remove the tea.WithInput(CSIuReader) line entirely. The existing DisableKittyKeyboard/RestoreKittyKeyboard escape sequences already handle Kitty protocol terminals. The CSIuReader approach cannot work at the io.Reader level.

Also fixes the CSIuReader's internal terminator set to use the standard CSI final byte range (0x40-0x7E) instead of a hardcoded subset that missed SGR mouse terminators (M/m). This makes the code correct if reused as a tea.KeyMsg translator in Update().

Reverts the one-line change from #535.

Fixes #539

Test plan

  • Arrow keys work in tmux + xterm (verified locally)
  • TestCSIuReaderPassesSGRMouseEvents — regression test for the terminator fix
  • All 19 existing CSIuReader tests pass

@johnuopini johnuopini force-pushed the fix/csiu-reader-mouse-terminator branch from 3289966 to 5908bfe Compare April 8, 2026 09:24
@johnuopini johnuopini changed the title fix: CSIuReader drops arrow keys when mouse events are present fix: remove CSIuReader from tea.WithInput — breaks terminal raw mode Apr 8, 2026
tea.WithInput(io.Reader) replaces Bubble Tea's stdin with a plain
io.Reader, stripping the *os.File interface. Bubble Tea needs the
file descriptor to set raw terminal mode. Without it, the terminal
stays in cooked mode: escape sequences are processed by the terminal
driver instead of reaching the app, causing arrow keys and all CSI
sequences to appear as raw text.

The existing DisableKittyKeyboard/RestoreKittyKeyboard escape sequences
already handle Kitty protocol terminals correctly. Remove the
CSIuReader wrapper entirely — it cannot work at the io.Reader level.

Also fix CSIuReader's terminator set to use the standard CSI final byte
range (0x40-0x7E) instead of a hardcoded subset, so the code is correct
if reused elsewhere (e.g., as a tea.KeyMsg translator in Update()).

Reverts the one-line change from asheshgoplani#535.
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.

v1.4.1: Arrow keys and keyboard input broken — CSIuReader strips raw terminal mode

2 participants