♻️ refactor: add generic SafeBoundary error boundary with tiered fallback#13321
♻️ refactor: add generic SafeBoundary error boundary with tiered fallback#13321
Conversation
…back Introduce a unified SafeBoundary component (silent/alert variants) to replace scattered custom ErrorBoundary class components. Automatically wraps Inspector, ContentBlock sub-components, MessageItem, and EditorCanvas to prevent individual component crashes from propagating to the entire app.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@canisminor1990 @ONLY-yours - This refactor introduces a unified SafeBoundary error boundary component, touching EditorCanvas, UI components, conversation messages, and plugin/tool rendering. Please take a look. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## canary #13321 +/- ##
=======================================
Coverage 66.76% 66.76%
=======================================
Files 1888 1888
Lines 151436 151436
Branches 14507 14509 +2
=======================================
+ Hits 101109 101111 +2
+ Misses 50215 50213 -2
Partials 112 112
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
❤️ Great PR @Innei ❤️ The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world. |
💻 Change Type
🔗 Related Issue
N/A
🔀 Description of Change
Introduce a unified
SafeBoundarycomponent that replaces scattered customErrorBoundaryclass components (ToolErrorBoundary,EditorErrorBoundary) with a single, generic implementation backed byreact-error-boundary(re-exported from@lobehub/ui).Two-variant fallback strategy:
silent(default): minimal dashed-border placeholder with warning icon — for non-critical areas (Inspector, Reasoning, ImageViewer, Tools)alert: full Alert card with error stack + close/retry — for core content (MessageContent, ToolDetail, EditorCanvas)Injection points (container layer):
ContentBlock: wraps Reasoning (silent), MessageContent (alert), ImageFileListViewer (silent), Tools (silent)MessageItem: wraps entire message rendering (alert) as a top-level fallbackInspector: wraps CustomInspector withresetKeysfor streaming recoveryTool/Detail: migrated fromToolErrorBoundary→SafeBoundary(alert)PluginRender: migrated fromToolErrorBoundary→SafeBoundary(alert)EditorCanvas: migrated fromEditorErrorBoundary→SafeBoundary(alert)Key features:
resetKeysprop for automatic error recovery when props change (e.g., streaming)onErrorcallback for custom error loggingwithErrorBoundaryHOC for wrapping components declaratively🧪 How to Test
📝 Additional Information
ErrorBoundary.tsxfiles (ToolErrorBoundary,EditorErrorBoundary) are now unused but not deleted — can be cleaned up in a follow-upBootErrorBoundaryis intentionally NOT migrated as it has specialized reload-recovery logic