Skip to content

Add error boundary with diagnostics - #58

Open
moshloop wants to merge 2 commits into
mainfrom
feat/error-boundary-diagnostics-dkht3fixyv34
Open

Add error boundary with diagnostics#58
moshloop wants to merge 2 commits into
mainfrom
feat/error-boundary-diagnostics-dkht3fixyv34

Conversation

@moshloop

@moshloop moshloop commented Aug 6, 2026

Copy link
Copy Markdown
Member

Add a reusable error boundary component with copyable diagnostics for uncaught React errors.

What

  • Full-page error fallback with normalized diagnostics
  • Support-ready clipboard reporting functionality
  • Tests and Storybook stories for success and failure flows

Why

  • Provides consumers with a shared error handling strategy
  • Improves debugging and support workflows through easy error export

Summary by CodeRabbit

  • New Features

    • Added an error boundary with an accessible fallback screen when rendering fails.
    • Error details can be expanded, including causes and component information.
    • Added formatted error-report copying with success and failure feedback.
    • Exported the error boundary component for use throughout the UI package.
  • Documentation

    • Added Storybook coverage for the error fallback experience.
  • Bug Fixes

    • Updated user event visuals for improved consistency.
  • Tests

    • Added coverage for fallback rendering, diagnostics, report copying, and announcements.

Give consumers a shared full-page fallback for uncaught React errors, with normalized diagnostics and support-ready clipboard reporting. Include tests and Storybook coverage for successful and failed copy flows.

Claude-Session-Id: 208885f0-1dd9-44f9-9b16-0d59284bd391
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: dec03bd8-ab3d-48e6-a1c2-e842ce1257dc

📥 Commits

Reviewing files that changed from the base of the PR and between 530410d and fbeb570.

📒 Files selected for processing (4)
  • packages/ui/src/components/ErrorWrapper.stories.tsx
  • packages/ui/src/components/ErrorWrapper.test.tsx
  • packages/ui/src/components/ErrorWrapper.tsx
  • packages/ui/src/data/ai/SessionViewer.rows.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/ui/src/components/ErrorWrapper.test.tsx

Walkthrough

Changes

ErrorWrapper

Layer / File(s) Summary
Capture errors and build diagnostics
packages/ui/src/components/ErrorWrapper.tsx
ErrorWrapper captures render errors and component stacks, calls onError, and normalizes diagnostic data.
Render fallback and copy reports
packages/ui/src/components/ErrorWrapper.tsx
The fallback renders accessible error details and copies formatted reports with success or failure announcements.
Expose and validate ErrorWrapper
packages/ui/src/components.ts, packages/ui/src/components/ErrorWrapper.stories.tsx, packages/ui/src/components/ErrorWrapper.test.tsx
The component and props type are exported. Storybook and tests cover fallback rendering, diagnostics, and clipboard behavior.

Session viewer icon

Layer / File(s) Summary
Update user event icon
packages/ui/src/data/ai/SessionViewer.rows.tsx
User event rows and their visual mapping now use UiUser instead of UiUserCircle.

Sequence Diagram(s)

sequenceDiagram
  participant BrokenPage
  participant ErrorWrapper
  participant Clipboard
  BrokenPage->>ErrorWrapper: throw render error
  ErrorWrapper->>ErrorWrapper: normalize diagnostics
  ErrorWrapper-->>BrokenPage: render accessible fallback
  ErrorWrapper->>Clipboard: write formatted error report
  Clipboard-->>ErrorWrapper: resolve or reject copy request
  ErrorWrapper-->>BrokenPage: announce copy status
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a reusable error boundary with diagnostics.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches 💡 1
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch feat/error-boundary-diagnostics-dkht3fixyv34
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/error-boundary-diagnostics-dkht3fixyv34
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feat/error-boundary-diagnostics-dkht3fixyv34

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

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

Inline comments:
In `@packages/ui/src/components/ErrorWrapper.stories.tsx`:
- Around line 40-53: Add Storybook interaction coverage alongside the Default
story for both ErrorWrapper copy outcomes: click “Copy error details” and assert
the successful copied status, then cover clipboard failure and assert its
failure status. Reuse the existing ErrorWrapper/BrokenDashboard setup and
Storybook play-function patterns, keeping the fallback rendering assertions
intact.

In `@packages/ui/src/components/ErrorWrapper.test.tsx`:
- Around line 19-22: Restore the original navigator.clipboard property
descriptor in the afterEach cleanup for ErrorWrapper tests, since
vi.restoreAllMocks() does not undo Object.defineProperty changes. At
packages/ui/src/components/ErrorWrapper.test.tsx lines 19-22, capture and
restore the original descriptor; at lines 60-63, use the restored test fixture
so no replacement remains globally installed.

In `@packages/ui/src/components/ErrorWrapper.tsx`:
- Around line 191-192: Update the page URL handling in ErrorWrapper to copy only
window.location.origin and pathname, excluding query strings and fragments from
the support report. Preserve the existing conditional behavior and update the
related test to assert that both search parameters and hash fragments are
omitted.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7a153742-29ef-41e7-abf2-4fa3037e5429

📥 Commits

Reviewing files that changed from the base of the PR and between d6f554d and 530410d.

📒 Files selected for processing (4)
  • packages/ui/src/components.ts
  • packages/ui/src/components/ErrorWrapper.stories.tsx
  • packages/ui/src/components/ErrorWrapper.test.tsx
  • packages/ui/src/components/ErrorWrapper.tsx

Comment thread packages/ui/src/components/ErrorWrapper.stories.tsx
Comment thread packages/ui/src/components/ErrorWrapper.test.tsx
Comment thread packages/ui/src/components/ErrorWrapper.tsx Outdated
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Gavel summary

Source Pass Fail Skip Duration
./apps/kitchen-sink 1 0 0 507ms
./apps/storybook 615 0 0 1m21s
./e2e 4 0 0 1m51s
./packages/ui 2124 0 0 2m25s
lint: betterleaks 0 0 1 -
lint: tsc 1 0 0 299ms

Totals: 2745 passed · 0 failed · 1 skipped · 5m38s

View full results

Keep query parameters and URL fragments out of copied diagnostics to prevent accidental credential disclosure. Add coverage for clipboard outcomes and align session user visuals with the standard icon.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant