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.

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

import { useAgentGroupStore } from '@/store/agentGroup';
import { useChatStore } from '@/store/chat';

/**
 * Closing the DM panel forgets which member it was with, then hands the close
 * to the host when it supplied one — otherwise the whole portal stack closes.
 */
export const useGroupThreadClose = (onClose?: () => void) => {
  const clearPortalStack = useChatStore((s) => s.clearPortalStack);

  return useCallback(() => {
    useAgentGroupStore.setState({ activeThreadAgentId: '' });
    (onClose ?? clearPortalStack)();
  }, [clearPortalStack, onClose]);
};