Files
hermes-agent/ui-tui/src/hooks/useInputHistory.ts
Brooklyn Nicholson 9931d1d814 chore: cleanup
2026-04-15 10:35:08 -05:00

16 lines
484 B
TypeScript

import { useCallback, useRef, useState } from 'react'
import * as inputHistory from '../lib/history.js'
export function useInputHistory() {
const historyRef = useRef<string[]>(inputHistory.load())
const [historyIdx, setHistoryIdx] = useState<number | null>(null)
const historyDraftRef = useRef('')
const pushHistory = useCallback((text: string) => {
inputHistory.append(text)
}, [])
return { historyRef, historyIdx, setHistoryIdx, historyDraftRef, pushHistory }
}