fix(tui,coding-agent): handle tmux xterm extended keys and warn on tmux setup fixes #1872
This commit is contained in:
@@ -8,13 +8,30 @@ Work out of the box.
|
||||
|
||||
## Ghostty
|
||||
|
||||
Add to your Ghostty config (`~/.config/ghostty/config`):
|
||||
Add to your Ghostty config (`~/Library/Application Support/com.mitchellh.ghostty/config` on macOS, `~/.config/ghostty/config` on Linux):
|
||||
|
||||
```
|
||||
keybind = alt+backspace=text:\x1b\x7f
|
||||
```
|
||||
|
||||
Older Claude Code versions may have added this Ghostty mapping:
|
||||
|
||||
```
|
||||
keybind = shift+enter=text:\n
|
||||
```
|
||||
|
||||
That mapping sends a raw linefeed byte. Inside pi, that is indistinguishable from `Ctrl+J`, so tmux and pi no longer see a real `shift+enter` key event.
|
||||
|
||||
If Claude Code 2.x or newer is the only reason you added that mapping, you can remove it, unless you want to use Claude Code in tmux, where it still requires that Ghostty mapping.
|
||||
|
||||
If you want `Shift+Enter` to keep working in tmux via that remap, add `ctrl+j` to your pi `newLine` keybinding in `~/.pi/agent/keybindings.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"newLine": ["shift+enter", "ctrl+j"]
|
||||
}
|
||||
```
|
||||
|
||||
## WezTerm
|
||||
|
||||
Create `~/.wezterm.lua`:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# tmux Setup
|
||||
|
||||
Pi works inside tmux, but tmux strips modifier information from certain keys by default. Without configuration, `Shift+Enter` and `Ctrl+Enter` are indistinguishable from plain `Enter`.
|
||||
Pi works inside tmux, but tmux strips modifier information from certain keys by default. Without configuration, `Shift+Enter` and `Ctrl+Enter` are usually indistinguishable from plain `Enter`.
|
||||
|
||||
## Required Configuration
|
||||
## Recommended Configuration
|
||||
|
||||
Add to `~/.tmux.conf`:
|
||||
|
||||
@@ -11,27 +11,49 @@ set -g extended-keys on
|
||||
set -g extended-keys-format csi-u
|
||||
```
|
||||
|
||||
Then restart tmux (not just reload):
|
||||
Then restart tmux fully:
|
||||
|
||||
```bash
|
||||
tmux kill-server
|
||||
tmux
|
||||
```
|
||||
|
||||
This tells tmux to forward modified key sequences in CSI-u format when an application requests extended key reporting. Pi requests this automatically when Kitty keyboard protocol is not available.
|
||||
Pi requests extended key reporting automatically when Kitty keyboard protocol is not available. With `extended-keys-format csi-u`, tmux forwards modified keys in CSI-u format, which is the most reliable configuration.
|
||||
|
||||
## Why `csi-u` Is Recommended
|
||||
|
||||
With only:
|
||||
|
||||
```tmux
|
||||
set -g extended-keys on
|
||||
```
|
||||
|
||||
tmux defaults to `extended-keys-format xterm`. When an application requests extended key reporting, modified keys are forwarded in xterm `modifyOtherKeys` format such as:
|
||||
|
||||
- `Ctrl+C` → `\x1b[27;5;99~`
|
||||
- `Ctrl+D` → `\x1b[27;5;100~`
|
||||
- `Ctrl+Enter` → `\x1b[27;5;13~`
|
||||
|
||||
With `extended-keys-format csi-u`, the same keys are forwarded as:
|
||||
|
||||
- `Ctrl+C` → `\x1b[99;5u`
|
||||
- `Ctrl+D` → `\x1b[100;5u`
|
||||
- `Ctrl+Enter` → `\x1b[13;5u`
|
||||
|
||||
Pi supports both formats, but `csi-u` is the recommended tmux setup.
|
||||
|
||||
## What This Fixes
|
||||
|
||||
Without this config, tmux collapses modified enter keys to plain `\r`:
|
||||
Without tmux extended keys, modified Enter keys collapse to legacy sequences:
|
||||
|
||||
| Key | Without config | With config |
|
||||
|-----|---------------|-------------|
|
||||
| Key | Without extkeys | With `csi-u` |
|
||||
|-----|-----------------|--------------|
|
||||
| Enter | `\r` | `\r` |
|
||||
| Shift+Enter | `\r` | `\x1b[13;2u` |
|
||||
| Ctrl+Enter | `\r` | `\x1b[13;5u` |
|
||||
| Alt/Option+Enter | `\x1b\r` | `\x1b[13;3u` |
|
||||
|
||||
This affects the default keybindings (`Enter` to submit, `Shift+Enter` for newline) and any custom keybindings using modified enter keys.
|
||||
This affects the default keybindings (`Enter` to submit, `Shift+Enter` for newline) and any custom keybindings using modified Enter.
|
||||
|
||||
## Requirements
|
||||
|
||||
|
||||
Reference in New Issue
Block a user