Files
hermes-agent/ui-tui/src/hooks/useInputHistory.ts

16 lines
484 B
TypeScript
Raw Normal View History

2026-04-15 10:35:08 -05:00
import { useCallback, useRef, useState } from 'react'
2026-04-07 20:44:18 -05:00
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('')
2026-04-15 10:35:08 -05:00
const pushHistory = useCallback((text: string) => {
inputHistory.append(text)
}, [])
2026-04-07 20:44:18 -05:00
return { historyRef, historyIdx, setHistoryIdx, historyDraftRef, pushHistory }
}