Skip to content

Fix Leave option not shown when Delete option is visible for group channels#6416

Open
VelikovPetar wants to merge 1 commit intodevelopfrom
bug/AND-1170_show_leave_and_delete_for_group_channels
Open

Fix Leave option not shown when Delete option is visible for group channels#6416
VelikovPetar wants to merge 1 commit intodevelopfrom
bug/AND-1170_show_leave_and_delete_for_group_channels

Conversation

@VelikovPetar
Copy link
Copy Markdown
Contributor

@VelikovPetar VelikovPetar commented May 6, 2026

Goal

For group channels where the current user has both leave-channel and delete-channel capabilities (typically channel owners/admins), the channel info screen and the Compose channel-list options menu were only surfacing Delete and hiding Leave. Users want to be able to leave a group they own without having to delete it for everyone.

This change makes both options available whenever the user has the corresponding capability.

Implementation

  • ChannelInfoViewController.buildChannelOptionList: appends LeaveChannel whenever leave-channel capability is present, and independently appends DeleteChannel when delete-channel is present (previously the two were mutually exclusive via if/else).
  • ChannelOptions.buildGroupChannelActions (Compose channel-list bottom sheet): shows LeaveGroup whenever canLeaveChannel, dropping the && !canDeleteChannel exclusion.
  • ChannelInfoOptionButton: replaces the CompositionLocalProvider(LocalContentColor = accentError) wrapper with an explicit destructive: Boolean parameter that drives icon tint and text color (buttonDestructiveText vs textSecondary/textPrimary). Call sites for BlockUser, LeaveChannel, and DeleteChannel pass the appropriate flag — LeaveChannel and DeleteChannel are destructive, BlockUser is not.
  • ChannelInfoViewControllerTest: existing owner-capabilities test updated to expect both LeaveChannel and DeleteChannel in the option list.
  • Snapshot images regenerated for ChannelInfoOptionItemTest (direct + group, light + dark) and DirectChannelInfoContentTest to reflect the explicit destructive coloring.

Testing

  • Updated unit test in ChannelInfoViewControllerTest covers the owner case (both capabilities → both options listed).
  • Updated snapshot tests cover the destructive coloring in light/dark mode for both direct and group channel option items.
  • Manual verification: open a group where you have both leave and delete capabilities and confirm both options appear in the channel info screen and in the Compose channel-list long-press menu.

Summary by CodeRabbit

Release Notes

  • UI Improvements

    • Destructive channel actions (leave, delete) now display with distinctive destructive styling for enhanced visual clarity.
  • Bug Fixes

    • Users with both leave and delete channel permissions can now access both options simultaneously, instead of only seeing one.

Co-Authored-By: Claude <noreply@anthropic.com>
@VelikovPetar VelikovPetar added the pr:bug Bug fix label May 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled (or ignored for dependabot PRs).

🎉 Great job! This PR is ready for review.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.82 MB 5.82 MB 0.00 MB 🟢
stream-chat-android-ui-components 11.02 MB 11.02 MB 0.00 MB 🟢
stream-chat-android-compose 12.37 MB 12.37 MB 0.00 MB 🟢

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 6, 2026

@VelikovPetar VelikovPetar changed the title Show Leave and Delete options together for group channels (AND-1170) Show Leave and Delete options together for group channels May 6, 2026
@VelikovPetar VelikovPetar changed the title Show Leave and Delete options together for group channels Fix Leave option not shown when Delete option is visible for group channels May 6, 2026
@VelikovPetar VelikovPetar marked this pull request as ready for review May 8, 2026 09:10
@VelikovPetar VelikovPetar requested a review from a team as a code owner May 8, 2026 09:10
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 973a71e1-8c4c-4021-8e95-56efca900be6

📥 Commits

Reviewing files that changed from the base of the PR and between db25173 and 15b1de8.

⛔ Files ignored due to path filters (6)
  • stream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.channel.info_ChannelInfoOptionItemTest_direct_channel_info_option_items_in_dark_mode.png is excluded by !**/*.png
  • stream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.channel.info_ChannelInfoOptionItemTest_direct_channel_info_option_items_in_light_mode.png is excluded by !**/*.png
  • stream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.channel.info_ChannelInfoOptionItemTest_group_channel_info_option_items_in_dark_mode.png is excluded by !**/*.png
  • stream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.channel.info_ChannelInfoOptionItemTest_group_channel_info_option_items_in_light_mode.png is excluded by !**/*.png
  • stream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.channel.info_DirectChannelInfoContentTest_content.png is excluded by !**/*.png
  • stream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.channel.info_DirectChannelInfoContentTest_content_in_dark_mode.png is excluded by !**/*.png
📒 Files selected for processing (5)
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channel/info/ChannelInfoOption.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channel/info/ChannelInfoOptionItem.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/channels/ChannelOptions.kt
  • stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/channel/info/ChannelInfoViewController.kt
  • stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/feature/channel/info/ChannelInfoViewControllerTest.kt

Walkthrough

The pull request refactors channel info option styling from externally applied color providers to a destructive parameter on ChannelInfoOptionButton, and changes option visibility logic to allow LeaveChannel and DeleteChannel options to coexist rather than be mutually exclusive. Updates flow from compose parameter addition through UI refactoring, option visibility rules, and test assertions.

Changes

Destructive Action Styling and Dual Options Support

Layer / File(s) Summary
Compose Button Destructive Parameter
stream-chat-android-compose/.../ChannelInfoOption.kt
ChannelInfoOptionButton adds a destructive: Boolean parameter that controls icon tint and text color styling, switching between error accent and secondary/primary colors based on the flag.
Compose Option Items Refactoring
stream-chat-android-compose/.../ChannelInfoOptionItem.kt
Removes CompositionLocalProvider wrappers and updates BlockUser (destructive=false), LeaveChannel (destructive=true), and DeleteChannel (destructive=true) options to use explicit destructive parameters. Imports simplified to remove unused material3 color providers.
Option Visibility and Logic Changes
stream-chat-android-compose/.../ChannelOptions.kt, stream-chat-android-ui-common/.../ChannelInfoViewController.kt
Option inclusion logic changed from mutually exclusive if/else chains to independent conditions, allowing both LeaveChannel and DeleteChannel options to appear when user has both LEAVE_CHANNEL and DELETE_CHANNEL capabilities.
Compose Preview and Test Updates
stream-chat-android-compose/.../ChannelInfoOption.kt, stream-chat-android-ui-common/.../ChannelInfoViewControllerTest.kt
Delete button preview updated to pass destructive = true; group channel options test assertion updated to expect LeaveChannel option before DeleteChannel when both capabilities are present.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A button now knows if it's naughty or nice,
With destructive flags—no more color splice!
Leave and Delete dance together with glee,
No longer exclusive, just wild and free.
Compose refactored, the tests align,
This hop through the code is truly divine!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: enabling the Leave option to be shown alongside the Delete option for group channels.
Description check ✅ Passed The description covers Goal, Implementation, and Testing sections comprehensively with clear explanations of changes across multiple files and test updates.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bug/AND-1170_show_leave_and_delete_for_group_channels

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants