import React, { useState, useEffect } from 'react'; import { SessionCreationForm } from './components/SessionCreationForm'; import { SessionProgressMonitor } from './components/SessionProgressMonitor'; import type { HostedSessionConfig } from '../../../packages/domain/entities/HostedSessionConfig'; interface SessionProgress { sessionId: string; currentStep: number; state: string; completedSteps: number[]; hasError: boolean; errorMessage: string | null; } export function App() { const [sessionId, setSessionId] = useState(null); const [progress, setProgress] = useState(null); const [isRunning, setIsRunning] = useState(false); useEffect(() => { if (window.electronAPI) { window.electronAPI.onSessionProgress((newProgress: SessionProgress) => { setProgress(newProgress); if (newProgress.state === 'COMPLETED' || newProgress.state === 'FAILED' || newProgress.state === 'STOPPED_AT_STEP_18') { setIsRunning(false); } }); } }, []); const handleStartAutomation = async (config: HostedSessionConfig) => { setIsRunning(true); const result = await window.electronAPI.startAutomation(config); if (result.success && result.sessionId) { setSessionId(result.sessionId); } else { setIsRunning(false); alert(`Failed to start automation: ${result.error}`); } }; const handleStopAutomation = async () => { if (sessionId) { const result = await window.electronAPI.stopAutomation(sessionId); if (result.success) { setIsRunning(false); setProgress(prev => prev ? { ...prev, state: 'STOPPED', hasError: false, errorMessage: 'User stopped automation' } : null); } else { alert(`Failed to stop automation: ${result.error}`); } } }; return (

GridPilot Companion

Hosted Session Automation POC

{isRunning && ( )}
); }