Repository navigation
Add scoped ErrorBoundary to Rules page to contain rendering crashes - #7437
Conversation
✅ Deploy Preview for actualbudget ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
👋 Hello contributor! We would love to review your PR! Before we can do that, please make sure:
We do this to reduce the TOIL the core contributor team has to go through for each PR and to allow for speedy reviews and merges. For more information, please see our Contributing Guide. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a new Changes
Sequence Diagram(s)sequenceDiagram
participant Browser
participant Router
participant FinancesApp
participant ErrorBoundary
participant FeatureErrorFallback
participant User
Browser->>Router: navigate to /rules or /rules/:id
Router->>FinancesApp: render route element
FinancesApp->>ErrorBoundary: render child (Rules / RuleEdit)
alt child renders successfully
ErrorBoundary->>User: render Rules UI
else child throws during render
ErrorBoundary->>FeatureErrorFallback: render fallback (passes error + reset)
FeatureErrorFallback->>User: show error message + "Try again" button
User->>FeatureErrorFallback: click "Try again"
FeatureErrorFallback->>ErrorBoundary: call resetErrorBoundary (attempt re-render)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 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 |
|
🤖 Auto-generated Release Notes Hey @tmchow! I've automatically created a release notes file based on CodeRabbit's analysis: Category: Enhancements If you're happy with this release note, you can add it to your pull request. If not, you'll need to add your own before a maintainer can review your change. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/desktop-client/src/components/FinancesApp.tsx (1)
292-304: AddresetKeysto ErrorBoundary to reset state on route navigation.In react-error-boundary v6, the boundary does not auto-reset when React Router's path changes. Without
resetKeys, if a component crashes once, the boundary remains in fallback state across navigation until manually retried. AddingresetKeys={[location.pathname]}ensures recovery when the route changes.♻️ Suggested implementation
export function FinancesApp() { const { isNarrowWidth } = useResponsive(); + const location = useLocation(); useMetaThemeColor(isNarrowWidth ? theme.mobileViewTheme : undefined); @@ - <ErrorBoundary FallbackComponent={FeatureErrorFallback}> + <ErrorBoundary + FallbackComponent={FeatureErrorFallback} + resetKeys={[location.pathname]} + > <NarrowAlternate name="Rules" /> </ErrorBoundary> @@ - <ErrorBoundary FallbackComponent={FeatureErrorFallback}> + <ErrorBoundary + FallbackComponent={FeatureErrorFallback} + resetKeys={[location.pathname]} + > <NarrowAlternate name="RuleEdit" /> </ErrorBoundary>🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/desktop-client/src/components/FinancesApp.tsx` around lines 292 - 304, The ErrorBoundary instances wrapping NarrowAlternate ("Rules" and "RuleEdit") must receive resetKeys so they reset when the route changes: import useLocation from react-router-dom, call const location = useLocation() in the FinancesApp component, and add resetKeys={[location.pathname]} to each <ErrorBoundary FallbackComponent={FeatureErrorFallback}> (both the Route for "/rules" and "/rules/:id") so the boundary clears fallback state on navigation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/desktop-client/src/components/FinancesApp.tsx`:
- Around line 292-304: The ErrorBoundary instances wrapping NarrowAlternate
("Rules" and "RuleEdit") must receive resetKeys so they reset when the route
changes: import useLocation from react-router-dom, call const location =
useLocation() in the FinancesApp component, and add
resetKeys={[location.pathname]} to each <ErrorBoundary
FallbackComponent={FeatureErrorFallback}> (both the Route for "/rules" and
"/rules/:id") so the boundary clears fallback state on navigation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d811f567-b024-4b97-8465-b3a4707835b3
📒 Files selected for processing (2)
packages/desktop-client/src/components/FeatureErrorFallback.tsxpackages/desktop-client/src/components/FinancesApp.tsx
In react-error-boundary v6, the boundary does not auto-reset when the
user navigates away and back. Adding resetKeys={[location.pathname]}
ensures the error state clears on route changes.
This contribution was developed with AI assistance (Claude Code).
|
@tmchow I am working on adding errorboundarys to other components in PR #7497. I would like to implement your shared FeatureErrorFallback. It looks like your PR has been sitting in WIP status for several days. Is this ready for review yet? If so, please remove the [WIP] tag from the PR title and I will wait on my PR until your shared component has been merged. Thanks! |
I think it's ready |
Addresses reviewer feedback on #7437: surface error.message in the FeatureErrorFallback so users can copy-paste when reporting issues, and log the error to the console via useEffect so the error isn't swallowed by the boundary.
✅ Deploy Preview for actualbudget-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for actualbudget-website ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
c77b4cc
…#7497) * Addition of scoped ErrorBoundarys per 7391 * Adjusted to use FeatureErrorfallback from actualbudget#7437

Addresses #7391 (picking the Rules page area from the table).
When a Rules or RuleEdit component throws during rendering, the whole app goes to the Fatal Error screen. This wraps both
/rulesand/rules/:idroutes in a scopedErrorBoundaryso crashes stay contained to that section.What changed:
FeatureErrorFallbackcomponent with a retry button. Reusable for other areas laterFinancesApp.tsxfor both Rules routesThe fallback uses the existing
react-error-boundaryv6 dependency and@actual-app/componentsprimitives. All strings go throughTransfor i18n.The
FeatureErrorFallbackcomponent follows the pattern fromGetCardData.tsxbut addsresetErrorBoundarysupport so users can retry without leaving the page.This change was made with AI assistance.
Bundle Stats
View detailed bundle stats
desktop-client
Total
Changeset
src/components/FeatureErrorFallback.tsxsrc/components/FinancesApp.tsxView detailed bundle breakdown
Added
No assets were added
Removed
No assets were removed
Bigger
Smaller
No assets were smaller
Unchanged
loot-core
Total
View detailed bundle breakdown
Added
No assets were added
Removed
No assets were removed
Bigger
No assets were bigger
Smaller
No assets were smaller
Unchanged
api
Total
View detailed bundle breakdown
Added
No assets were added
Removed
No assets were removed
Bigger
No assets were bigger
Smaller
No assets were smaller
Unchanged
cli
Total
View detailed bundle breakdown
Added
No assets were added
Removed
No assets were removed
Bigger
No assets were bigger
Smaller
No assets were smaller
Unchanged