Skip to content
PidebugCLI & tooling

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

6msession
0interventions
GOAL

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.

  1. Prompt · +0
    Investigate why ALT+ENTER doesn't work with Pi in Warp, even though option+up works in Codex; can clone codex to compare keystroke handling.
  2. Agent did · +0m
    Searched 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.
  3. Agent did · +0m
    Cloned openai/codex locally and explored its Rust TUI, finding it uses crossterm for structured key events and tracks keyboard enhancement/Kitty support via PushKeyboardEnhancementFlags.
  4. Agent did · +1m
    Traced 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.
  5. Agent did · +2m
    Confirmed 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.
  6. Break · 32m away, not counted
  7. Prompt · +5m
    So wait, how come option+up arrow works fine in Codex then?
  8. Agent did · +6m
    Found 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.
  9. Outcome · +6m
    Diagnosed 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.
VERDICT

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.

I tried this · 0

Discussion · 0

How Builds work