import { useState, useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; import { OnboardStep } from '../types'; import { StepContent } from '../components/StepContent'; import LoaderIcon from '@/assets/icons/loader.svg?react'; import ConnectedIcon from '@/assets/icons/connected.svg?react'; import { ServerEvents, useSocket } from '@/lib/contexts/SocketContext'; import type { McpConnectedPayload } from '@/features/logs/hooks/useMcpUsage'; const STEP_DESCRIPTIONS = [ 'Install Node.js', 'Install InsForge MCP', 'Test the Connection', ] as const; const STEPS = [ { id: OnboardStep.INSTALL_NODEJS, title: STEP_DESCRIPTIONS[0] }, { id: OnboardStep.INSTALL_MCP, title: STEP_DESCRIPTIONS[1] }, { id: OnboardStep.TEST_CONNECTION, title: STEP_DESCRIPTIONS[2] }, ] as const; export default function OnBoardPage() { const [mcpDetected, setMcpDetected] = useState(false); const navigate = useNavigate(); const { socket } = useSocket(); // Navigate to dashboard on successful connection useEffect(() => { if (!socket) { return; } const handleMcpCallDetected = (_data: McpConnectedPayload) => { setMcpDetected(true); // Navigate to dashboard to show success message void navigate('/dashboard', { state: { showSuccessBanner: true } }); }; socket.on(ServerEvents.MCP_CONNECTED, handleMcpCallDetected); return () => { socket.off(ServerEvents.MCP_CONNECTED, handleMcpCallDetected); }; }, [socket, navigate]); return (
{/* Fixed Header */}
{!mcpDetected ? (

Waiting for Connection

) : (

Successfully Connected! Redirecting to Dashboard...

)}

Get Started by Connecting to Your Coding Agent

{/* Scrollable Content Area */}
{/* Left: Vertical Stepper line */}
{/* Right: All Step Contents */}
{STEPS.map((step, index) => (
{/* Step number circle */}
{index + 1}
{/* Step title and content */}

{step.title}

))}
); }