Skip to content

Conversation

xsahil03x
Copy link
Member

@xsahil03x xsahil03x commented Sep 19, 2025

Submit a pull request

Fixes: FLU-234

Description of the pull request

This PR allows users with the sendReply capability to send replies within a thread, even if they don't have broader send message permission.

Summary by CodeRabbit

  • Bug Fixes

    • Resolved an issue preventing users with reply permissions from sending threaded replies. Threaded messaging now respects reply-specific permissions in message input.
  • Documentation

    • Added an “Upcoming Beta” section to the changelog highlighting the fix for threaded replies.

…ability

This commit allows users with the `sendReply` capability to send replies within a thread, even if they don't have broader send message permission.
Copy link
Contributor

coderabbitai bot commented Sep 19, 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

Adds thread-aware permission checks to message input so users with sendReply can reply in threads even without sendMessage. Updates the changelog to note the fix. No public API changes.

Changes

Cohort / File(s) Summary
Docs: Changelog update
packages/stream_chat_flutter/CHANGELOG.md
Added “Upcoming Beta” with a fix note: users with sendReply can send thread replies. No code changes.
Message input permission logic
packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart
Updated canSendOrUpdateMessage to detect thread context (via parentId) and include ChannelCapability.sendReply when inside a thread. Existing edit checks unchanged; no API changes.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor User
    participant UI as MessageInput UI
    participant Perm as Capability Check
    participant Chan as Channel (capabilities)

    User->>UI: Focus thread reply input
    UI->>Perm: canSendOrUpdateMessage(message)
    Perm->>Perm: insideThread = message.parentId != null
    Perm->>Chan: get capabilities
    alt insideThread
        Note over Perm: Include sendReply in check
    else not in thread
        Note over Perm: Check sendMessage only
    end
    Perm-->>UI: allowed / denied
    alt allowed
        UI->>Chan: send reply message
        Chan-->>UI: ack
    else denied
        UI-->>User: input disabled / no permission
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10–15 minutes

Suggested reviewers

  • Brazol

Poem

A burrow of threads where replies may hop,
I nibble the perms—sendReply on top.
No new posts today? That’s fine by me,
In rabbit lanes, we thread joyfully.
Tap-tap, approve—then bounce away,
Carrots for bugs squashed fresh today. 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "fix(ui): enable sending reply in threads for users with sendReply capability" succinctly and accurately describes the primary change: allowing users with only the sendReply capability to send replies in thread contexts. It is concise, specific to the UI behavior being fixed, and contains no extraneous noise or vague terms. A teammate scanning history will understand the main intent from this title.
Linked Issues Check ✅ Passed The change in packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart adds thread-aware permission logic that includes ChannelCapability.sendReply when inside a thread, which directly implements the suggested solution in FLU-234. This resolves the reported reproduction where the input was disabled for users who have send-reply but not send-message and restores reply-only workflows. The PR therefore meets the coding-related requirements of the linked issue.
Out of Scope Changes Check ✅ Passed The PR only modifies the message input permission check and updates the CHANGELOG entry; no other source files or unrelated features were changed. Both edits are directly tied to enabling reply-only permission behavior described in the linked issue. I see no out-of-scope modifications.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

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

Copy link
Contributor

coderabbitai bot commented Sep 19, 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

codecov bot commented Sep 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (v10.0.0@90d5bc2). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             v10.0.0    #2385   +/-   ##
==========================================
  Coverage           ?   64.93%           
==========================================
  Files              ?      419           
  Lines              ?    25944           
  Branches           ?        0           
==========================================
  Hits               ?    16846           
  Misses             ?     9098           
  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.

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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart (1)

620-634: Fix edit gating: require update rights for stored edits; follow send rights for composing/bounced edits.

File: packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart — canSendOrUpdateMessage

Current OR logic lets thread sendReply enable the edit UI for stored messages without update permissions; split edit vs send logic and treat bounced-with-error edits as sends.

-    bool canSendOrUpdateMessage(List<ChannelCapability> capabilities) {
-      var result = capabilities.contains(ChannelCapability.sendMessage);
-
-      final insideThread = _effectiveController.message.parentId != null;
-      if (insideThread) {
-        result |= capabilities.contains(ChannelCapability.sendReply);
-      }
-
-      if (_isEditing) {
-        result |= capabilities.contains(ChannelCapability.updateOwnMessage);
-        result |= capabilities.contains(ChannelCapability.updateAnyMessage);
-      }
-
-      return result;
-    }
+    bool canSendOrUpdateMessage(List<ChannelCapability> capabilities) {
+      final insideThread = _effectiveController.message.parentId != null;
+      final isBouncedEdit =
+          _isEditing && _effectiveController.message.isBouncedWithError;
+
+      // If editing a stored message, require update capability strictly.
+      if (_isEditing && !isBouncedEdit) {
+        return capabilities.contains(ChannelCapability.updateOwnMessage) ||
+            capabilities.contains(ChannelCapability.updateAnyMessage);
+      }
+
+      // Composing (or editing a bounced error), follow send rights.
+      return capabilities.contains(ChannelCapability.sendMessage) ||
+          (insideThread && capabilities.contains(ChannelCapability.sendReply));
+    }

Verified:

  • Not editing, inside thread, only sendReply → input enabled (expected).
  • Not editing, channel (no thread), only sendReply → input disabled (expected).
  • Editing stored thread message, lacks update rights but has sendReply → currently enabled (bug); editing a bounced-with-error message → enabled and will be sent (expected).
🧹 Nitpick comments (1)
packages/stream_chat_flutter/CHANGELOG.md (1)

1-6: Unify section naming: prefer “Upcoming” or bump beta version.

Top section uses “Upcoming Beta” while the file already has “Upcoming”. Pick one for consistency, or move this bullet under the existing “Upcoming”. Also consider phrasing: “Fixed an issue where users with the sendReply capability couldn’t send replies in threads. (FLU-234)”

📜 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 0f8a4f5 and 80836ba.

📒 Files selected for processing (2)
  • packages/stream_chat_flutter/CHANGELOG.md (1 hunks)
  • packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-08T14:27:59.621Z
Learnt from: xsahil03x
PR: GetStream/stream-chat-flutter#2348
File: packages/stream_chat_flutter_core/lib/src/stream_channel.dart:383-406
Timestamp: 2025-08-08T14:27:59.621Z
Learning: In stream_chat_flutter_core/lib/src/stream_channel.dart, threads (replies) do not support around-anchor loading. Thread replies are fetched as: initial latest page via StreamChannelState.getReplies(), and further pagination via StreamChannelState.queryReplies(parentId, direction: top|bottom). Anchored loads apply only to channel messages, not to threads.

Applied to files:

  • packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build (android)
  • GitHub Check: test

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