diff --git a/src/Web/autopilot-monitor-web/app/sessions/[sessionId]/components/ReportSessionModal.tsx b/src/Web/autopilot-monitor-web/app/sessions/[sessionId]/components/ReportSessionModal.tsx index 59a56574..094b7311 100644 --- a/src/Web/autopilot-monitor-web/app/sessions/[sessionId]/components/ReportSessionModal.tsx +++ b/src/Web/autopilot-monitor-web/app/sessions/[sessionId]/components/ReportSessionModal.tsx @@ -1,6 +1,6 @@ "use client"; -import { useState } from "react"; +import { useState, useEffect } from "react"; import { Session, EnrollmentEvent, RuleResult } from "../page"; const MAX_AGENT_LOG_SIZE = 5 * 1024 * 1024; // 5 MB @@ -27,6 +27,15 @@ export default function ReportSessionModal({ const [screenshotFile, setScreenshotFile] = useState(null); const [agentLogFile, setAgentLogFile] = useState(null); const [agentLogError, setAgentLogError] = useState(null); + const [submitResult, setSubmitResult] = useState<'success' | 'error' | null>(null); + const [submitErrorMessage, setSubmitErrorMessage] = useState(null); + + useEffect(() => { + if (show) { + setSubmitResult(null); + setSubmitErrorMessage(null); + } + }, [show]); if (!show || !session) return null; @@ -63,17 +72,28 @@ export default function ReportSessionModal({ agentLogFileName = agentLogFile.name; } - await onSubmit(comment, email, screenshotBase64, screenshotFileName, agentLogBase64, agentLogFileName); - // Reset form on successful submit - setComment(""); - setEmail(""); - setScreenshotFile(null); - setAgentLogFile(null); - setAgentLogError(null); + try { + await onSubmit(comment, email, screenshotBase64, screenshotFileName, agentLogBase64, agentLogFileName); + setSubmitResult('success'); + setComment(""); + setEmail(""); + setScreenshotFile(null); + setAgentLogFile(null); + setAgentLogError(null); + } catch (err: any) { + setSubmitResult('error'); + setSubmitErrorMessage(err?.message || 'Failed to submit report.'); + } + }; + + const handleClose = () => { + setSubmitResult(null); + setSubmitErrorMessage(null); + onCancel(); }; return ( -
+
e.stopPropagation()}>
{/* Header */} @@ -91,117 +111,160 @@ export default function ReportSessionModal({
- {/* Explanation */} -

- Submit this session for analysis by the Autopilot Monitor team. The event timeline, - session data, analysis results, and UI exports will be included so discrepancies - can be analyzed and improvements made. -

+ {/* Submit result feedback */} + {submitResult === 'success' && ( +
+ + + +
+

Report submitted successfully

+

+ The session has been submitted for analysis by the Autopilot Monitor team. +

+
+
+ )} - {/* Comment */} -
- -