fix: load keybindings before --resume session picker

The problem: I wanted to be able to select my session (either from
`/resume` or `--resume`) with different keybindings.

The issue: when running `pi --resume`, custom keybindings from
`~/.pi/agent/keybindings.json` were not being applied to the session
picker. This happened because `KeybindingsManager.create()` was only
called when `InteractiveMode` initialized, but the session picker runs
before that in `main.ts`.

The session picker uses `getEditorKeybindings()` for navigation
(selectUp/selectDown etc.), which returns the global default keybindings
if `setEditorKeybindings()` hasn't been called yet.

Fix: Call `KeybindingsManager.create()` inside the `--resume` block
before showing the session picker. This loads user keybindings and sets
them globally.

The current fix results in double-init of keybindings when entering
interactive mode which _should_ be harmless, since it's the same same
config loaded twice, but is minimal and only affects the `--resume`
path.

I considered passing keybindings from `main()` to `InteractiveMode` -
it's cleaner but requires API changes.

Also documented the `select*` keybindings in README.md.
This commit is contained in:
Aos Dabbagh 2026-01-11 12:55:43 -05:00 committed by Mario Zechner
parent da6a2fb5ea
commit 23a4fd1159
2 changed files with 8 additions and 0 deletions

View file

@ -347,6 +347,10 @@ All keyboard shortcuts can be customized via `~/.pi/agent/keybindings.json`. Eac
| `toggleThinking` | `ctrl+t` | Toggle thinking |
| `externalEditor` | `ctrl+g` | Open external editor |
| `followUp` | `alt+enter` | Queue follow-up message |
| `selectUp` | `up` | Move selection up in lists (session picker, model selector) |
| `selectDown` | `down` | Move selection down in lists |
| `selectConfirm` | `enter` | Confirm selection |
| `selectCancel` | `escape`, `ctrl+c` | Cancel selection |
**Example (Emacs-style):**