feat(tui): add circular wrap-around navigation to all menus (#82)

Co-authored-by: xes garcia <xes.garcia@deus.ai>
This commit is contained in:
butelo 2025-12-01 02:49:38 +01:00 committed by GitHub
parent d2b60f11eb
commit cc9773b34e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 12 deletions

View file

@ -185,14 +185,14 @@ export class ModelSelectorComponent extends Container {
}
handleInput(keyData: string): void {
// Up arrow
// Up arrow - wrap to bottom when at top
if (keyData === "\x1b[A") {
this.selectedIndex = Math.max(0, this.selectedIndex - 1);
this.selectedIndex = this.selectedIndex === 0 ? this.filteredModels.length - 1 : this.selectedIndex - 1;
this.updateList();
}
// Down arrow
// Down arrow - wrap to top when at bottom
else if (keyData === "\x1b[B") {
this.selectedIndex = Math.min(this.filteredModels.length - 1, this.selectedIndex + 1);
this.selectedIndex = this.selectedIndex === this.filteredModels.length - 1 ? 0 : this.selectedIndex + 1;
this.updateList();
}
// Enter

View file

@ -78,13 +78,13 @@ class UserMessageList implements Component {
}
handleInput(keyData: string): void {
// Up arrow - go to previous (older) message
// Up arrow - go to previous (older) message, wrap to bottom when at top
if (keyData === "\x1b[A") {
this.selectedIndex = Math.max(0, this.selectedIndex - 1);
this.selectedIndex = this.selectedIndex === 0 ? this.messages.length - 1 : this.selectedIndex - 1;
}
// Down arrow - go to next (newer) message
// Down arrow - go to next (newer) message, wrap to top when at bottom
else if (keyData === "\x1b[B") {
this.selectedIndex = Math.min(this.messages.length - 1, this.selectedIndex + 1);
this.selectedIndex = this.selectedIndex === this.messages.length - 1 ? 0 : this.selectedIndex + 1;
}
// Enter - select message and branch
else if (keyData === "\r") {

View file

@ -145,14 +145,14 @@ export class SelectList implements Component {
}
handleInput(keyData: string): void {
// Up arrow
// Up arrow - wrap to bottom when at top
if (keyData === "\x1b[A") {
this.selectedIndex = Math.max(0, this.selectedIndex - 1);
this.selectedIndex = this.selectedIndex === 0 ? this.filteredItems.length - 1 : this.selectedIndex - 1;
this.notifySelectionChange();
}
// Down arrow
// Down arrow - wrap to top when at bottom
else if (keyData === "\x1b[B") {
this.selectedIndex = Math.min(this.filteredItems.length - 1, this.selectedIndex + 1);
this.selectedIndex = this.selectedIndex === this.filteredItems.length - 1 ? 0 : this.selectedIndex + 1;
this.notifySelectionChange();
}
// Enter