mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-07 02:51:50 +00:00
fix(tui): share overlay close controls
- add reusable overlay key and help-text helpers for picker-style overlays - make model, session, skills, and pager hints consistently support Esc/q close behavior
This commit is contained in:
parent
fdcbd2257b
commit
a046483e86
6 changed files with 102 additions and 57 deletions
41
ui-tui/src/components/overlayControls.tsx
Normal file
41
ui-tui/src/components/overlayControls.tsx
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import { Text, useInput } from '@hermes/ink'
|
||||
|
||||
import type { Theme } from '../theme.js'
|
||||
|
||||
type TextWrap = 'end' | 'middle' | 'truncate' | 'truncate-end' | 'truncate-middle' | 'wrap' | 'wrap-char' | 'wrap-trim'
|
||||
|
||||
export function useOverlayKeys({ disabled = false, onBack, onClose }: OverlayKeysOptions) {
|
||||
useInput((ch, key) => {
|
||||
if (disabled) {
|
||||
return
|
||||
}
|
||||
|
||||
if (ch.toLowerCase() === 'q') {
|
||||
return onClose()
|
||||
}
|
||||
|
||||
if (key.escape) {
|
||||
return onBack ? onBack() : onClose()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function OverlayControls({ children, t, wrap = 'truncate-end' }: OverlayControlsProps) {
|
||||
return (
|
||||
<Text color={t.color.dim} wrap={wrap}>
|
||||
{children}
|
||||
</Text>
|
||||
)
|
||||
}
|
||||
|
||||
interface OverlayControlsProps {
|
||||
children: string
|
||||
t: Theme
|
||||
wrap?: TextWrap
|
||||
}
|
||||
|
||||
interface OverlayKeysOptions {
|
||||
disabled?: boolean
|
||||
onBack?: () => void
|
||||
onClose: () => void
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue