mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
chore: uptick
This commit is contained in:
parent
9c2c9e3a3e
commit
b397c91d4a
10 changed files with 136 additions and 290 deletions
20
ui-tui/src/hooks/useInputHistory.ts
Normal file
20
ui-tui/src/hooks/useInputHistory.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { 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 = (text: string) => {
|
||||
const trimmed = text.trim()
|
||||
|
||||
if (trimmed && historyRef.current.at(-1) !== trimmed) {
|
||||
historyRef.current.push(trimmed)
|
||||
inputHistory.append(trimmed)
|
||||
}
|
||||
}
|
||||
|
||||
return { historyRef, historyIdx, setHistoryIdx, historyDraftRef, pushHistory }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue