import { useQuery } from '@tanstack/react-query'; import { Link } from 'react-router'; import { Globe, Loader2, X, Eye } from 'lucide-react'; import { toast } from 'sonner'; import { useClient } from 'hooks/useClient'; import { browserTabPath, useBrowserTargets, useSelectedTabId, type BrowserTarget } from './shared'; export const TabList = () => { const client = useClient(); const selectedId = useSelectedTabId(); const { data: status } = useQuery({ queryKey: ['browser-status'], queryFn: () => client.get<{ extensionConnected: boolean; targetCount: number }>('/browser/status'), refetchInterval: 5000, }); const { data: targets, isLoading } = useBrowserTargets(!!status?.extensionConnected); const targetList: BrowserTarget[] = targets ?? []; const handleClose = async (targetId: string) => { try { await client.post(`/browser/targets/${targetId}/close`); } catch { toast.error('Failed to close tab'); } }; const handleActivate = async (targetId: string) => { try { await client.post(`/browser/targets/${targetId}/activate`); } catch { toast.error('Failed to activate tab'); } }; const isConnected = status?.extensionConnected ?? false; return (
Browser
{!isConnected && (

Extension not connected

{/* A , not an : a raw href to an in-app route reloads the whole SPA. */} Set up in Integrations
)} {isConnected && isLoading && (
)} {isConnected && !isLoading && targetList.length === 0 && (
No tabs attached Click the extension icon on a tab
)} {isConnected && targetList.length > 0 && (
{/* Focus and Close are siblings of the anchor, not children of it: an may not contain a
))}
)} ); };