"use client"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { useState } from "react"; import { toast } from "sonner"; import { auth } from "@/lib/firebase/config"; import { Link2, CheckCircle2, Copy } from "lucide-react"; interface ProjectLinkerProps { projectId: string; projectName: string; } export function ProjectLinker({ projectId, projectName }: ProjectLinkerProps) { const [workspacePath, setWorkspacePath] = useState(""); const [isLinking, setIsLinking] = useState(false); const [isLinked, setIsLinked] = useState(false); const handleLink = async () => { if (!workspacePath.trim()) { toast.error("Please enter a workspace path"); return; } try { setIsLinking(true); const user = auth.currentUser; if (!user) { toast.error("Not authenticated"); return; } const idToken = await user.getIdToken(); const response = await fetch("/api/extension/link-project", { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${idToken}`, }, body: JSON.stringify({ projectId, workspacePath: workspacePath.trim(), }), }); if (!response.ok) { const error = await response.json(); throw new Error(error.error || "Failed to link extension"); } setIsLinked(true); toast.success("Extension linked successfully!"); } catch (error) { console.error("Failed to link extension:", error); toast.error(error instanceof Error ? error.message : "Failed to link extension"); } finally { setIsLinking(false); } }; const copyProjectId = () => { navigator.clipboard.writeText(projectId); toast.success("Project ID copied to clipboard"); }; return ( Link Browser Extension Connect your Cursor Monitor extension to this project so AI chats are automatically captured. {isLinked ? (
Extension linked to {projectName}
) : ( <>

Copy this ID and add it to your Cursor Monitor extension settings.

setWorkspacePath(e.target.value)} className="font-mono text-sm" />

Enter the full path to your Cursor workspace directory.

)}

How it works:

  1. Copy the Project ID above
  2. Open Cursor Monitor extension settings
  3. Paste the Project ID in the "Vibn Project ID" field
  4. Enter your workspace path here and click "Link Extension"
  5. All AI chats from Cursor will now be captured in this project
); }