import { useEffect, useState, useRef } from "react"; import { useVirtualizer } from "@tanstack/react-virtual"; import HistoryList from "@/components/HistoryList.tsx"; import HistorySearch from "@/components/HistorySearch.tsx"; import Stats from "@/components/history/Stats.tsx"; import Drawer from "@/components/Drawer.tsx"; import { useStore } from "@/state/store"; function Header() { return (

Shell History

} >
); } export default function Search() { const history = useStore((state) => state.shellHistory); const refreshHistory = useStore((state) => state.refreshShellHistory); const historyNextPage = useStore((state) => state.historyNextPage); let [query, setQuery] = useState(""); useEffect(() => { (async () => { // nothing rn })(); refreshHistory(); }, []); const parentRef = useRef(null); const rowVirtualizer = useVirtualizer({ count: history.length, getScrollElement: () => parentRef.current, estimateSize: () => 90, overscan: 5, }); useEffect(() => { const [lastItem] = rowVirtualizer.getVirtualItems().slice(-1); if (!lastItem) return; // no undefined plz if (lastItem.index < history.length - 1) return; // if we're not at the end yet, bail // we're at the end! more rows plz! historyNextPage(query); }, [rowVirtualizer.getVirtualItems()]); return ( <>

A history of all the commands you run in your shell.

{ setQuery(q); refreshHistory(q); }} refresh={() => { refreshHistory(query); }} />
); }