sse events

This commit is contained in:
2026-05-29 16:27:55 +05:30
parent 034e0ad29a
commit 08057f370c
2 changed files with 8 additions and 3 deletions

View File

@@ -22,6 +22,7 @@ import CheckCircleIcon from "@mui/icons-material/CheckCircle";
import ErrorIcon from "@mui/icons-material/Error"; import ErrorIcon from "@mui/icons-material/Error";
import WarningAmberIcon from "@mui/icons-material/WarningAmber"; import WarningAmberIcon from "@mui/icons-material/WarningAmber";
import PlayArrowIcon from "@mui/icons-material/PlayArrow"; import PlayArrowIcon from "@mui/icons-material/PlayArrow";
import RemoveCircleOutlineIcon from "@mui/icons-material/RemoveCircleOutline";
import { import {
useFetchRequest, useFetchRequest,
useUpdateFetchRequest, useUpdateFetchRequest,
@@ -55,13 +56,13 @@ const statusIcons: Record<FetchRequestStatus, React.ReactNode> = {
failed: <ErrorIcon sx={{ fontSize: 16 }} />, failed: <ErrorIcon sx={{ fontSize: 16 }} />,
}; };
const stepLabels = ["Load Content", "Extract", "Enrich", "Save"]; const stepLabels = ["Load Content", "Extract", "Validate", "Enrich", "Save"];
function statusToActiveStep(status: FetchRequestStatus): number { function statusToActiveStep(status: FetchRequestStatus): number {
switch (status) { switch (status) {
case "pending": return -1; case "pending": return -1;
case "processing": return 0; case "processing": return 0;
case "paused": return 1; case "paused": return 2;
case "raw_expenses_done": return 2; case "raw_expenses_done": return 2;
case "enriched_done": return 3; case "enriched_done": return 3;
case "completed": return 4; case "completed": return 4;
@@ -74,6 +75,7 @@ function sseIcon(status: SSEEvent["status"]) {
switch (status) { switch (status) {
case "started": return <CircularProgress size={14} />; case "started": return <CircularProgress size={14} />;
case "completed": return <CheckCircleIcon sx={{ fontSize: 16, color: "success.main" }} />; case "completed": return <CheckCircleIcon sx={{ fontSize: 16, color: "success.main" }} />;
case "skipped": return <RemoveCircleOutlineIcon sx={{ fontSize: 16, color: "text.disabled" }} />;
case "paused": return <WarningAmberIcon sx={{ fontSize: 16, color: "warning.main" }} />; case "paused": return <WarningAmberIcon sx={{ fontSize: 16, color: "warning.main" }} />;
} }
} }
@@ -145,6 +147,9 @@ export default function FetchRequestDetail() {
refetchRequest(); refetchRequest();
refetchAmbiguities(); refetchAmbiguities();
} }
if (parsed.status === "completed" || parsed.step === "resume_extract") {
refetchRequest();
}
} catch { } catch {
// ignore malformed events // ignore malformed events
} }

View File

@@ -82,7 +82,7 @@ export interface ResolveAmbiguityPayload {
export interface SSEEvent { export interface SSEEvent {
step: string; step: string;
status: "started" | "completed" | "paused"; status: "started" | "completed" | "skipped" | "paused";
message: string; message: string;
} }