Skip to content

fix: added visual loading spinner and success/error toast when restoring default langflow flows#1931

Open
Vchen7629 wants to merge 2 commits into
mainfrom
restore-flow-ui-feedback-fix
Open

fix: added visual loading spinner and success/error toast when restoring default langflow flows#1931
Vchen7629 wants to merge 2 commits into
mainfrom
restore-flow-ui-feedback-fix

Conversation

@Vchen7629

@Vchen7629 Vchen7629 commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #1286 , Adds loading state feedback for the restore retrieval flow functionality to improve user experience.

Demo (Before)

screen-capture.4.webm

Demo (After)

screen-capture.2.webm

Changes

Testing

  • Confirmed that button is disabled during loading by checking network requests when loading
  • Confirmed that the spinner animation displays correctly
  • Tested restore flow with successful completion
  • Tested restore flow with error handling by disabling backend docker container before restoring

Summary by CodeRabbit

Release Notes

  • New Features
    • Restore flow operations in settings now display a loading indicator while processing, with the confirm button disabled during the operation to provide clearer feedback on async progress.

@Vchen7629 Vchen7629 requested a review from hunterxtang June 18, 2026 20:49
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

ConfirmationDialog gains an optional isLoading prop that disables the confirm button and shows a Loader2 spinner. Both AgentSettingsSection and IngestSettingsSection add an isRestoringFlow state to track in-flight restore requests, add success/error toast notifications, and pass the flag to their respective confirmation dialogs.

Changes

Restore flow loading state and toast feedback

Layer / File(s) Summary
ConfirmationDialog isLoading prop and spinner
frontend/components/confirmation-dialog.tsx
Imports Loader2, adds optional isLoading?: boolean to ConfirmationDialogProps (defaults false), and updates the confirm button to disable itself and render the spinning icon while loading.
Agent settings restore lifecycle
frontend/app/settings/_components/agent-settings-section.tsx
Adds isRestoringFlow state; handleRestoreRetrievalFlow sets it before the POST, resets systemPrompt to DEFAULT_AGENT_SETTINGS.system_prompt and shows a success toast on success, shows an error toast on failure, clears the flag in .finally(). Wires isLoading={isRestoringFlow} into the confirmation dialog.
Ingest settings restore lifecycle
frontend/app/settings/_components/ingest-settings-section.tsx
Adds isRestoringFlow state; handleRestoreIngestFlow sets it before the POST, shows success/error toasts, closes the dialog in both outcomes, and clears the flag in .finally(). Wires isLoading={isRestoringFlow} into the confirmation dialog.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

bug, enhancement

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: adding visual loading spinner and success/error toast notifications to the restore flow feature.
Linked Issues check ✅ Passed The PR comprehensively addresses issue #1286 by implementing visual loading indicators, success/error notifications, and button disabling to prevent duplicate requests.
Out of Scope Changes check ✅ Passed All changes are directly related to addressing the restore flow UI feedback issue. No extraneous modifications or unrelated refactoring is present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch restore-flow-ui-feedback-fix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added frontend 🟨 Issues related to the UI/UX bug 🔴 Something isn't working. labels Jun 18, 2026
@github-actions github-actions Bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Jun 18, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
frontend/app/settings/_components/ingest-settings-section.tsx (1)

235-239: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid unconditional JSON parsing on successful restore response.

At Line 237, parsing JSON for every successful response can throw on empty success responses and incorrectly trigger the error toast path.

Suggested fix
 fetch("/api/reset-flow/ingest", { method: "POST" })
   .then((res) => {
-    if (res.ok) return res.json();
-    throw new Error(`HTTP ${res.status}: ${res.statusText}`);
+    if (!res.ok) throw new Error(`HTTP ${res.status}: ${res.statusText}`);
+    return res;
+  })
+  .then(async (res) => {
+    const contentType = res.headers.get("content-type") || "";
+    if (contentType.includes("application/json")) {
+      await res.json();
+    }
+    return;
   })
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/app/settings/_components/ingest-settings-section.tsx` around lines
235 - 239, The fetch call to "/api/reset-flow/ingest" with POST method
unconditionally calls res.json() on successful responses, which will throw an
error for empty response bodies and incorrectly trigger error handling even
though the request succeeded. Modify the .then() handler to check if the
response has content (by checking the Content-Length header or response size)
before attempting to parse JSON, or conditionally return the parsed JSON only
when the body is not empty, otherwise return a default success value to avoid
parsing errors on empty successful responses.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/app/settings/_components/agent-settings-section.tsx`:
- Around line 186-193: The handleRestoreRetrievalFlow function unconditionally
calls res.json() for all successful responses, but the endpoint may return a
successful response with an empty body, which causes JSON parsing to fail.
Modify the .then() handler to check if the response has content before
attempting to parse JSON. You can do this by checking the Content-Length header
or the response status, or by using res.text() first and only parsing as JSON if
there is actual content in the response body. This will prevent false error
toasts when the endpoint returns a successful empty response.

---

Outside diff comments:
In `@frontend/app/settings/_components/ingest-settings-section.tsx`:
- Around line 235-239: The fetch call to "/api/reset-flow/ingest" with POST
method unconditionally calls res.json() on successful responses, which will
throw an error for empty response bodies and incorrectly trigger error handling
even though the request succeeded. Modify the .then() handler to check if the
response has content (by checking the Content-Length header or response size)
before attempting to parse JSON, or conditionally return the parsed JSON only
when the body is not empty, otherwise return a default success value to avoid
parsing errors on empty successful responses.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 98017bb7-5cf9-4283-9064-e8e3decad1c7

📥 Commits

Reviewing files that changed from the base of the PR and between 89e0400 and 7b773dc.

📒 Files selected for processing (3)
  • frontend/app/settings/_components/agent-settings-section.tsx
  • frontend/app/settings/_components/ingest-settings-section.tsx
  • frontend/components/confirmation-dialog.tsx

Comment on lines 186 to 193
const handleRestoreRetrievalFlow = (closeDialog: () => void) => {
setIsRestoringFlow(true);

fetch("/api/reset-flow/retrieval", { method: "POST" })
.then((res) => {
if (res.ok) return res.json();
throw new Error(`HTTP ${res.status}: ${res.statusText}`);
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Handle successful empty responses without forcing JSON parse.

At Line 191, res.json() is called for every successful response. If the endpoint returns success with no JSON body, this throws and shows a false error toast.

Suggested fix
 fetch("/api/reset-flow/retrieval", { method: "POST" })
   .then((res) => {
-    if (res.ok) return res.json();
+    if (!res.ok) throw new Error(`HTTP ${res.status}: ${res.statusText}`);
+    return res;
+  })
+  .then(async (res) => {
+    const contentType = res.headers.get("content-type") || "";
+    if (contentType.includes("application/json")) {
+      await res.json();
+    }
+    return;
-    throw new Error(`HTTP ${res.status}: ${res.statusText}`);
   })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const handleRestoreRetrievalFlow = (closeDialog: () => void) => {
setIsRestoringFlow(true);
fetch("/api/reset-flow/retrieval", { method: "POST" })
.then((res) => {
if (res.ok) return res.json();
throw new Error(`HTTP ${res.status}: ${res.statusText}`);
})
const handleRestoreRetrievalFlow = (closeDialog: () => void) => {
setIsRestoringFlow(true);
fetch("/api/reset-flow/retrieval", { method: "POST" })
.then((res) => {
if (!res.ok) throw new Error(`HTTP ${res.status}: ${res.statusText}`);
return res;
})
.then(async (res) => {
const contentType = res.headers.get("content-type") || "";
if (contentType.includes("application/json")) {
await res.json();
}
return;
})
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/app/settings/_components/agent-settings-section.tsx` around lines
186 - 193, The handleRestoreRetrievalFlow function unconditionally calls
res.json() for all successful responses, but the endpoint may return a
successful response with an empty body, which causes JSON parsing to fail.
Modify the .then() handler to check if the response has content before
attempting to parse JSON. You can do this by checking the Content-Length header
or the response status, or by using res.text() first and only parsing as JSON if
there is actual content in the response body. This will prevent false error
toasts when the endpoint returns a successful empty response.

@richardz403 richardz403 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Ran locally, tested that visual loading spinner does work correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🔴 Something isn't working. frontend 🟨 Issues related to the UI/UX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: No UI Feedback During Restore flow Process

2 participants