mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-09 13:21:42 +00:00
opentui(v6): monotonic double-press clock + consume the viewer's closing Esc
This commit is contained in:
parent
f4bb617f62
commit
73b261b94f
2 changed files with 6 additions and 2 deletions
|
|
@ -40,7 +40,9 @@ export interface DoublePress {
|
|||
export function createDoublePress(windowMs: number = DOUBLE_PRESS_WINDOW_MS): DoublePress {
|
||||
let armedAt: number | undefined
|
||||
return {
|
||||
press(now: number = Date.now()): boolean {
|
||||
// performance.now() is monotonic (Node) — an NTP/wall-clock jump between
|
||||
// two presses can't break or spuriously satisfy the window (review finding).
|
||||
press(now: number = performance.now()): boolean {
|
||||
if (armedAt !== undefined && now - armedAt <= windowMs) {
|
||||
armedAt = undefined
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -62,7 +62,9 @@ export function PromptHistory(props: {
|
|||
useKeyboard(key => {
|
||||
if (key.eventType === 'release') return
|
||||
if (key.name === 'escape' || (key.ctrl && key.name === 'c')) {
|
||||
// Esc backs out one level: confirm → list, list → closed.
|
||||
// Esc backs out one level: confirm → list, list → closed. Consumed —
|
||||
// a closing Esc must never reach later global handlers (review finding).
|
||||
key.preventDefault()
|
||||
if (confirming() !== undefined) setConfirming(undefined)
|
||||
else props.onClose()
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue