ensure we get reindex progress on mount

This commit is contained in:
Josh Hawkins 2024-10-13 16:14:43 -05:00
parent afc668fe0a
commit 97097556c7

View File

@ -193,6 +193,17 @@ export default function Explore() {
// embeddings reindex progress // embeddings reindex progress
const { send: sendReindexCommand } = useWs(
"embeddings_reindex_progress",
"embeddingsReindexProgress",
);
useEffect(() => {
sendReindexCommand("embeddingsReindexProgress");
// only run on mount
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const { payload: reindexProgress } = useEmbeddingsReindexProgress(); const { payload: reindexProgress } = useEmbeddingsReindexProgress();
const embeddingsReindexing = useMemo(() => { const embeddingsReindexing = useMemo(() => {
@ -210,10 +221,10 @@ export default function Explore() {
// model states // model states
const { send: sendCommand } = useWs("model_state", "modelState"); const { send: sendModelCommand } = useWs("model_state", "modelState");
useEffect(() => { useEffect(() => {
sendCommand("modelState"); sendModelCommand("modelState");
// only run on mount // only run on mount
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, []); }, []);
@ -299,14 +310,18 @@ export default function Explore() {
/> />
</div> </div>
<div className="flex w-96 flex-col gap-2 py-5"> <div className="flex w-96 flex-col gap-2 py-5">
{reindexProgress.time_remaining >= 0 && ( {reindexProgress.time_remaining !== null && (
<div className="mb-3 flex flex-col items-center justify-center gap-1"> <div className="mb-3 flex flex-col items-center justify-center gap-1">
<div className="text-primary-variant"> <div className="text-primary-variant">
Estimated time remaining: {reindexProgress.time_remaining === -1
? "Starting up..."
: "Estimated time remaining:"}
</div> </div>
{formatSecondsToDuration( {reindexProgress.time_remaining >= 0 &&
reindexProgress.time_remaining, (formatSecondsToDuration(
) || "Finishing shortly"} reindexProgress.time_remaining,
) ||
"Finishing shortly")}
</div> </div>
)} )}
<div className="flex flex-row items-center justify-center gap-3"> <div className="flex flex-row items-center justify-center gap-3">