Skip to content

fix: show error widget when content fails to load #84 - #651

Open
AzazelSensei wants to merge 1 commit into
CircuitVerse:masterfrom
AzazelSensei:fix-error-widget#84
Open

AzazelSensei wants to merge 1 commit into
CircuitVerse:masterfrom
AzazelSensei:fix-error-widget#84

Conversation

@AzazelSensei

@AzazelSensei AzazelSensei commented Sep 1, 2026 •

Copy link
Copy Markdown

Fixes #84

Describe the changes you have made in this PR -
Added a CVException widget and wired it into the screens that fetch over the network. When a load fails (no internet, API error, etc.) those views now show the error message instead of looking empty.

Screenshots of the changes (If any) -

Note: Please check Allow edits from maintainers. if you would like us to assist in the PR.

Summary by CodeRabbit

  • New Features

    • Added consistent error screens with a cloud-off icon and clear messages across assignment, group, chapter, notification, favourite, project, and featured project views.
    • Empty group states now appear only when data loads successfully without results.
  • Bug Fixes

    • Improved visibility of fetch and search failures instead of showing blank or misleading content.
  • Tests

    • Added coverage for the shared error display and featured project error handling.

API screens now show CVException instead of an empty view when a fetch fails.
@netlify

netlify Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

❌ Deploy Preview for cv-mobile-app-web failed.

Name Link
🔨 Latest commit fd59793
🔍 Latest deploy log https://app.netlify.com/projects/cv-mobile-app-web/deploys/6a96e8bf2bfb430008e2e2ef

@coderabbitai

coderabbitai Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Added the public CVException widget with a cloud-off icon and themed error message. Updated group, chapter, notification, profile, featured project, and project detail views to display fetch errors through this widget. Added widget tests for CVException and featured project error rendering.

Merge Risk: 🟡 Moderate · up to fd597

Failed network loads now display error states, but some screens can still show stale or unrelated content, and the affected test currently expects a single error while producing two. The PR is not merge-ready until these bounded rendering and test issues are corrected.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the primary change: showing an error widget when content fails to load. It is concise and references issue #84.
Linked Issues check ✅ Passed The changes satisfy issue #84 by adding the CVException error widget and integrating it into network-dependent views when content loading fails. Tests cover the new widget and a failed featured-projec…
Out of Scope Changes check ✅ Passed The code and test changes are directly related to displaying load errors for issue #84. No unrelated changes are identified.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Full details: Linked Issues check

Explanation

The changes satisfy issue #84 by adding the CVException error widget and integrating it into network-dependent views when content loading fails. Tests cover the new widget and a failed featured-projects load.

Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (12 skipped: 12 unsupported.)

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: d91aa05b-bc3b-4e48-aed2-8c9e27e396e7

📥 Commits

Reviewing files that changed from the base of the PR and between e3a57d4 and fd59793.

📒 Files selected for processing (12)
  • lib/ui/components/cv_exception.dart
  • lib/ui/views/groups/assignment_details_view.dart
  • lib/ui/views/groups/group_details_view.dart
  • lib/ui/views/groups/my_groups_view.dart
  • lib/ui/views/ib/ib_landing_view.dart
  • lib/ui/views/notifications/notifications_view.dart
  • lib/ui/views/profile/user_favourites_view.dart
  • lib/ui/views/profile/user_projects_view.dart
  • lib/ui/views/projects/featured_projects_view.dart
  • lib/ui/views/projects/project_details_view.dart
  • test/ui_tests/components/cv_exception_test.dart
  • test/ui_tests/projects/featured_projects_view_test.dart

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

Comment on lines +580 to +586
if (_model.isError(_model.FETCH_GROUP_DETAILS)) {
_items.add(
CVException(
_model.errorMessageFor(_model.FETCH_GROUP_DETAILS),
),
);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Render the fetch error before the empty group sections.

When FETCH_GROUP_DETAILS fails, _items already contains the group header, three section headers, and their spacers. The new CVException is therefore below the initial content, while the screen can show empty sections instead of the error. Build the error-state content before adding the fetched-data sections.

Comment on lines +104 to +109
if (model.isError(model.FETCH_FEATURED_PROJECTS)) {
_items.add(
CVException(model.errorMessageFor(model.FETCH_FEATURED_PROJECTS)),
);
_projects = _items;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Make the active request error state exclusive.

When featured loading has already succeeded, model.isSuccess(model.FETCH_FEATURED_PROJECTS) remains true. If the first search then fails, FeaturedProjectsViewModel.searchProjects leaves _showSearchedResult false, so model.projects still returns the featured projects. The success block adds those unrelated cards before this branch adds the search error.

A stale featured error can also remain after a successful search. Render the active request as an exclusive loading, success, or error state, and reset the inactive request status when switching modes.

Also applies to: 111-114

when(model.SEARCH_PROJECTS).thenAnswer((_) => 'search_projects');
when(model.isBusy(any)).thenAnswer((_) => false);
when(model.isSuccess(any)).thenAnswer((_) => false);
when(model.isError(any)).thenAnswer((_) => true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Limit the error stub to the featured-project request.

when(model.isError(any)).thenAnswer((_) => true) marks both FETCH_FEATURED_PROJECTS and SEARCH_PROJECTS as errors. The two independent branches in lib/ui/views/projects/featured_projects_view.dart then add two CVException widgets, so find.byType(CVException), findsOneWidget fails.

Stub FETCH_FEATURED_PROJECTS as true and SEARCH_PROJECTS as false.

Proposed test fix
-      when(model.isError(any)).thenAnswer((_) => true);
+      when(
+        model.isError(model.FETCH_FEATURED_PROJECTS),
+      ).thenAnswer((_) => true);
+      when(
+        model.isError(model.SEARCH_PROJECTS),
+      ).thenAnswer((_) => false);
📝 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
when(model.isError(any)).thenAnswer((_) => true);
when(
model.isError(model.FETCH_FEATURED_PROJECTS),
).thenAnswer((_) => true);
when(
model.isError(model.SEARCH_PROJECTS),
).thenAnswer((_) => false);

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing Failed to load/ Error widget

1 participant