diff --git a/frontend/app/settings/_components/agent-settings-section.tsx b/frontend/app/settings/_components/agent-settings-section.tsx index 59fa14f4f..2f187f4d3 100644 --- a/frontend/app/settings/_components/agent-settings-section.tsx +++ b/frontend/app/settings/_components/agent-settings-section.tsx @@ -43,6 +43,7 @@ export function AgentSettingsSection() { const pathname = usePathname(); const focusLlmModel = searchParams.get("focusLlmModel") === "true"; + const [isRestoringFlow, setIsRestoringFlow] = useState(false); const [openLlmSelector, setOpenLlmSelector] = useState(false); const [systemPrompt, setSystemPrompt] = useState(""); @@ -183,6 +184,8 @@ export function AgentSettingsSection() { }; const handleRestoreRetrievalFlow = (closeDialog: () => void) => { + setIsRestoringFlow(true); + fetch("/api/reset-flow/retrieval", { method: "POST" }) .then((res) => { if (res.ok) return res.json(); @@ -190,12 +193,15 @@ export function AgentSettingsSection() { }) .then(() => { setSystemPrompt(DEFAULT_AGENT_SETTINGS.system_prompt); + toast.success("Default agent flow settings restored successfully"); closeDialog(); }) .catch((err) => { console.error("Error restoring retrieval flow:", err); + toast.error("Failed to restore default agent flow settings"); closeDialog(); - }); + }) + .finally(() => setIsRestoringFlow(false)); }; return ( @@ -223,6 +229,7 @@ export function AgentSettingsSection() { confirmText="Restore" variant="destructive" onConfirm={handleRestoreRetrievalFlow} + isLoading={isRestoringFlow} /> (false); + const [chunkSize, setChunkSize] = useState(1024); const [chunkOverlap, setChunkOverlap] = useState(50); const [chunkValidationError, setChunkValidationError] = useState< @@ -228,6 +230,8 @@ export function IngestSettingsSection() { }; const handleRestoreIngestFlow = (closeDialog: () => void) => { + setIsRestoringFlow(true); + fetch("/api/reset-flow/ingest", { method: "POST" }) .then((res) => { if (res.ok) return res.json(); @@ -241,12 +245,15 @@ export function IngestSettingsSection() { setPictureDescriptions(DEFAULT_KNOWLEDGE_SETTINGS.picture_descriptions); setDisableIngestWithLangflow(false); setChunkValidationError(null); + toast.success("Default ingest flow settings restored successfully"); closeDialog(); }) .catch((err) => { console.error("Error restoring ingest flow:", err); + toast.error("Failed to restore default ingest flow settings"); closeDialog(); - }); + }) + .finally(() => setIsRestoringFlow(false)); }; return ( @@ -274,6 +281,7 @@ export function IngestSettingsSection() { confirmText="Restore" variant="destructive" onConfirm={handleRestoreIngestFlow} + isLoading={isRestoringFlow} /> void; variant?: "default" | "destructive" | "warning"; confirmIcon?: ReactNode | null; + isLoading?: boolean; } export function ConfirmationDialog({ @@ -34,6 +36,7 @@ export function ConfirmationDialog({ onCancel, variant = "default", confirmIcon = null, + isLoading = false, }: ConfirmationDialogProps) { const [open, setOpen] = useState(false); @@ -61,7 +64,13 @@ export function ConfirmationDialog({ -