Conversation
…setting organizationSlug and viewParams. This change improves state management and simplifies the component's logic.
📝 WalkthroughWalkthroughRefactored atom hydration to use explicit setters with effects in ExamPageShell, improved loading and error state handling in exercise components by decoupling them with separate early returns, and added localized error messages and retry button text to translation files. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@services/main-frontend/src/components/course-material/ContentRenderer/moocfi/ExerciseBlock/index.tsx`:
- Around line 305-325: Replace the use of React Query's isLoading with
isFetching in the render gating for getCourseMaterialExercise so the Spinner
(Spinner component) shows during refetches triggered by
getCourseMaterialExercise.refetch(); specifically, change checks that reference
getCourseMaterialExercise.isLoading to use getCourseMaterialExercise.isFetching
(and keep the existing ErrorBanner + retry button behavior) so clicking the
retry button gives a visual loading indicator while the fetch is in progress.
In `@shared-module/packages/common/src/locales/en/shared-module.json`:
- Line 40: These translation keys ("dynamic-loading-cause-hydration-script",
"dynamic-loading-cause-runtime-error", "dynamic-loading-cause-suspense-forever",
"dynamic-loading-possible-causes-title") are not referenced anywhere (only
"dynamic-loading-fallback-title" and "dynamic-loading-fallback-reason" are used
in DynamicImportFallback.tsx); either remove these unused keys from
shared-module.json to avoid dead translations or keep them but add a short TODO
comment in the PR description and a code comment near DynamicImportFallback.tsx
indicating planned usage (and list the exact keys) so reviewers know they’re
intentionally reserved for a future implementation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a61429a0-27e7-4887-bb98-bff25d864dbc
📒 Files selected for processing (5)
services/main-frontend/src/app/org/[organizationSlug]/(course-material)/exams/ExamPageShell.tsxservices/main-frontend/src/components/course-material/ContentRenderer/moocfi/ExerciseBlock/PeerOrSelfReviewView/PeerOrSelfReviewViewImpl.tsxservices/main-frontend/src/components/course-material/ContentRenderer/moocfi/ExerciseBlock/index.tsxshared-module/packages/common/src/locales/en/main-frontend.jsonshared-module/packages/common/src/locales/en/shared-module.json
| if (getCourseMaterialExercise.isLoading) { | ||
| return <Spinner variant={"medium"} /> | ||
| } | ||
| if (!getCourseMaterialExercise.data) { | ||
| return ( | ||
| <div> | ||
| <ErrorBanner | ||
| variant={"readOnly"} | ||
| error={t("error-loading-exercise", { defaultValue: "Error loading exercise" })} | ||
| /> | ||
| <button | ||
| className={cx(exerciseButtonStyles)} | ||
| onClick={() => { | ||
| void getCourseMaterialExercise.refetch() | ||
| }} | ||
| > | ||
| {t("button-text-try-again", { defaultValue: "Try again" })} | ||
| </button> | ||
| </div> | ||
| ) | ||
| } |
There was a problem hiding this comment.
Use isFetching instead of isLoading for consistent refetch feedback.
When the user clicks the Retry button, refetch() is called. However, React Query's isLoading is only true during the initial load, not during refetches—only isFetching becomes true during refetch operations. This means the spinner won't display while the retry is in progress, leaving users without visual feedback.
This is inconsistent with PeerOrSelfReviewViewImpl.tsx (lines 195-197 in context snippet 2), which correctly uses isFetching with an explicit comment explaining: "Uses isFetching instead of isPending because we want there to be a visual indication when the refresh button is clicked".
Proposed fix
- if (getCourseMaterialExercise.isLoading) {
+ if (getCourseMaterialExercise.isFetching) {
return <Spinner variant={"medium"} />
}📝 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.
| if (getCourseMaterialExercise.isLoading) { | |
| return <Spinner variant={"medium"} /> | |
| } | |
| if (!getCourseMaterialExercise.data) { | |
| return ( | |
| <div> | |
| <ErrorBanner | |
| variant={"readOnly"} | |
| error={t("error-loading-exercise", { defaultValue: "Error loading exercise" })} | |
| /> | |
| <button | |
| className={cx(exerciseButtonStyles)} | |
| onClick={() => { | |
| void getCourseMaterialExercise.refetch() | |
| }} | |
| > | |
| {t("button-text-try-again", { defaultValue: "Try again" })} | |
| </button> | |
| </div> | |
| ) | |
| } | |
| if (getCourseMaterialExercise.isFetching) { | |
| return <Spinner variant={"medium"} /> | |
| } | |
| if (!getCourseMaterialExercise.data) { | |
| return ( | |
| <div> | |
| <ErrorBanner | |
| variant={"readOnly"} | |
| error={t("error-loading-exercise", { defaultValue: "Error loading exercise" })} | |
| /> | |
| <button | |
| className={cx(exerciseButtonStyles)} | |
| onClick={() => { | |
| void getCourseMaterialExercise.refetch() | |
| }} | |
| > | |
| {t("button-text-try-again", { defaultValue: "Try again" })} | |
| </button> | |
| </div> | |
| ) | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@services/main-frontend/src/components/course-material/ContentRenderer/moocfi/ExerciseBlock/index.tsx`
around lines 305 - 325, Replace the use of React Query's isLoading with
isFetching in the render gating for getCourseMaterialExercise so the Spinner
(Spinner component) shows during refetches triggered by
getCourseMaterialExercise.refetch(); specifically, change checks that reference
getCourseMaterialExercise.isLoading to use getCourseMaterialExercise.isFetching
(and keep the existing ErrorBanner + retry button behavior) so clicking the
retry button gives a visual loading indicator while the fetch is in progress.
Summary by CodeRabbit
Release Notes
Bug Fixes
New Features
Localization