Skip to content

Add scoped ErrorBoundary to Rules page to contain rendering crashes - #7437

Merged
MatissJanis merged 5 commits into
actualbudget:masterfrom
tmchow:osc/7391-rules-error-boundary
Apr 14, 2026
Merged

MatissJanis merged 5 commits into
actualbudget:masterfrom
tmchow:osc/7391-rules-error-boundary

Conversation

@tmchow

@tmchow tmchow commented Apr 9, 2026 •

Copy link
Copy Markdown
Contributor

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 /rules and /rules/:id routes in a scoped ErrorBoundary so crashes stay contained to that section.

What changed:

  • New FeatureErrorFallback component with a retry button. Reusable for other areas later
  • ErrorBoundary wrapping in FinancesApp.tsx for both Rules routes

The fallback uses the existing react-error-boundary v6 dependency and @actual-app/components primitives. All strings go through Trans for i18n.

The FeatureErrorFallback component follows the pattern from GetCardData.tsx but adds resetErrorBoundary support so users can retry without leaving the page.


This change was made with AI assistance.

CE


Bundle Stats

Bundle Files count Total bundle size % Changed
desktop-client 27 12.86 MB → 12.86 MB (+2.12 kB) +0.02%
loot-core 1 4.84 MB 0%
api 1 3.84 MB 0%
cli 1 7.89 MB 0%
View detailed bundle stats

desktop-client

Total

Files count Total bundle size % Changed
27 12.86 MB → 12.86 MB (+2.12 kB) +0.02%
Changeset
File Δ Size
src/components/FeatureErrorFallback.tsx 🆕 +1.3 kB 0 B → 1.3 kB
src/components/FinancesApp.tsx 📈 +841 B (+4.71%) 17.44 kB → 18.26 kB
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger

Asset File Size % Changed
static/js/index.js 3.31 MB → 3.32 MB (+2.12 kB) +0.06%

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
static/js/BackgroundImage.js 121.09 kB 0%
static/js/FormulaEditor.js 852.77 kB 0%
static/js/ReportRouter.js 1.17 MB 0%
static/js/TransactionList.js 82.49 kB 0%
static/js/ca.js 191.98 kB 0%
static/js/da.js 104.66 kB 0%
static/js/de.js 174.38 kB 0%
static/js/en-GB.js 8.2 kB 0%
static/js/en.js 175.72 kB 0%
static/js/es.js 181.8 kB 0%
static/js/fr.js 177.08 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.46 kB 0%
static/js/it.js 165.87 kB 0%
static/js/narrow.js 363.02 kB 0%
static/js/nb-NO.js 151.85 kB 0%
static/js/nl.js 108.93 kB 0%
static/js/pl.js 88.34 kB 0%
static/js/pt-BR.js 177.44 kB 0%
static/js/resize-observer.js 18.06 kB 0%
static/js/th.js 179.3 kB 0%
static/js/theme.js 485.18 kB 0%
static/js/uk.js 212.6 kB 0%
static/js/useTransactionBatchActions.js 4.33 MB 0%
static/js/wide.js 295 B 0%
static/js/workbox-window.prod.es5.js 7.33 kB 0%
static/js/zh-Hans.js 99.27 kB 0%

loot-core

Total

Files count Total bundle size % Changed
1 4.84 MB 0%
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

Asset File Size % Changed
kcab.worker.2cr-I6dh.js 4.84 MB 0%

api

Total

Files count Total bundle size % Changed
1 3.84 MB 0%
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

Asset File Size % Changed
index.js 3.84 MB 0%

cli

Total

Files count Total bundle size % Changed
1 7.89 MB 0%
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

Asset File Size % Changed
cli.js 7.89 MB 0%

@actual-github-bot actual-github-bot Bot changed the title Add scoped ErrorBoundary to Rules page to contain rendering crashes [WIP] Add scoped ErrorBoundary to Rules page to contain rendering crashes Apr 9, 2026
@netlify

netlify Bot commented Apr 9, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 93b64ae
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget/deploys/69dea9d798fadd0008fe6126
😎 Deploy Preview https://deploy-preview-7437.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

👋 Hello contributor!

We would love to review your PR! Before we can do that, please make sure:

  • ✅ All CI checks pass
  • ✅ The PR is moved from draft to open (if applicable)
  • ✅ The "[WIP]" prefix is removed from the PR title
  • ✅ All CodeRabbit code review comments are resolved (if you disagree with anything - reply to the bot with your reasoning so we can read through it). The bot will eventually approve the PR.

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.

@coderabbitai

coderabbitai Bot commented Apr 9, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c9ff9daf-8e68-4abb-9e14-0e4840eb5cf6

📥 Commits

Reviewing files that changed from the base of the PR and between af272dd and 93b64ae.

📒 Files selected for processing (1)
  • packages/desktop-client/src/components/FeatureErrorFallback.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/desktop-client/src/components/FeatureErrorFallback.tsx

📝 Walkthrough

Walkthrough

Adds a new FeatureErrorFallback React component and wraps the /rules and /rules/:id routes in FinancesApp with an ErrorBoundary using that fallback; the boundary resets when the pathname changes.

Changes

Cohort / File(s) Summary
Error Fallback Component
packages/desktop-client/src/components/FeatureErrorFallback.tsx
Adds exported FeatureErrorFallback(FallbackProps) that logs errors, renders a centered i18n error message, shows the error message block when present, and includes a "Try again" button wired to resetErrorBoundary.
Route Error Handling
packages/desktop-client/src/components/FinancesApp.tsx
Wraps the /rules and /rules/:id route elements with ErrorBoundary using FallbackComponent={FeatureErrorFallback} and resetKeys={[location.pathname]} to scope and reset the boundary on navigation.
Release Notes
upcoming-release-notes/7437.md
Adds release note entry announcing the scoped ErrorBoundary for the Rules page.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hop where renderings fail and fray,
I log the tumble, then softly say,
"Press my button, we'll try once more" —
Reboot the view, bound back to the shore.
Puff of fur, and the UI's on its way.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and clearly describes the main change: adding a scoped ErrorBoundary to the Rules page to contain rendering crashes.
Description check ✅ Passed The description is directly related to the changeset, explaining the motivation (issue #7391), the specific changes made, and the design pattern used.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 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 and usage tips.

@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

🤖 Auto-generated Release Notes

Hey @tmchow! I've automatically created a release notes file based on CodeRabbit's analysis:

Category: Enhancements
Summary: Add scoped ErrorBoundary to Rules page to prevent rendering crashes and improve stability.
File: upcoming-release-notes/7437.md

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/desktop-client/src/components/FinancesApp.tsx (1)

292-304: Add resetKeys to 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. Adding resetKeys={[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

📥 Commits

Reviewing files that changed from the base of the PR and between f364d5a and eee4d7e.

📒 Files selected for processing (2)
  • packages/desktop-client/src/components/FeatureErrorFallback.tsx
  • packages/desktop-client/src/components/FinancesApp.tsx

coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 9, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 9, 2026
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).
coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 9, 2026
@tempiz

tempiz commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

@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!

@tmchow tmchow changed the title [WIP] Add scoped ErrorBoundary to Rules page to contain rendering crashes Add scoped ErrorBoundary to Rules page to contain rendering crashes Apr 14, 2026
@tmchow

tmchow commented Apr 14, 2026

Copy link
Copy Markdown
Contributor Author

@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.

@MatissJanis MatissJanis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! Thanks

Image

@netlify

netlify Bot commented Apr 14, 2026

Copy link
Copy Markdown

✅ Deploy Preview for actualbudget-storybook ready!

Name Link
🔨 Latest commit 93b64ae
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget-storybook/deploys/69dea9d798fadd0008fe612b
😎 Deploy Preview https://deploy-preview-7437--actualbudget-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Apr 14, 2026

Copy link
Copy Markdown

✅ Deploy Preview for actualbudget-website ready!

Name Link
🔨 Latest commit 93b64ae
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget-website/deploys/69dea9d7ec49f20008bf4723
😎 Deploy Preview https://deploy-preview-7437.www.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Merged via the queue into actualbudget:master with commit c77b4cc Apr 14, 2026
32 of 33 checks passed
tempiz added a commit to tempiz/actual that referenced this pull request Apr 14, 2026
github-merge-queue Bot pushed a commit that referenced this pull request Apr 17, 2026
* Addition of scoped ErrorBoundarys per 7391

* Adjusted to use FeatureErrorfallback from #7437
jadenar07 pushed a commit to jadenar07/actual that referenced this pull request Apr 22, 2026
…#7497)

* Addition of scoped ErrorBoundarys per 7391

* Adjusted to use FeatureErrorfallback from actualbudget#7437
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants