feat(ui): enhance StreamComponentBuilders with extension support#60
feat(ui): enhance StreamComponentBuilders with extension support#60xsahil03x wants to merge 2 commits intomain-design-systemfrom
Conversation
Allow external packages to register typed component builders via StreamComponentBuilderExtension without modifying StreamComponentBuilders. Extensions are keyed by their Props type and retrieved through the extension<T>() method, enabling per-component customization beyond the built-in builder set. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe changes introduce an extensible builder extension mechanism to Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/stream_core_flutter/lib/src/factory/stream_component_factory.dart (1)
195-209: Freezeextensionsbefore storing to preserve immutability semantics.
StreamComponentBuildersis@immutable, butextensionsremains mutable after construction. In-place mutation can cause stale/inconsistent behavior with equality and ancestor notifications.♻️ Minimal hardening
- extensions: _extensionIterableToMap(extensions), + extensions: Map.unmodifiable(_extensionIterableToMap(extensions)),static Map<Object, StreamComponentBuilderExtension<dynamic>> _extensionIterableToMap( Iterable<StreamComponentBuilderExtension<dynamic>> extensionsIterable, ) { - return <Object, StreamComponentBuilderExtension<dynamic>>{ + return Map.unmodifiable(<Object, StreamComponentBuilderExtension<dynamic>>{ for (final extension in extensionsIterable) extension.type: extension, - }; + }); }Also applies to: 239-239, 310-315
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/stream_core_flutter/lib/src/factory/stream_component_factory.dart` around lines 195 - 209, StreamComponentBuilders is annotated `@immutable` but the extensions map passed into the .raw constructor remains mutable; convert/freeze extensions into an unmodifiable Map before storing (e.g., inside the StreamComponentBuilders.raw factory or where _extensionIterableToMap is used) so the internal field cannot be mutated after construction—ensure you replace the direct assignment of extensions with a frozen copy (use an immutable/unmodifiable map wrapper or copy) and adjust _extensionIterableToMap usage to return an unmodifiable Map to preserve immutability and correct equality/notification behavior.
🤖 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/stream_core_flutter/lib/src/factory/stream_component_factory.dart`:
- Around line 195-209: StreamComponentBuilders is annotated `@immutable` but the
extensions map passed into the .raw constructor remains mutable; convert/freeze
extensions into an unmodifiable Map before storing (e.g., inside the
StreamComponentBuilders.raw factory or where _extensionIterableToMap is used) so
the internal field cannot be mutated after construction—ensure you replace the
direct assignment of extensions with a frozen copy (use an
immutable/unmodifiable map wrapper or copy) and adjust _extensionIterableToMap
usage to return an unmodifiable Map to preserve immutability and correct
equality/notification behavior.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
packages/stream_core_flutter/lib/src/factory/stream_component_factory.dartpackages/stream_core_flutter/lib/src/factory/stream_component_factory.g.theme.dart
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main-design-system #60 +/- ##
=====================================================
Coverage ? 32.73%
=====================================================
Files ? 101
Lines ? 3067
Branches ? 0
=====================================================
Hits ? 1004
Misses ? 2063
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Description of the pull request
Allow external packages to register typed component builders via StreamComponentBuilderExtension without modifying StreamComponentBuilders. Extensions are keyed by their Props type and retrieved through the extension() method, enabling per-component customization beyond the built-in builder set.
Summary by CodeRabbit
New Features
Refactor