"use client"; import Link from "next/link"; import { HoverCard, HoverCardTrigger, HoverCardContent } from "@/components/ui/hover-card"; import { CircleXIcon } from "lucide-react"; import { useDomain } from "@/hooks/useDomain"; import { unwrapServiceError } from "@/lib/utils"; import useCaptureEvent from "@/hooks/useCaptureEvent"; import { env } from "@/env.mjs"; import { useQuery } from "@tanstack/react-query"; import { ConnectionSyncStatus, RepoIndexingStatus } from "@sourcebot/db"; import { getConnections } from "@/actions"; import { getRepos } from "@/actions"; export const ErrorNavIndicator = () => { const domain = useDomain(); const captureEvent = useCaptureEvent(); const { data: repos, isPending: isPendingRepos, isError: isErrorRepos } = useQuery({ queryKey: ['repos', domain], queryFn: () => unwrapServiceError(getRepos(domain)), select: (data) => data.filter(repo => repo.repoIndexingStatus === RepoIndexingStatus.FAILED), refetchInterval: env.NEXT_PUBLIC_POLLING_INTERVAL_MS, }); const { data: connections, isPending: isPendingConnections, isError: isErrorConnections } = useQuery({ queryKey: ['connections', domain], queryFn: () => unwrapServiceError(getConnections(domain)), select: (data) => data.filter(connection => connection.syncStatus === ConnectionSyncStatus.FAILED), refetchInterval: env.NEXT_PUBLIC_POLLING_INTERVAL_MS, }); if (isPendingRepos || isErrorRepos || isPendingConnections || isErrorConnections) { return null; } if (repos.length === 0 && connections.length === 0) { return null; } return ( captureEvent('wa_error_nav_hover', {})}> captureEvent('wa_error_nav_pressed', {})}>
{repos.length + connections.length > 0 && ( {repos.length + connections.length} )}
{connections.length > 0 && (

Connection Sync Issues

The following connections have failed to sync:

{connections .slice(0, 10) .map(connection => ( captureEvent('wa_error_nav_job_pressed', {})}>
{connection.name}
))} {connections.length > 10 && (
And {connections.length - 10} more...
)}
)} {repos.length > 0 && (

Repository Indexing Issues

The following repositories failed to index:

{repos .slice(0, 10) .map(repo => ( // Link to the first connection for the repo captureEvent('wa_error_nav_job_pressed', {})}>
{repo.repoName}
))} {repos.length > 10 && (
And {repos.length - 10} more...
)}
)}
); };