Skip to content

[CSM Portal Microapp]: app-wide crash isolation and a root error boundary - #1377

Merged
Rashmika998 merged 4 commits into
wso2-open-operations:mainfrom
2003dinijay:feat/crash-isolation-error-boundaries
Aug 5, 2026
Merged

Rashmika998 merged 4 commits into
wso2-open-operations:mainfrom
2003dinijay:feat/crash-isolation-error-boundaries

Conversation

@2003dinijay

@2003dinijay 2003dinijay commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Two gaps found while auditing this app's error-boundary coverage (webapp checked for reference — its AppErrorBoundary covers the root-level gap the same way, but has no per-item isolation either, so that part is new here):

  • No boundary above the page level anywhere. App.tsx, main.tsx, MainLayout.tsx had none, and several pages (AnnouncementsPage, HomePage, MorePage, ...) have no boundary of their own. An uncaught render error in any of those unmounted the entire React tree to a blank screen with no recovery. This is almost certainly what the Announcements "white space" bug actually was — a render-time throw with nothing above it to catch it. Added AppErrorBoundary at the root (main.tsx), mirroring the webapp's version, trimmed to a simple themed "Something went wrong / Reload" screen.
  • No isolation within a list. Four lists render backend-shaped data per item — CaseActivityFeed (comments/lifecycle/attachments merged), AttachmentsTab's rows, SupportPage's case cards, AnnouncementsPage's announcement cards — all under one list-level ErrorBoundary. A render error in one item was caught by that shared boundary, which unmounts everything below it, not just the offending item. This is exactly how one bad attachment took down the entire comments feed alongside it. Added ListItemErrorBoundary, wrapping each individual item in these four lists so a crash degrades to a small inline "Couldn't display this item" placeholder instead.

No changes to any data access, optional chaining, or field-level fallbacks — this is purely containment for whatever still slips through.

Test plan

  • npx tsc --noEmit
  • npx eslint .
  • npm run build

Summary by CodeRabbit

  • Bug Fixes

    • Improved stability by isolating errors in individual case, announcement, update, comment, audit, and attachment items.
    • Added a full-page recovery screen for unexpected application errors, with an option to reload.
    • Improved rendering of comments and updates containing inline images.
    • Limited inline image processing to 20 unique images to help prevent excessive loading.
  • User Experience

    • Lists now remain available when a single item cannot be displayed.

extractIixAttachmentIds had no upper bound and deduped via an O(n)
ids.includes() scan per match. useResolvedInlineImageHtml fires one
parallel authenticated Blob fetch per id it returns, so a
comment/description with an unreasonable number of distinct .iix
images would fire an unbounded number of concurrent fetches. Caps
collection at 20 unique ids (via a Set, also fixing the O(n) scan)
— ids past the cap are simply never extracted, so they fall through
existing "unresolved reference" handling in replaceInlineImageSrcs
(stripped, not left pointing at an auth-gated URL).
No boundary existed above the page level anywhere in the app —
App.tsx, main.tsx, and MainLayout.tsx all had none, and several pages
(AnnouncementsPage, HomePage, MorePage, ...) have no boundary of their
own either. An uncaught render error in any of those unmounted the
entire React tree to a blank white screen with no way back short of
force-quitting the WebView. This is almost certainly what the
Announcements "white space" bug actually was: a render-time throw
(the createdBy UserReference crash) with nothing above it to catch it.

Mirrors the webapp's AppErrorBoundary, trimmed to this app's simpler
recovery options — no clipboard/correlation-ID reporting, just a
themed "Something went wrong / Reload" screen, logged via the
existing Logger.error.
Four lists render backend-shaped data (UserReference createdBy,
attachment type, ...) one item per iteration, all under a single
list-level ErrorBoundary: CaseActivityFeed (comments/lifecycle
entries/attachments merged together), AttachmentsTab's row list,
SupportPage's case list, AnnouncementsPage's announcement list. A
render error in any one item was caught by that shared boundary,
which unmounts everything below it — not just the offending item,
every sibling too. This is exactly how one attachment with a bad
createdBy value took down the entire comments feed alongside it.

ListItemErrorBoundary wraps a single item so a render error there
degrades to a small inline "Couldn't display this item" placeholder
instead, leaving every other item in the list unaffected. No built-in
retry: a render error here is a code/data-shape bug, not a transient
failure a tap can fix, consistent with how every other ErrorBoundary
in this app already behaves.
Copilot AI lite review requested due to automatic review settings August 5, 2026 16:41

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added App/CSM Portal Platform/Microapp Type/New Feature Represents a request or task for a new feature labels Aug 5, 2026
@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The microapp adds application-level and list-item error boundaries. It isolates failures in case, announcement, support, and activity-feed items. It also recognizes image HTML and caps unique inline image extraction at 20 IDs.

Changes

Microapp error handling

Layer / File(s) Summary
Error boundary foundation
apps/csm-portal/microapp/src/components/common/AppErrorBoundary.tsx, apps/csm-portal/microapp/src/components/common/ListItemErrorBoundary.tsx, apps/csm-portal/microapp/src/main.tsx
Adds root and list-item error boundaries with logging, fallback UI, and application mounting.
List item error isolation
apps/csm-portal/microapp/src/components/case-detail/AttachmentsTab.tsx, apps/csm-portal/microapp/src/components/case-detail/CaseActivityFeed.tsx, apps/csm-portal/microapp/src/pages/AnnouncementsPage.tsx, apps/csm-portal/microapp/src/pages/SupportPage.tsx
Wraps attachment rows, feed entries, announcement cards, and case cards in keyed item boundaries with item-specific contexts.
Inline image processing
apps/csm-portal/microapp/src/components/case-detail/CommentBody.tsx, apps/csm-portal/microapp/src/pages/UpdatesPage.tsx, apps/csm-portal/microapp/src/utils/inlineImages.ts
Recognizes <img> content and limits extraction to 20 unique inline image IDs.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant main.tsx
  participant AppErrorBoundary
  participant ListItemErrorBoundary
  participant CaseActivityFeed
  main.tsx->>AppErrorBoundary: render App
  AppErrorBoundary->>CaseActivityFeed: render application content
  CaseActivityFeed->>ListItemErrorBoundary: render each feed item
  ListItemErrorBoundary-->>CaseActivityFeed: render item fallback on failure
  AppErrorBoundary-->>main.tsx: render recovery screen on root failure
Loading

Possibly related PRs

Suggested labels: Area/Frontend

Suggested reviewers: copilot, cloby99

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description explains the problem, solution, scope, and test plan but omits most required template sections. Complete the required sections, including release note, documentation, security checks, automation test details, training, certification, marketing, and test environment.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the primary change: app-wide crash isolation through a root error boundary.
✨ 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.

@2003dinijay 2003dinijay changed the title feat(csm-portal-microapp): app-wide crash isolation and a root error boundary [CSM Portal Microapp]: app-wide crash isolation and a root error boundary Aug 5, 2026

@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)
apps/csm-portal/microapp/src/components/common/AppErrorBoundary.tsx (1)

43-55: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add regression tests for the microapp error-boundary scopes.

The microapp package has only build/lint scripts, and there are no test/spec files under apps/csm-portal/microapp. Add component tests for these new boundary behaviors:

  • Root fallback and reload action for AppErrorBoundary.tsx.
  • Item isolation with one failing child and healthy siblings for ListItemErrorBoundary.tsx.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/csm-portal/microapp/src/components/common/AppErrorBoundary.tsx` around
lines 43 - 55, Add regression component tests for the microapp error-boundary
scopes: in apps/csm-portal/microapp/src/components/common/AppErrorBoundary.tsx
(lines 43-55), verify the root fallback renders and its reload action works; in
apps/csm-portal/microapp/src/components/common/ListItemErrorBoundary.tsx (lines
44-67), verify one failing child is isolated while healthy siblings remain
rendered. Add the necessary test setup and scripts without changing the boundary
implementations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@apps/csm-portal/microapp/src/components/common/AppErrorBoundary.tsx`:
- Around line 43-55: Add regression component tests for the microapp
error-boundary scopes: in
apps/csm-portal/microapp/src/components/common/AppErrorBoundary.tsx (lines
43-55), verify the root fallback renders and its reload action works; in
apps/csm-portal/microapp/src/components/common/ListItemErrorBoundary.tsx (lines
44-67), verify one failing child is isolated while healthy siblings remain
rendered. Add the necessary test setup and scripts without changing the boundary
implementations.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 20c58184-2499-4557-91a6-5af1c18f7454

📥 Commits

Reviewing files that changed from the base of the PR and between 38a1cc1 and eefbcd8.

📒 Files selected for processing (10)
  • apps/csm-portal/microapp/src/components/case-detail/AttachmentsTab.tsx
  • apps/csm-portal/microapp/src/components/case-detail/CaseActivityFeed.tsx
  • apps/csm-portal/microapp/src/components/case-detail/CommentBody.tsx
  • apps/csm-portal/microapp/src/components/common/AppErrorBoundary.tsx
  • apps/csm-portal/microapp/src/components/common/ListItemErrorBoundary.tsx
  • apps/csm-portal/microapp/src/main.tsx
  • apps/csm-portal/microapp/src/pages/AnnouncementsPage.tsx
  • apps/csm-portal/microapp/src/pages/SupportPage.tsx
  • apps/csm-portal/microapp/src/pages/UpdatesPage.tsx
  • apps/csm-portal/microapp/src/utils/inlineImages.ts

@Rashmika998
Rashmika998 merged commit 69bdb96 into wso2-open-operations:main Aug 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

App/CSM Portal Platform/Microapp Type/New Feature Represents a request or task for a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants