Skip to content

A newline in an input box is any modified Enter or Ctrl-J, not Shift-Enter alone; copying out is Ctrl-Y//copy to the platform clipboard command; and mouse reporting is a setting (--no-mouse) because it is what takes the terminal's own selection away

TUI decision 68 · accepted · 2026-09-15

Shift-Enter was the only way to get a newline, and in most terminals it is not a distinct key: the emulator sends the same \r for both, so crossterm reports enter with no modifiers and the text was sent instead of split. Nothing in the harness can fix that from the Elixir side, so the fix is to accept every spelling a terminal can send — alt, super, meta, shift on Enter, plus Ctrl-J, which is a literal \n byte and therefore survives every terminal, multiplexer and ssh hop. The box's title advertises Alt-Enter and Ctrl-J rather than Shift-Enter for the same reason: naming a key that silently does the wrong thing is worse than naming a duller one that works. Copying needed a different answer than "select it with the mouse", because a transcript is taller than the pane and the interesting part has usually scrolled: Ctrl-Y and /copy [n] copy the whole activated transcript, taken from the same Model.pane_blocks/5 the pane draws but unstyled and unwrapped, so what lands on the clipboard has the agent's own line breaks and not the ones this terminal width imposed. Troupe.UI.Clipboard shells out to pbcopy/clip/wl-copy/xclip/xsel (Wayland first when WAYLAND_DISPLAY is set, since xclip on the same box would talk to XWayland's clipboard instead of the session the user is looking at) and stages the text in a temp file rather than piping it, because OS.Process gives the reaper the child's stdin — a pipe was not available without changing the one module every OS process goes through. clipboard_command overrides the guess, which is how a tmux buffer or an OSC-52 helper over ssh gets used, and how the test suite avoids clobbering the developer's real clipboard. The Ctrl-Y clause has to sit above the y/n/a approval clause in window_key/3: that clause matches any modifier, so it swallowed Ctrl-Y and answered an approval instead — the test asserts both halves. Mouse reporting stays on by default, since clicking a tile and scrolling the pane under the cursor are most of what makes the TUI feel direct, but it is now --no-mouse and a mouse setting, because the terminal hands the app every click once it is on and the user's own click-drag-copy stops working inside Troupe; the flag is tri-state (nil = "ask the setting") so a config file can decide when no flag is given. Its effect is :next_run — the escape sequence is written at init_terminal, so unlike every other setting it cannot apply to the session already on screen, which is why effect_line/1 grew a third case rather than lying about it.

Governs: clients/tui/lib/troupe/ui/tui/input.ex, clients/tui/lib/troupe/clipboard.ex