mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-30 01:41:43 +00:00
perf(tui): optimistically echo simple input
This commit is contained in:
parent
19d75d1797
commit
9bb3bc422d
1 changed files with 5 additions and 1 deletions
|
|
@ -10,11 +10,12 @@ import { isActionMod, isMac, isMacActionFallback } from '../lib/platform.js'
|
|||
type InkExt = typeof Ink & {
|
||||
stringWidth: (s: string) => number
|
||||
useDeclaredCursor: (a: { line: number; column: number; active: boolean }) => (el: any) => void
|
||||
useStdout: () => { stdout?: NodeJS.WriteStream }
|
||||
useTerminalFocus: () => boolean
|
||||
}
|
||||
|
||||
const ink = Ink as unknown as InkExt
|
||||
const { Box, Text, useStdin, useInput, stringWidth, useDeclaredCursor, useTerminalFocus } = ink
|
||||
const { Box, Text, useStdin, useInput, useStdout, stringWidth, useDeclaredCursor, useTerminalFocus } = ink
|
||||
|
||||
const ESC = '\x1b'
|
||||
const INV = `${ESC}[7m`
|
||||
|
|
@ -293,6 +294,7 @@ export function TextInput({
|
|||
const [sel, setSel] = useState<null | { end: number; start: number }>(null)
|
||||
const fwdDel = useFwdDelete(focus)
|
||||
const termFocus = useTerminalFocus()
|
||||
const { stdout } = useStdout()
|
||||
|
||||
const curRef = useRef(cur)
|
||||
const selRef = useRef<null | { end: number; start: number }>(null)
|
||||
|
|
@ -787,6 +789,7 @@ export function TextInput({
|
|||
!selected &&
|
||||
!mask &&
|
||||
!placeholder &&
|
||||
!!stdout?.isTTY &&
|
||||
c === v.length &&
|
||||
!v.includes('\n') &&
|
||||
stringWidth(text) === text.length &&
|
||||
|
|
@ -796,6 +799,7 @@ export function TextInput({
|
|||
c += text.length
|
||||
|
||||
if (simpleAppend) {
|
||||
stdout!.write(text)
|
||||
commit(v, c, true, false)
|
||||
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue