- Added token-aware query matching so highlights mirror `HistoryStorage.search` tokenization. - Added token highlighting, compact relative timestamps, and selected-row styling in results. - Added PageUp/PageDown and Home/End selection shortcuts in `HistorySearchComponent`. - Added selector matchers for `tui.select.pageUp` and `tui.select.pageDown`. - Changed empty-result messaging to distinguish `No history yet` from `No matching history`. - Added tests for page/home/end navigation and token-highlighting result rendering.
52 lines
1.8 KiB
TypeScript
52 lines
1.8 KiB
TypeScript
import { getKeybindings, matchesKey } from "@oh-my-pi/pi-tui";
|
|
|
|
/**
|
|
* Match the coding-agent interrupt key.
|
|
*
|
|
* Interactive mode installs a keybinding manager that exposes `app.interrupt`
|
|
* globally, but some isolated component tests still run with only TUI
|
|
* keybindings registered. In that case, fall back to raw Escape matching.
|
|
*/
|
|
export function matchesAppInterrupt(data: string): boolean {
|
|
const keybindings = getKeybindings();
|
|
const interruptKeys = keybindings.getKeys("app.interrupt");
|
|
if (interruptKeys.length > 0) {
|
|
return keybindings.matches(data, "app.interrupt");
|
|
}
|
|
return matchesKey(data, "escape") || matchesKey(data, "esc");
|
|
}
|
|
|
|
/** Match the generic selector cancel keybinding. */
|
|
export function matchesSelectCancel(data: string): boolean {
|
|
return getKeybindings().matches(data, "tui.select.cancel");
|
|
}
|
|
|
|
/** Match the generic selector up-navigation keybinding. */
|
|
export function matchesSelectUp(data: string): boolean {
|
|
return getKeybindings().matches(data, "tui.select.up");
|
|
}
|
|
|
|
/** Match the generic selector down-navigation keybinding. */
|
|
export function matchesSelectDown(data: string): boolean {
|
|
return getKeybindings().matches(data, "tui.select.down");
|
|
}
|
|
|
|
/** Match the generic selector page-up keybinding. */
|
|
export function matchesSelectPageUp(data: string): boolean {
|
|
return getKeybindings().matches(data, "tui.select.pageUp");
|
|
}
|
|
|
|
/** Match the generic selector page-down keybinding. */
|
|
export function matchesSelectPageDown(data: string): boolean {
|
|
return getKeybindings().matches(data, "tui.select.pageDown");
|
|
}
|
|
|
|
export function matchesAppExternalEditor(data: string): boolean {
|
|
const keybindings = getKeybindings();
|
|
const externalEditorKeys = keybindings.getKeys("app.editor.external");
|
|
if (externalEditorKeys.length > 0) {
|
|
return keybindings.matches(data, "app.editor.external");
|
|
}
|
|
return matchesKey(data, "ctrl+g");
|
|
}
|