Skip to content

feat(ui): enhance StreamComponentBuilders with extension support#60

Open
xsahil03x wants to merge 2 commits intomain-design-systemfrom
feat/component-factory-extension
Open

feat(ui): enhance StreamComponentBuilders with extension support#60
xsahil03x wants to merge 2 commits intomain-design-systemfrom
feat/component-factory-extension

Conversation

@xsahil03x
Copy link
Member

@xsahil03x xsahil03x commented Feb 25, 2026

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

    • Added extensible component builder system supporting custom extensions, enabling developers to register and retrieve typed builder extensions for enhanced component customization and flexibility.
  • Refactor

    • Restructured component builder initialization and operations (copy, merge, interpolation) to natively support extension management, ensuring extensions are properly maintained across builder transformations.

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>
@xsahil03x xsahil03x requested a review from a team as a code owner February 25, 2026 19:35
@coderabbitai
Copy link

coderabbitai bot commented Feb 25, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The changes introduce an extensible builder extension mechanism to StreamComponentBuilders. A new StreamComponentBuilderExtension<T> class wraps custom builders, and StreamComponentBuilders now accepts extensions via a factory constructor, delegates to a raw constructor, stores extensions in a map, and provides typed retrieval via an extension<T>() method. Generated code (lerp, copyWith, equality) was updated to handle extensions.

Changes

Cohort / File(s) Summary
Extension Mechanism Implementation
packages/stream_core_flutter/lib/src/factory/stream_component_factory.dart
Introduced StreamComponentBuilderExtension<T> immutable class with typed builder wrapping and type-based lookup. Refactored StreamComponentBuilders with a factory constructor accepting extensions, a new raw constructor with explicit extension field, and an extension<T>() retrieval method. Added helper _extensionIterableToMap to convert extension iterables to maps keyed by type.
Generated Theme Code Updates
packages/stream_core_flutter/lib/src/factory/stream_component_factory.g.theme.dart
Updated copyWith, lerp, merge methods and equality/hashCode logic to recognize and propagate extensions map. Constructor calls now use .raw with extensions handled as first-class member in interpolation, copying, and comparison operations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A warren of builders, once plain and quite square,
Now springs forth with extensions, a gift beyond rare!
We map them, we store them, we fetch them with grace,
Through typed generics that land in their place.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description explains the feature's purpose and mechanism, but is missing required template sections like Linear ticket, CLA checkbox, and testing information. Complete the PR template by adding Linear ticket reference (FLA-), CLA confirmation, best practices confirmation, testing details, and optional screenshots/videos sections.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding extension support to StreamComponentBuilders for enhanced customization.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/component-factory-extension

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.

@xsahil03x
Copy link
Member Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Feb 25, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/stream_core_flutter/lib/src/factory/stream_component_factory.dart (1)

195-209: Freeze extensions before storing to preserve immutability semantics.

StreamComponentBuilders is @immutable, but extensions remains 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.

📥 Commits

Reviewing files that changed from the base of the PR and between da18aa0 and 8e735c4.

📒 Files selected for processing (2)
  • packages/stream_core_flutter/lib/src/factory/stream_component_factory.dart
  • packages/stream_core_flutter/lib/src/factory/stream_component_factory.g.theme.dart

@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

❌ Patch coverage is 0% with 12 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main-design-system@da18aa0). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...tter/lib/src/factory/stream_component_factory.dart 0.00% 12 Missing ⚠️

❌ 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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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