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.

892 B
Raw Blame
import { getDashboardListPath, getDashboardPath } from '@/features/Dashboard/utils/path';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useChatStore } from '@/store/chat';

/**
 * Leave the conversation for a dashboard — inside its project when it has one
 * — or for a board list: the widget project's when it lives in one, else the
 * home dashboard list. The portal stack is this conversation's inspection
 * session, so it is cleared on the way out.
 */
export const useOpenDashboard = () => {
  const navigate = useWorkspaceAwareNavigate();
  const clearPortalStack = useChatStore((s) => s.clearPortalStack);

  return (dashboard?: { id: string; projectId?: string | null }, projectId?: string | null) => {
    clearPortalStack();
    navigate(dashboard ? getDashboardPath(dashboard) : getDashboardListPath(projectId));
  };
};