Skip to content

Conversation

@xsahil03x
Copy link
Member

@xsahil03x xsahil03x commented Oct 14, 2025

Description of the pull request

Introduces attachmentPickerOptionsBuilder to allow for full customization of the attachment picker options. This builder receives the context and a list of default options, which can then be modified, reordered, or extended.

The customAttachmentPickerOptions property is now deprecated in favor of attachmentPickerOptionsBuilder.

A new callback, onAttachmentPickerResult, is added. This callback is triggered when any result is returned from the attachment picker. It allows developers to handle custom attachment types by returning true. If false is returned, the default internal handling proceeds.

Summary by CodeRabbit

  • New Features

    • Attachment picker supports an optionsBuilder to customize/extend default options (gallery, file, image, video, poll) for both tabbed and system pickers.
    • In-place poll creation available from both picker modes.
    • Result handler now returns a boolean/FutureOr to indicate if a result was handled.
  • Refactor

    • Replaced customOptions with a builder-based configuration across picker and message input.
    • Added validation ensuring supplied options match the picker type.
  • Documentation

    • Updated samples and docs to show the new builder and result handler.

…rResult`

Introduces `attachmentPickerOptionsBuilder` to allow for full customization of the attachment picker options. This builder receives the context and a list of default options, which can then be modified, reordered, or extended.

The `customAttachmentPickerOptions` property is now deprecated in favor of `attachmentPickerOptionsBuilder`.

A new callback, `onAttachmentPickerResult`, is added. This callback is triggered when any result is returned from the attachment picker. It allows developers to handle custom attachment types by returning `true`. If `false` is returned, the default internal handling proceeds.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 14, 2025

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.

Walkthrough

Replaces per-call customOptions with an optionsBuilder pattern for attachment pickers, updates builders and bottom-sheet wiring, changes OnAttachmentPickerResult to return FutureOr, updates StreamMessageInput wiring to respect handler short-circuiting, and updates sample app usage to the new builder/result APIs.

Changes

Cohort / File(s) Summary of Changes
Attachment Picker Core (Tabbed & System)
packages/stream_chat_flutter/lib/src/message_input/attachment_picker/stream_attachment_picker.dart
Replaces customOptions with optionsBuilder; defines defaultOptions; validates option types; composes options dynamically with allowedTypes; wires gallery/file/image/video/poll options for tabbed and system pickers; integrates poll creation and existing single-pick handling; updates error messages to reference optionsBuilder.
Bottom Sheet API & Routing
packages/stream_chat_flutter/lib/src/message_input/attachment_picker/stream_attachment_picker_bottom_sheet.dart
Adds typedef AttachmentPickerOptionsBuilder<T extends AttachmentPickerOption> = List<T> Function(BuildContext, List<T>); replaces customOptions with optionsBuilder in showStreamAttachmentPickerModalBottomSheet; chooses tabbed/system builders based on useSystemPicker and forwards optionsBuilder; removes prior customOptions branching/validation.
Picker Result Typedefs
packages/stream_chat_flutter/lib/src/message_input/attachment_picker/stream_attachment_picker_result.dart
Removes OnCustomAttachmentPickerResult; changes OnAttachmentPickerResult<T> signature to FutureOr<bool> Function(T result); minor import reordering and comment tweak.
Message Input Wiring
packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart
Constructor/fields updated: add attachmentPickerOptionsBuilder and onAttachmentPickerResult; remove customAttachmentPickerOptions and onCustomAttachmentPickerResult; pass optionsBuilder to bottom sheet; call onAttachmentPickerResult and short-circuit internal handling when it returns handled=true; remove CustomAttachmentPickerResult branch.
Sample App Update
sample_app/lib/pages/channel_page.dart
Replaces customAttachmentPickerOptions with attachmentPickerOptionsBuilder; replaces onCustomAttachmentPickerResult with onAttachmentPickerResult and update handler to return bool; gates location-sharing flow via the handled flag while preserving prior behavior by composing default options.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant MI as StreamMessageInput
  participant BS as AttachmentPickerBottomSheet
  participant PK as Picker (Tabbed/System)
  participant OB as optionsBuilder
  participant AH as onAttachmentPickerResult

  U->>MI: Tap attach
  MI->>BS: showStreamAttachmentPickerModalBottomSheet(optionsBuilder)
  BS->>PK: Build picker (tabbed/system)
  PK->>OB: request options (context, defaultOptions)
  OB-->>PK: return List<AttachmentPickerOption>
  U->>PK: Select option / complete action
  PK-->>MI: StreamAttachmentPickerResult
  MI->>AH: call onAttachmentPickerResult(result)?
  alt AH returns true (handled)
    MI-->>U: stop (user handled)
  else AH absent or returns false
    MI->>MI: internal default handling
    MI-->>U: continue default flow
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Pay extra attention to:
    • Type validation paths in stream_attachment_picker.dart (Tabbed vs System option types).
    • Correct propagation of optionsBuilder through the bottom-sheet and builder selection.
    • Updated OnAttachmentPickerResult usage sites (now FutureOr<bool>) and short-circuit logic in stream_message_input.dart.
    • Sample app changes to ensure handler return types and control flow match new contract.

Possibly related PRs

Suggested reviewers

  • renefloor

Poem

A rabbit hops through tabs and tiles,
Building options with bespoke styles.
"Handled?" it asks with twitching ear—
True stops the flow, false keeps it near.
Bottom sheets open, choices bloom and sing. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "feat(ui): add attachmentPickerOptionsBuilder" directly addresses the primary change in this pull request, which introduces a new builder mechanism to customize attachment picker options. The title is specific, clear, and concise—it identifies the main feature being added and avoids vague or generic language. While the PR also includes secondary changes like the new onAttachmentPickerResult callback, the title appropriately focuses on the most significant change without being overly broad. A teammate reviewing the commit history would clearly understand that this PR introduces a builder pattern for attachment picker customization.

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
Contributor

coderabbitai bot commented Oct 14, 2025

✅ 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
Contributor

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

Actionable comments posted: 1

🧹 Nitpick comments (7)
packages/stream_chat_flutter/lib/src/message_input/attachment_picker/stream_attachment_picker_result.dart (1)

7-8: Clarify return semantics and minor doc nit

Please document the boolean meaning (true = handled, false = continue default). Also fix “a attachment” -> “an attachment”.

Example:

-/// Signature for a function that is called when a attachment picker result
-/// is received.
+/// Signature for a function that is called when an attachment picker result
+/// is received.
+///
+/// Return `true` to indicate the result was handled by the caller;
+/// return `false` to let the SDK perform its default handling.
typedef OnAttachmentPickerResult<T extends StreamAttachmentPickerResult>
    = FutureOr<bool> Function(T result);
packages/stream_chat_flutter/lib/src/message_input/attachment_picker/stream_attachment_picker.dart (4)

432-433: Docs still reference customOptions; update to optionsBuilder

Public docs above still mention [customOptions]. Please update to [optionsBuilder] to avoid confusion.

Proposed doc tweak (outside this hunk):

-/// [customOptions], [galleryPickerConfig], [pollConfig], and
+/// [optionsBuilder], [galleryPickerConfig], [pollConfig], and

494-496: Typo: rename _handleSingePick to _handleSinglePick

Minor but public-facing readability. Update call sites.

-          final result = await _handleSingePick(controller, file);
+          final result = await _handleSinglePick(controller, file);
-          final result = await _handleSingePick(controller, image);
+          final result = await _handleSinglePick(controller, image);
-          final result = await _handleSingePick(controller, video);
+          final result = await _handleSinglePick(controller, video);

And update the declaration (outside selected lines):

// rename
Future<StreamAttachmentPickerResult> _handleSinglePick(
  StreamAttachmentPickerController controller,
  Attachment? attachment,
) async { ... }

Also applies to: 511-514, 530-532


571-575: Error text mentions “custom options”; align to builder API

Update error message to guide users correctly.

-      'custom options must be of type TabbedAttachmentPickerOption when using '
-      'the tabbed attachment picker (default on mobile).',
+      'optionsBuilder must return only TabbedAttachmentPickerOption when using '
+      'the tabbed attachment picker (default on mobile).',

680-683: Error text mentions “custom options”; align to builder API

Same here for system picker.

-      'custom options must be of type SystemAttachmentPickerOption when using '
-      'the system attachment picker (enabled explicitly or on web/desktop).',
+      'optionsBuilder must return only SystemAttachmentPickerOption when using '
+      'the system attachment picker (enabled explicitly or on web/desktop).',
packages/stream_chat_flutter/lib/src/message_input/attachment_picker/stream_attachment_picker_bottom_sheet.dart (1)

71-94: Docs still reference customOptions; update to optionsBuilder and refresh examples

The function docs still instruct passing [customOptions]. Replace with [optionsBuilder] and adjust examples to show modifying defaultOptions via the builder.

I can submit a doc update patch for the examples if helpful.

sample_app/lib/pages/channel_page.dart (1)

175-184: Rename helper to reflect new API (optional)

Rename _onCustomAttachmentPickerResult to _onAttachmentPickerResult for consistency.

-  bool _onCustomAttachmentPickerResult(
+  bool _onAttachmentPickerResult(
     Channel channel,
     StreamAttachmentPickerResult result,
   ) {
     // Notify that the result was not handled.
     if (result is! LocationPicked) return false;

     _onShareLocationPicked(channel, result.location).ignore();
     return true; // Notify that the result was handled.
   }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7ba65c2 and 852c66f.

📒 Files selected for processing (5)
  • packages/stream_chat_flutter/lib/src/message_input/attachment_picker/stream_attachment_picker.dart (4 hunks)
  • packages/stream_chat_flutter/lib/src/message_input/attachment_picker/stream_attachment_picker_bottom_sheet.dart (3 hunks)
  • packages/stream_chat_flutter/lib/src/message_input/attachment_picker/stream_attachment_picker_result.dart (1 hunks)
  • packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart (4 hunks)
  • sample_app/lib/pages/channel_page.dart (2 hunks)
🔇 Additional comments (6)
packages/stream_chat_flutter/lib/src/message_input/attachment_picker/stream_attachment_picker_bottom_sheet.dart (2)

7-16: Good: flexible options builder API

The generic AttachmentPickerOptionsBuilder signature is clear and future‑proof.


126-139: Correct wiring of builder selection and optionsBuilder passthrough

Picker selection by platform flag and passing optionsBuilder looks solid.

sample_app/lib/pages/channel_page.dart (1)

138-140: Correct usage of onAttachmentPickerResult (bool short‑circuit)

Early return pattern is correct and matches new API.

packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart (3)

161-163: New customization points look good

Adding attachmentPickerOptionsBuilder and onAttachmentPickerResult improves extensibility.


991-999: Correctly passes optionsBuilder through to modal

Good wiring to the bottom sheet builder.


1003-1006: Good: user handler gets first dibs

Short‑circuiting when the handler returns true aligns with the new contract.

@dballance
Copy link
Contributor

These changes should address our usecase - which is basically just being able to update the ordering of widgets in the picker.

🍻

@xsahil03x xsahil03x marked this pull request as ready for review October 28, 2025 13:19
@xsahil03x
Copy link
Member Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 28, 2025

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

@codecov
Copy link

codecov bot commented Oct 28, 2025

Codecov Report

❌ Patch coverage is 20.38835% with 82 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (v10.0.0@4bb47e1). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...ut/attachment_picker/stream_attachment_picker.dart 19.58% 78 Missing ⚠️
...er/lib/src/message_input/stream_message_input.dart 0.00% 3 Missing ⚠️
..._picker/stream_attachment_picker_bottom_sheet.dart 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             v10.0.0    #2415   +/-   ##
==========================================
  Coverage           ?   65.73%           
==========================================
  Files              ?      421           
  Lines              ?    26260           
  Branches           ?        0           
==========================================
  Hits               ?    17261           
  Misses             ?     8999           
  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.

@xsahil03x xsahil03x merged commit ea361cd into v10.0.0 Oct 29, 2025
19 of 21 checks passed
@xsahil03x xsahil03x deleted the feat/attachment-picker-options-builder branch October 29, 2025 12:01
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.

4 participants