Repository navigation
feat(reports): scoped ErrorBoundaries for individual report routes - #7658
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. |
|
Complex PR? Review this PR in Change Stack to move by importance, not file order. Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
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 (2)
📝 WalkthroughWalkthroughReportRouter adds an internal ReportBoundary that uses useLocation() and wraps all non-dashboard report routes in an ErrorBoundary configured with FeatureErrorFallback and resetKeys tied to location.pathname; dashboard routes remain unwrapped. ChangesReport Router Error Boundaries
Sequence DiagramsequenceDiagram
participant Router as ReportRouter
participant Loc as useLocation
participant Boundary as ReportBoundary/ErrorBoundary
participant Report as ReportRouteComponent
participant Fallback as FeatureErrorFallback
Router->>Loc: read location.pathname
Router->>Boundary: render route element inside ReportBoundary
Boundary->>Boundary: set resetKeys = [location.pathname]
Boundary->>Report: render report component
alt report component throws
Boundary->>Fallback: render FeatureErrorFallback
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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.
🧹 Nitpick comments (1)
packages/desktop-client/src/components/reports/ReportRouter.tsx (1)
32-287: Reduce boundary boilerplate to a small helper to lower drift risk.The same
ErrorBoundarywrapper is repeated for every report route. A tiny helper will keep future route additions safer and easier to review.Refactor sketch
export function ReportRouter() { const location = useLocation(); + function withReportBoundary(element: React.ReactElement) { + return ( + <ErrorBoundary + FallbackComponent={FeatureErrorFallback} + resetKeys={[location.pathname]} + > + {element} + </ErrorBoundary> + ); + } return ( <Routes> @@ - <Route - path="/net-worth" - element={ - <ErrorBoundary - FallbackComponent={FeatureErrorFallback} - resetKeys={[location.pathname]} - > - <NetWorth /> - </ErrorBoundary> - } - /> + <Route path="/net-worth" element={withReportBoundary(<NetWorth />)} />🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/desktop-client/src/components/reports/ReportRouter.tsx` around lines 32 - 287, The routes in ReportRouter.tsx repeat the same ErrorBoundary wrapper for every report (ErrorBoundary, FallbackComponent=FeatureErrorFallback, resetKeys={[location.pathname]}), which is boilerplate and error-prone; create a small helper function or component (e.g., wrapWithFeatureBoundary or FeatureRouteWrapper) that accepts a report component (NetWorth, Crossover, AgeOfMoney, CashFlow, CustomReport, Spending, BudgetAnalysis, Summary, Calendar, Formula, Sankey) and returns the element already wrapped by ErrorBoundary with FallbackComponent and resetKeys set to [location.pathname], then replace each route element with a call to that helper to remove duplication and keep behavior identical.
🤖 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/reports/ReportRouter.tsx`:
- Around line 32-287: The routes in ReportRouter.tsx repeat the same
ErrorBoundary wrapper for every report (ErrorBoundary,
FallbackComponent=FeatureErrorFallback, resetKeys={[location.pathname]}), which
is boilerplate and error-prone; create a small helper function or component
(e.g., wrapWithFeatureBoundary or FeatureRouteWrapper) that accepts a report
component (NetWorth, Crossover, AgeOfMoney, CashFlow, CustomReport, Spending,
BudgetAnalysis, Summary, Calendar, Formula, Sankey) and returns the element
already wrapped by ErrorBoundary with FallbackComponent and resetKeys set to
[location.pathname], then replace each route element with a call to that helper
to remove duplication and keep behavior identical.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4aaf8657-af7c-4ce9-bdf5-5fb2af671155
📒 Files selected for processing (2)
packages/desktop-client/src/components/reports/ReportRouter.tsxupcoming-release-notes/7658.md
✅ Deploy Preview for actualbudget-website ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/desktop-client/src/components/reports/ReportRouter.tsx (1)
3-3: Consider creating or using a customuseLocationhook wrapper fromsrc/hooks.The coding guideline requires using custom hooks from
src/hooksinstead of consuming react-router hooks directly.useNavigate()already has a wrapper in the project following this pattern. For consistency, consider creating auseLocationwrapper hook or deferring this import until one exists.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/desktop-client/src/components/reports/ReportRouter.tsx` at line 3, ReportRouter currently imports useLocation directly from 'react-router'; per project guidelines create a custom hook wrapper (e.g., export function useLocation() { return useReactRouterLocation(); } or re-export) in your hooks module and update ReportRouter to import useLocation from src/hooks instead of 'react-router' so it follows the established pattern used for useNavigate; target the useLocation symbol and the ReportRouter component when applying the change.
🤖 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/reports/ReportRouter.tsx`:
- Line 3: ReportRouter currently imports useLocation directly from
'react-router'; per project guidelines create a custom hook wrapper (e.g.,
export function useLocation() { return useReactRouterLocation(); } or re-export)
in your hooks module and update ReportRouter to import useLocation from
src/hooks instead of 'react-router' so it follows the established pattern used
for useNavigate; target the useLocation symbol and the ReportRouter component
when applying the change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9970f8d0-7654-413f-9e24-5fbbdab92d80
📒 Files selected for processing (1)
packages/desktop-client/src/components/reports/ReportRouter.tsx
…7391) Wrap each route in ReportRouter for NetWorth, CashFlow, Spending, etc. in ErrorBoundary with FeatureErrorFallback. Matches the pattern used for /rules routes in FinancesApp.tsx so a render error in a single report no longer takes down the whole app.
…boilerplate
Each report route was wrapping its element in the same ErrorBoundary block
with FeatureErrorFallback and resetKeys={[location.pathname]}. Pull that
into a small withReportBoundary(element) helper inside ReportRouter so
each route is one line again.
Behavior is unchanged. The ErrorBoundary, FallbackComponent, and resetKeys
are identical to before; the helper just closes over location.pathname.
Addresses review feedback from @joel-jeremy and the CodeRabbit nitpick on
the same file (a custom Route component is not viable since react-router
v6's <Routes> requires literal <Route> children, but a helper function
gives the same boilerplate reduction).
38bb4a5 to
cdd30e7
Compare
| const budgetAnalysisReportEnabled = useFeatureFlag('budgetAnalysisReport'); | ||
| const sankeyReportEnabled = useFeatureFlag('sankeyReport'); | ||
|
|
||
| function withReportBoundary(element: ReactElement) { |
There was a problem hiding this comment.
This should be defined outside of the ReportRouter function.
Move the per-route error-boundary helper out of ReportRouter as a module-scoped component. ReportBoundary calls useLocation() internally so each call site stays clean. Addresses review feedback.
|
@cursor resolve the merge conflicts in this pull request |
Resolve ReportRouter.tsx conflict: keep ReportBoundary wrapping for all report routes while adopting master's changes (crossover now always-on, new balance-forecast routes behind balanceForecastReport flag). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
@coderabbitai full review |
✅ Action performedFull review finished. |
…ctualbudget#7658) * feat(reports): scoped ErrorBoundaries for individual report routes (actualbudget#7391) Wrap each route in ReportRouter for NetWorth, CashFlow, Spending, etc. in ErrorBoundary with FeatureErrorFallback. Matches the pattern used for /rules routes in FinancesApp.tsx so a render error in a single report no longer takes down the whole app. * chore: rename release note to PR number * refactor(reports): extract withReportBoundary helper to remove route boilerplate Each report route was wrapping its element in the same ErrorBoundary block with FeatureErrorFallback and resetKeys={[location.pathname]}. Pull that into a small withReportBoundary(element) helper inside ReportRouter so each route is one line again. Behavior is unchanged. The ErrorBoundary, FallbackComponent, and resetKeys are identical to before; the helper just closes over location.pathname. Addresses review feedback from @joel-jeremy and the CodeRabbit nitpick on the same file (a custom Route component is not viable since react-router v6's <Routes> requires literal <Route> children, but a helper function gives the same boilerplate reduction). * refactor(reports): hoist withReportBoundary to ReportBoundary component Move the per-route error-boundary helper out of ReportRouter as a module-scoped component. ReportBoundary calls useLocation() internally so each call site stays clean. Addresses review feedback. --------- Co-authored-by: github-actions[bot] <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
…ctualbudget#7658) * feat(reports): scoped ErrorBoundaries for individual report routes (actualbudget#7391) Wrap each route in ReportRouter for NetWorth, CashFlow, Spending, etc. in ErrorBoundary with FeatureErrorFallback. Matches the pattern used for /rules routes in FinancesApp.tsx so a render error in a single report no longer takes down the whole app. * chore: rename release note to PR number * refactor(reports): extract withReportBoundary helper to remove route boilerplate Each report route was wrapping its element in the same ErrorBoundary block with FeatureErrorFallback and resetKeys={[location.pathname]}. Pull that into a small withReportBoundary(element) helper inside ReportRouter so each route is one line again. Behavior is unchanged. The ErrorBoundary, FallbackComponent, and resetKeys are identical to before; the helper just closes over location.pathname. Addresses review feedback from @joel-jeremy and the CodeRabbit nitpick on the same file (a custom Route component is not viable since react-router v6's <Routes> requires literal <Route> children, but a helper function gives the same boilerplate reduction). * refactor(reports): hoist withReportBoundary to ReportBoundary component Move the per-route error-boundary helper out of ReportRouter as a module-scoped component. ReportBoundary calls useLocation() internally so each call site stays clean. Addresses review feedback. --------- Co-authored-by: github-actions[bot] <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Description
This PR adds scoped
ErrorBoundarywrappers around each individual report route inReportRouter.tsx(NetWorth, CashFlow, Spending, CustomReport, Calendar, Formula, Summary, Crossover, AgeOfMoney, BudgetAnalysis, Sankey).Today, a render error inside any of those report views bubbles up to the top-level
FatalErrorboundary inApp.tsxand crashes the whole app to the fatal-error screen. Wrapping each route in aFeatureErrorFallbackboundary contains the failure to that one report — the rest of the app keeps working.This is the next slice of #7391's table; the prior PRs (#7382 dashboard widgets, #7437 rules, #7497 budget/account/transactions/schedules/sidebar) already handled their respective areas. The dashboard view uses
Overview.tsx's per-widget boundaries so it's intentionally not wrapped here.The pattern matches the one already used for
/rulesroutes inFinancesApp.tsx:The
resetKeys={[location.pathname]}lets the boundary auto-reset when the user navigates to a different report.Related issue(s)
Relates to #7391
Testing
Manual:
FeatureErrorFallback; the sidebar, header, and account list keep rendering.pathnamechange.yarn oxlint --type-aware --quietandyarn oxfmt --checkagainst the changed file — clean.Checklist
Bundle Stats
View detailed bundle stats
desktop-client
Total
Changeset
src/components/reports/ReportRouter.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
crdt
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