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:
Brooklyn Nicholson 2026-04-25 14:17:04 -05:00
parent fdcbd2257b
commit a046483e86
6 changed files with 102 additions and 57 deletions

View 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
}