Debug alt+enter not working in Pi TUI under Warp terminal
Session from pi-mono-sessions on Hugging Face by thomasmustier · MIT · condensed by Coders Talk
The developer wanted to find out why ALT+ENTER doesn't trigger the followUp action in Pi when running inside Warp, despite option+up arrow working fine in Codex, and understand the root cause by comparing how each tool parses terminal key sequences.
- +0Prompt · +0Investigate why ALT+ENTER doesn't work with Pi in Warp, even though option+up works in Codex; can clone codex to compare keystroke handling.
- +0mAgent did · +0mSearched pi-mono for keypress/alt handling, read packages/tui/src/keys.ts, keybindings.ts and terminal.ts to see how followUp (alt+enter) is matched and how Kitty protocol detection is wired up.
- +0mAgent did · +0mCloned openai/codex locally and explored its Rust TUI, finding it uses crossterm for structured key events and tracks keyboard enhancement/Kitty support via PushKeyboardEnhancementFlags.
- +1mAgent did · +1mTraced Codex's chat_composer.rs and textarea.rs Enter handling, then compared to Pi's editor.ts newLine detection; concluded Pi expects raw escape sequences (\x1b\r legacy or Kitty CSI u) for alt+enter that Warp may not be sending.
- +2mAgent did · +2mConfirmed followUp is bound to alt+enter via keybindings.ts, wrote a standalone /tmp/keytest.ts script to sniff raw bytes Warp sends, and pointed out Pi supports custom keybindings via ~/.pi/agent/keybindings.json as a workaround.
- Break · 32m away, not counted
- +5mPrompt · +5mSo wait, how come option+up arrow works fine in Codex then?
- +6mAgent did · +6mFound that Codex's chat_composer.rs matches KeyCode::Up with any modifier (including ALT) because crossterm delivers structured key+modifier events, whereas Pi's keys.ts only recognizes alt+up via the Kitty CSI u sequence with no legacy xterm fallback (unlike alt+left, which has one) — identifying the actual asymmetry in Pi's key parsing.
- +6mOutcome · +6mDiagnosed root cause: Pi parses raw escape sequences and lacks a legacy fallback for alt+up (and possibly alt+enter under Warp), while Codex's crossterm-based input gets structured modifier flags directly; no code fix was implemented, only a keybindings.json workaround and a key-sniffing script were produced.
Next time I'd ask directly for a side-by-side comparison of how Warp's raw escape sequences map onto both tools' key-matching code, since that's what actually mattered — Pi parses raw bytes while Codex/crossterm gets structured key+modifier events. The follow-up question about option+up was what pushed the agent to find the real asymmetry (missing legacy fallback for alt+up), which the first pass had glossed over with speculation instead of digging into Pi's own keys.ts logic.