import { AlertTriangle, RefreshCw } from "lucide-react"; import { useState } from "react"; import type { TaskIdIntegrityReport } from "@fusion/core"; import { refreshDashboardHealth } from "../api"; import "./TaskIdIntegrityBanner.css"; interface TaskIdIntegrityBannerProps { report: TaskIdIntegrityReport; recommendedAction: string; onRefresh?: (report: TaskIdIntegrityReport, recommendedAction: string | null) => void; } const ANOMALY_LABELS: Record = { duplicate_active_id: "Duplicate active task ID", id_in_active_and_archived: "Task ID present in active and archived storage", next_sequence_at_or_below_used: "Allocator next sequence overlaps an existing task ID", task_row_outside_known_prefix: "Task row uses a prefix outside allocator state", }; function formatAffectedIds(affectedIds: string[]): string { if (affectedIds.length <= 5) { return affectedIds.join(", "); } const visible = affectedIds.slice(0, 5).join(", "); return `${visible} +${affectedIds.length - 5} more`; } export function TaskIdIntegrityBanner({ report, recommendedAction, onRefresh }: TaskIdIntegrityBannerProps) { const [refreshing, setRefreshing] = useState(false); const [refreshError, setRefreshError] = useState(null); if (report.status !== "anomaly") { return null; } const handleRefresh = async () => { setRefreshing(true); setRefreshError(null); try { const health = await refreshDashboardHealth(); onRefresh?.(health.taskIdIntegrity, health.taskIdIntegrity.recommendedAction); } catch (error) { setRefreshError(error instanceof Error ? error.message : "Failed to refresh integrity status."); } finally { setRefreshing(false); } }; return (

Fusion found allocator state that can cause task IDs to be reused or overwrite live task records.

    {report.anomalies.map((anomaly) => (
  • {ANOMALY_LABELS[anomaly.kind]} {anomaly.details} {formatAffectedIds(anomaly.affectedIds)}
  • ))}

{recommendedAction}

{refreshError ?

{refreshError}

: null}
); }