Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

491 B
Raw Blame
import { useCallback } from 'react';

import { getAgentStoreState } from '@/store/agent';

/**
 * Returns a callback that warms an agent's config before navigation (call it
 * on mouseEnter). The config lands in `agentMap`, so the page paints it on
 * its first frame; agents already there are skipped.
 */
export const usePrefetchAgent = () => {
  return useCallback((agentId: string) => {
    if (!agentId) return;

    void getAgentStoreState().prefetchAgentConfig(agentId);
  }, []);
};