UNPKG

@assistant-ui/react

Version:

Open-source TypeScript/React library for building production-grade AI chat experiences

35 lines (34 loc) • 1.18 kB
"use client"; import { createActionButton } from "../../utils/createActionButton.js"; import { c } from "@assistant-ui/tap/react-shim/compiler-runtime"; import "@assistant-ui/tap/react-shim"; import { useAui, useAuiState } from "@assistant-ui/store"; // src/primitives/thread/ThreadLoadEarlier.tsx const useThreadLoadEarlier = () => { const $ = c(2); const aui = useAui(); const hasEarlier = useAuiState(_temp); let t0; if ($[0] !== aui.thread) { t0 = () => { aui.thread.loadEarlier(); }; $[0] = aui.thread; $[1] = t0; } else t0 = $[1]; const loadEarlier = t0; if (!hasEarlier) return null; return loadEarlier; }; /** * A button that loads the page before the first loaded message. Disabled * while the runtime reports no earlier messages. A press while a page is * loading joins that load, so the button stays enabled and keeps keyboard * focus until the page lands; read `thread.isLoadingEarlier` to show progress. */ const ThreadPrimitiveLoadEarlier = createActionButton("ThreadPrimitive.LoadEarlier", useThreadLoadEarlier); function _temp(s) { return s.thread.hasEarlier; } export { ThreadPrimitiveLoadEarlier }; //# sourceMappingURL=ThreadLoadEarlier.js.map