Skip to content

Populate ChannelData.deletedAt when a channel is deleted - #6693

Merged
gpunto merged 3 commits into
v6from
fix/v6-channel-deleted-state
Sep 11, 2026
Merged

gpunto merged 3 commits into
v6from
fix/v6-channel-deleted-state

Conversation

@gpunto

@gpunto gpunto commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Goal

ChannelState.channelData.deletedAt was never populated, so an open chat screen had no way to tell that its
channel had been deleted. Listening for ChannelDeletedEvent was the only working signal.

Closes AND-1522

Implementation

  • Forward a batch to the channel logic before discarding the channel. EventHandlerSequential evicted the
    channel from both registries first, so channel.deleted never reached ChannelEventHandler and the branch
    setting the deletion date had been dead since the eviction was introduced. The channel is still discarded
    right after, and channelData keeps the value for consumers already holding the state.
  • Handle notification.channel_deleted in ChannelEventHandler, which had no branch for it at all.
  • Stop clearing the messages on deletion. Truncation remains the one event that empties a channel, matching
    iOS, where message visibility is gated on the channel's truncatedAt and never on its deletion date. No
    released version cleared them here, since the branch was unreachable.

Testing

  • New EventHandlerSequentialChannelDeletedTest covers both event types over the real StateRegistry and
    LogicRegistry, asserting the deletion date reaches an active channel's state and that the channel is
    still discarded afterwards. Both rows fail without the reorder, which a registry mock would not catch.
  • Verified on a device against the demo app: with a channel open, deleting it server-side moved deletedAt
    from null to the deletion date while the message count stayed put.

Summary by CodeRabbit

  • Bug Fixes
    • Channel deletion events now update the channel’s deleted status before the channel is removed from active state.
    • Both standard and notification-based channel deletion events are handled consistently.
    • Messages are retained when a channel is deleted instead of being removed automatically.
    • Improved event processing ensures deletion-related state changes are observable before channel disposal.

@gpunto gpunto added the pr:bug Bug fix label Sep 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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.

@gpunto

gpunto commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

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.

@github-actions

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.26 MB 5.32 MB 0.05 MB 🟢
stream-chat-android-offline 5.49 MB 5.54 MB 0.05 MB 🟢
stream-chat-android-ui-components 10.64 MB 10.76 MB 0.11 MB 🟢
stream-chat-android-compose 12.87 MB 13.15 MB 0.28 MB 🟡

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: e1d061df-7e8d-4cac-a644-cf9c8ee4fe36

📥 Commits

Reviewing files that changed from the base of the PR and between f3bbcd1 and 3774fe5.

📒 Files selected for processing (5)
  • stream-chat-android-state/src/main/java/io/getstream/chat/android/state/event/handler/internal/EventHandlerSequential.kt
  • stream-chat-android-state/src/main/java/io/getstream/chat/android/state/plugin/logic/channel/internal/ChannelEventHandler.kt
  • stream-chat-android-state/src/test/java/io/getstream/chat/android/state/channel/controller/WhenHandleEvent.kt
  • stream-chat-android-state/src/test/java/io/getstream/chat/android/state/event/handler/internal/EventHandlerSequentialChannelDeletedTest.kt
  • stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/logic/channel/internal/ChannelEventHandlerTest.kt

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


Walkthrough

Channel deletion events now update active channel state before disposal. Both deletion event types preserve messages and record deletedAt. Tests cover state ordering, registry removal, and message preservation.

Changes

Channel deletion handling

Layer / File(s) Summary
Deletion state handling
stream-chat-android-state/src/main/.../ChannelEventHandler.kt, stream-chat-android-state/src/test/.../WhenHandleEvent.kt, stream-chat-android-state/src/test/.../ChannelEventHandlerTest.kt
ChannelEventHandler handles both channel deletion event types. It records the deletion date without removing messages. Tests verify both behaviors.
Event forwarding and disposal ordering
stream-chat-android-state/src/main/.../EventHandlerSequential.kt, stream-chat-android-state/src/test/.../EventHandlerSequentialChannelDeletedTest.kt
EventHandlerSequential forwards deletion events before batch handling and removes channel logic afterward. Parameterized tests verify state updates before disposal.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant EventHandlerSequential
  participant ChannelEventHandler
  participant StateRegistry
  participant LogicRegistry
  EventHandlerSequential->>ChannelEventHandler: forward deletion event
  ChannelEventHandler->>ChannelEventHandler: set deletedAt and preserve messages
  EventHandlerSequential->>StateRegistry: handle batch event
  EventHandlerSequential->>LogicRegistry: remove channel logic
Loading

Merge Risk: ⚪ Minimal · up to 3774f

Channel deletion now records deletedAt before active logic is discarded and preserves messages for later truncation. Coverage exercises both event variants and disposal ordering, with no actionable current-head risk evident.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 5 files. 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 clearly and concisely describes the primary change: populating ChannelData.deletedAt when a channel is deleted.
Description check ✅ Passed The description includes the required Goal, Implementation, and Testing sections. It explains the reason for the change, the implementation details, and the test coverage. UI details, checklist items,…
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/v6-channel-deleted-state

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

A rabbit taps the event stream bright
Deletion dates settle right
Messages stay within their burrowed place
Logic leaves after state keeps pace
Two event paths complete the race

Comment @coderabbitai help to get the list of available commands.

@gpunto
gpunto marked this pull request as ready for review September 11, 2026 07:20
@gpunto
gpunto requested a review from a team as a code owner September 11, 2026 07:20
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@gpunto
gpunto merged commit 01619ef into v6 Sep 11, 2026
18 of 19 checks passed
@gpunto
gpunto deleted the fix/v6-channel-deleted-state branch September 11, 2026 13:20
@stream-public-bot stream-public-bot added the released Included in a release label Sep 15, 2026
@stream-public-bot

Copy link
Copy Markdown
Contributor

🚀 Available in v6.44.0

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

Labels

pr:bug Bug fix released Included in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants