mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 23:01:30 +00:00
Fix Escape key handling for Kitty keyboard protocol
Add isEscape() helper that handles both raw (\x1b) and Kitty protocol (\x1b[27u) Escape sequences. Update all components that check for Escape key to use the new helper.
This commit is contained in:
parent
314ef34ebc
commit
f8b6164ecd
11 changed files with 38 additions and 18 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { Editor, isCtrlC, isCtrlD, isCtrlO, isCtrlP, isCtrlT, isShiftTab } from "@mariozechner/pi-tui";
|
||||
import { Editor, isCtrlC, isCtrlD, isCtrlO, isCtrlP, isCtrlT, isEscape, isShiftTab } from "@mariozechner/pi-tui";
|
||||
|
||||
/**
|
||||
* Custom editor that handles Escape and Ctrl+C keys for coding-agent
|
||||
|
|
@ -39,7 +39,7 @@ export class CustomEditor extends Editor {
|
|||
|
||||
// Intercept Escape key - but only if autocomplete is NOT active
|
||||
// (let parent handle escape for autocomplete cancellation)
|
||||
if (data === "\x1b" && this.onEscape && !this.isShowingAutocomplete()) {
|
||||
if (isEscape(data) && this.onEscape && !this.isShowingAutocomplete()) {
|
||||
this.onEscape();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
* Simple text input component for hooks.
|
||||
*/
|
||||
|
||||
import { Container, Input, Spacer, Text } from "@mariozechner/pi-tui";
|
||||
import { Container, Input, isEscape, Spacer, Text } from "@mariozechner/pi-tui";
|
||||
import { theme } from "../theme/theme.js";
|
||||
import { DynamicBorder } from "./dynamic-border.js";
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ export class HookInputComponent extends Container {
|
|||
}
|
||||
|
||||
// Escape to cancel
|
||||
if (keyData === "\x1b") {
|
||||
if (isEscape(keyData)) {
|
||||
this.onCancelCallback();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* Displays a list of string options with keyboard navigation.
|
||||
*/
|
||||
|
||||
import { Container, Spacer, Text } from "@mariozechner/pi-tui";
|
||||
import { Container, isEscape, Spacer, Text } from "@mariozechner/pi-tui";
|
||||
import { theme } from "../theme/theme.js";
|
||||
import { DynamicBorder } from "./dynamic-border.js";
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ export class HookSelectorComponent extends Container {
|
|||
}
|
||||
}
|
||||
// Escape
|
||||
else if (keyData === "\x1b") {
|
||||
else if (isEscape(keyData)) {
|
||||
this.onCancelCallback();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { Model } from "@mariozechner/pi-ai";
|
||||
import { Container, Input, Spacer, Text, type TUI } from "@mariozechner/pi-tui";
|
||||
import { Container, Input, isEscape, Spacer, Text, type TUI } from "@mariozechner/pi-tui";
|
||||
import { getAvailableModels } from "../../../core/model-config.js";
|
||||
import type { SettingsManager } from "../../../core/settings-manager.js";
|
||||
import { fuzzyFilter } from "../../../utils/fuzzy.js";
|
||||
|
|
@ -192,7 +192,7 @@ export class ModelSelectorComponent extends Container {
|
|||
}
|
||||
}
|
||||
// Escape
|
||||
else if (keyData === "\x1b") {
|
||||
else if (isEscape(keyData)) {
|
||||
this.onCancelCallback();
|
||||
}
|
||||
// Pass everything else to search input
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Container, Spacer, TruncatedText } from "@mariozechner/pi-tui";
|
||||
import { Container, isEscape, Spacer, TruncatedText } from "@mariozechner/pi-tui";
|
||||
import { getOAuthProviders, type OAuthProviderInfo } from "../../../core/oauth/index.js";
|
||||
import { loadOAuthCredentials } from "../../../core/oauth/storage.js";
|
||||
import { theme } from "../theme/theme.js";
|
||||
|
|
@ -107,7 +107,7 @@ export class OAuthSelectorComponent extends Container {
|
|||
}
|
||||
}
|
||||
// Escape
|
||||
else if (keyData === "\x1b") {
|
||||
else if (isEscape(keyData)) {
|
||||
this.onCancelCallback();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,13 @@
|
|||
import { type Component, Container, Input, isCtrlC, Spacer, Text, truncateToWidth } from "@mariozechner/pi-tui";
|
||||
import {
|
||||
type Component,
|
||||
Container,
|
||||
Input,
|
||||
isCtrlC,
|
||||
isEscape,
|
||||
Spacer,
|
||||
Text,
|
||||
truncateToWidth,
|
||||
} from "@mariozechner/pi-tui";
|
||||
import type { SessionManager } from "../../../core/session-manager.js";
|
||||
import { fuzzyFilter } from "../../../utils/fuzzy.js";
|
||||
import { theme } from "../theme/theme.js";
|
||||
|
|
@ -139,7 +148,7 @@ class SessionList implements Component {
|
|||
}
|
||||
}
|
||||
// Escape - cancel
|
||||
else if (keyData === "\x1b") {
|
||||
else if (isEscape(keyData)) {
|
||||
if (this.onCancel) {
|
||||
this.onCancel();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { type Component, Container, isCtrlC, Spacer, Text, truncateToWidth } from "@mariozechner/pi-tui";
|
||||
import { type Component, Container, isCtrlC, isEscape, Spacer, Text, truncateToWidth } from "@mariozechner/pi-tui";
|
||||
import { theme } from "../theme/theme.js";
|
||||
import { DynamicBorder } from "./dynamic-border.js";
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ class UserMessageList implements Component {
|
|||
}
|
||||
}
|
||||
// Escape - cancel
|
||||
else if (keyData === "\x1b") {
|
||||
else if (isEscape(keyData)) {
|
||||
if (this.onCancel) {
|
||||
this.onCancel();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue