feat: use keybindings in all selectors and lists

Update all selector/list components to use EditorKeybindingsManager:
- model-selector, session-selector, oauth-selector, user-message-selector
- hook-selector, hook-input, hook-editor, tree-selector
- select-list, settings-list, cancellable-loader

This allows users to configure selectUp, selectDown, selectConfirm,
selectCancel actions in keybindings.json
This commit is contained in:
Helmut Januschka 2026-01-03 02:07:28 +01:00
parent 8f2682578b
commit 7574fed2f2
11 changed files with 73 additions and 64 deletions

View file

@ -1,5 +1,5 @@
import { type Model, modelsAreEqual } from "@mariozechner/pi-ai";
import { Container, Input, matchesKey, Spacer, Text, type TUI } from "@mariozechner/pi-tui";
import { Container, getEditorKeybindings, Input, Spacer, Text, type TUI } from "@mariozechner/pi-tui";
import type { ModelRegistry } from "../../../core/model-registry.js";
import type { SettingsManager } from "../../../core/settings-manager.js";
import { fuzzyFilter } from "../../../utils/fuzzy.js";
@ -205,27 +205,28 @@ export class ModelSelectorComponent extends Container {
}
handleInput(keyData: string): void {
const kb = getEditorKeybindings();
// Up arrow - wrap to bottom when at top
if (matchesKey(keyData, "up")) {
if (kb.matches(keyData, "selectUp")) {
if (this.filteredModels.length === 0) return;
this.selectedIndex = this.selectedIndex === 0 ? this.filteredModels.length - 1 : this.selectedIndex - 1;
this.updateList();
}
// Down arrow - wrap to top when at bottom
else if (matchesKey(keyData, "down")) {
else if (kb.matches(keyData, "selectDown")) {
if (this.filteredModels.length === 0) return;
this.selectedIndex = this.selectedIndex === this.filteredModels.length - 1 ? 0 : this.selectedIndex + 1;
this.updateList();
}
// Enter
else if (matchesKey(keyData, "enter")) {
else if (kb.matches(keyData, "selectConfirm")) {
const selectedModel = this.filteredModels[this.selectedIndex];
if (selectedModel) {
this.handleSelect(selectedModel.model);
}
}
// Escape or Ctrl+C
else if (matchesKey(keyData, "escape") || matchesKey(keyData, "ctrl+c")) {
else if (kb.matches(keyData, "selectCancel")) {
this.onCancelCallback();
}
// Pass everything else to search input