mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 05:12:14 +00:00
Coach conversation history was capped at the rail's first ~20 threads and searched only that loaded page. The rail and the standalone conversations page now walk the caller's entire history via cursor pagination (useInfiniteQuery + a scroll sentinel), and search runs server-side against the conversation title (GET /api/insights/chat?q=) instead of filtering an already-truncated client array. Also extends the "automatic screening" info line in the metric catalog to name the labs "what changed since your last panel" card alongside the rhythm/breathing/health-status watchdogs it already covered — it un-mounts the same way when there's nothing to flag and was missing from the copy.
23 lines
753 B
TypeScript
23 lines
753 B
TypeScript
"use client";
|
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
/**
|
|
* Debounces a fast-changing value (typically a search-input draft) so a
|
|
* dependent effect / query key only reacts once the value has settled for
|
|
* `delayMs`. Mirrors the inline 200 ms pattern the Dokumente vault search
|
|
* already used (`documents-view.tsx`), centralised here so other search
|
|
* surfaces (v1.30.2 — the Coach conversation history) don't hand-roll the
|
|
* same timeout.
|
|
*/
|
|
export function useDebouncedValue<T>(value: T, delayMs = 200): T {
|
|
const [debounced, setDebounced] = useState(value);
|
|
|
|
useEffect(() => {
|
|
const handle = setTimeout(() => setDebounced(value), delayMs);
|
|
return () => clearTimeout(handle);
|
|
}, [value, delayMs]);
|
|
|
|
return debounced;
|
|
}
|