Skip to content

fix(scans): replace error banner with toast feedback for delete and rescan failures#1666

Open
NaitikVerma6776 wants to merge 2 commits into
utksh1:mainfrom
NaitikVerma6776:fix/scans-replace-alerts-with-toast
Open

fix(scans): replace error banner with toast feedback for delete and rescan failures#1666
NaitikVerma6776 wants to merge 2 commits into
utksh1:mainfrom
NaitikVerma6776:fix/scans-replace-alerts-with-toast

Conversation

@NaitikVerma6776

Copy link
Copy Markdown
Contributor

Description

The Scans page was using setError() to display a persistent error banner for delete, clear-history, and bulk-delete failures, which was inconsistent with the rest of the app's non-blocking toast pattern. The rescan failure had no user feedback at all — only a console.error.
Changes:

  • Added useToast import and hook to Scans.tsx
  • Replaced all 3 setError() calls in catch blocks with addToasterror
  • Added addToast feedback to the previously-silent rescan failure catch
  • Updated existing test (handles clearAllTasks failure correctly) to reflect the new toast-based pattern
  • Added ToastProvider wrapper to all 3 existing Scans test files so useToast no longer throws
  • Added frontend/testing/unit/pages/ScansToastErrors.test.tsx with 4 focused tests covering the new toast behavior

Related Issues

Closes #1396

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

All 28 tests across the full Scans test suite pass locally via npm test (Scans.test.tsx, Scans.polling.test.tsx, ScansPhases.test.tsx, ScansToastErrors.test.tsx).

Checklist

  • My code follows the code style of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand
  • My changes generate no new warnings

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

The direction of this fix is correct — replacing setError() with addToast() for failure feedback is the right approach. However, it's incomplete:

1. Dead error banner code was left behind:
After replacing all setError(...) calls in catch blocks with addToast(...), the error banner infrastructure is now orphaned:

  • const [error, setError] = useState<string | null>(null) is still declared
  • The entire {error && (<div role="alert" ...>) } JSX block is untouched
  • Several setError(null) calls remain scattered (filter change, pagination, modal reset)

No catch block sets setError with a user-facing message anymore, making the banner dead code. Please remove:

  • The error state declaration
  • The {error && (...)} JSX block
  • All setError(null) calls that are now no-ops

2. Minor: ScansToastErrors.test.tsx is missing a trailing newline.

Once the dead code is cleaned up, this is a clean, well-tested fix that's ready to merge.

@utksh1 utksh1 added level:intermediate 35 pts difficulty label for moderate contributor PRs type:bug Bug fix work category bonus label area:frontend Frontend React/UI work labels Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:frontend Frontend React/UI work level:intermediate 35 pts difficulty label for moderate contributor PRs type:bug Bug fix work category bonus label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FRONTEND] Replace Scans page browser alerts with toast error feedback

2 participants