chore: uptick

This commit is contained in:
Brooklyn Nicholson 2026-04-07 20:44:18 -05:00
parent 9c2c9e3a3e
commit b397c91d4a
10 changed files with 136 additions and 290 deletions

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