perf(webui): restore cached threads and load mention catalogs on demand
This commit is contained in:
1 parent
c370e2a5a5
commit
1a78ae2b99
13 files changed
+316
-65
No files matched your search
@@ -13,6 +13,7 @@ import { hasPendingAgentActivity } from "@/lib/activity-timeline";
|
||||
import { deriveTitle } from "@/lib/format";
|
||||
import { projectThreadEvents } from "@/lib/thread-event-projection";
|
||||
import { webuiThreadCache } from "@/lib/webui-thread-cache";
|
||||
import { readReloadSessions, writeReloadCache } from "@/lib/reload-cache";
|
||||
import type {
|
||||
ChatSummary,
|
||||
SessionAutomationJob,
|
||||
@@ -214,7 +215,7 @@ export function useSessions(): {
|
||||
getSessionAutomations: (key: string) => Promise<SessionAutomationJob[]>;
|
||||
} {
|
||||
const { client, token } = useClient();
|
||||
const [sessions, setSessions] = useState<ChatSummary[]>([]);
|
||||
const [sessions, setSessions] = useState<ChatSummary[]>(readReloadSessions);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const tokenRef = useRef(token);
|
||||
@@ -223,6 +224,10 @@ export function useSessions(): {
|
||||
const refreshInFlightRef = useRef<Promise<void> | null>(null);
|
||||
tokenRef.current = token;
|
||||
|
||||
useEffect(() => {
|
||||
if (sessions.length || !loading) writeReloadCache("sessions", sessions.slice(0, 200));
|
||||
}, [sessions, loading]);
|
||||
|
||||
const refresh = useCallback((): Promise<void> => {
|
||||
refreshPendingRef.current = true;
|
||||
if (refreshInFlightRef.current) return refreshInFlightRef.current;
|
||||
|
||||
Reference in new issue
Block a user