Skip to content

fix(ui, samples): dispose fixes on channel list and avatar - #2876

Merged
renefloor merged 3 commits into
masterfrom
fix/channellist-dispose
Aug 12, 2026
Merged

renefloor merged 3 commits into
masterfrom
fix/channellist-dispose

Conversation

@renefloor

@renefloor renefloor commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Submit a pull request

CLA

  • I have signed the Stream CLA (required).
  • The code changes follow best practices
  • Code changes are tested (add some information if not applicable)

Description of the pull request

The avatar issue was introduced in: #2827
The issue was not released yet, so no changelog entry needed for this.

The channel.isOneToOne checks if the channel state is already disposed and if it is it crashes. This PR adds a channel state check before that.

In the ChannelList we have the issue that the _messageSearchListController was only created inside the dispose method, because of the late final. Now it's always created in didChangeDependencies.

Summary by CodeRabbit

  • Bug Fixes

    • Prevented channel avatars from throwing errors when channel state is disposed during a rebuild.
    • Improved avatar rendering while membership data is updating or unavailable.
    • Ensured channel lists refresh correctly when the active chat context changes.
    • Preserved active channel-list searches during context changes and reapplied them automatically.
  • Tests

    • Added regression coverage for avatar rebuilding after channel state disposal and member-data updates.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a2f7d6ed-f9eb-4c6d-bd28-eac5dca1e173

📥 Commits

Reviewing files that changed from the base of the PR and between e88d737 and 04ce301.

📒 Files selected for processing (1)
  • packages/stream_chat_flutter/test/src/avatars/stream_channel_avatar_test.dart
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/stream_chat_flutter/test/src/avatars/stream_channel_avatar_test.dart

📝 Walkthrough

Walkthrough

The PR makes StreamChannelAvatar safe when channel state becomes unavailable and adds regression coverage. It also reinitializes ChannelList controllers when dependencies change.

Changes

Channel avatar disposal handling

Layer / File(s) Summary
Disposal guard and regression test
packages/stream_chat_flutter/lib/src/components/avatar/stream_channel_avatar.dart, packages/stream_chat_flutter/test/src/avatars/stream_channel_avatar_test.dart
The avatar returns an empty widget when channel state is unavailable. The test covers active rendering, rebuilds after disposal, and member-stream emissions.

Channel list controller lifecycle

Layer / File(s) Summary
Dependency-driven controller initialization
sample_app/lib/widgets/channel_list.dart
ChannelList initializes mutable controllers in didChangeDependencies, disposes existing controllers, preserves the search query, and recreates them with the current client and user.

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

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies disposal fixes in the channel list and avatar, which matches the main changes in the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/channellist-dispose

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/stream_chat_flutter/test/src/avatars/stream_channel_avatar_test.dart`:
- Around line 89-102: Update the test around liveState disposal to emit a
membersController value immediately after setting liveState to null, before
incrementing rebuildNotifier and pumping. Keep the subsequent rebuild and
exception assertion separate so the member-stream disposal path is exercised
while the nested BetterStreamBuilder is still mounted.

In `@sample_app/lib/widgets/channel_list.dart`:
- Around line 32-46: Update _initControllers so replacing the search controller
preserves and reloads the existing _controller.text query, keeping active search
results synchronized; alternatively, clear _controller and reset _isSearchActive
before creating the replacement. Ensure the UI does not remain in active-search
mode with an empty replacement query.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 34c19af3-1826-471f-a796-601b93cd74d2

📥 Commits

Reviewing files that changed from the base of the PR and between dec43e3 and 28b8546.

📒 Files selected for processing (3)
  • packages/stream_chat_flutter/lib/src/components/avatar/stream_channel_avatar.dart
  • packages/stream_chat_flutter/test/src/avatars/stream_channel_avatar_test.dart
  • sample_app/lib/widgets/channel_list.dart

Comment thread sample_app/lib/widgets/channel_list.dart Outdated
@codecov

codecov Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.47%. Comparing base (dec43e3) to head (04ce301).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2876      +/-   ##
==========================================
+ Coverage   73.45%   73.47%   +0.01%     
==========================================
  Files         431      431              
  Lines       27826    27827       +1     
==========================================
+ Hits        20439    20445       +6     
+ Misses       7387     7382       -5     

☔ View full report in Codecov by Harness.
📢 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/stream_chat_flutter/test/src/avatars/stream_channel_avatar_test.dart`:
- Around line 92-102: Update the channel.isOneToOne stub in this regression test
to throw when liveState is null, while preserving its true result for active
state. After membersController.add and tester.pump(), assert that
find.byType(StreamUserAvatar) finds nothing, proving the disposed-channel
fallback rendered and the member-stream builder exercised the guard.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 03631ae3-3995-4eac-85cb-f26e824f46db

📥 Commits

Reviewing files that changed from the base of the PR and between 28b8546 and e88d737.

📒 Files selected for processing (2)
  • packages/stream_chat_flutter/test/src/avatars/stream_channel_avatar_test.dart
  • sample_app/lib/widgets/channel_list.dart

@renefloor
renefloor merged commit 56462e1 into master Aug 12, 2026
26 of 28 checks passed
@renefloor
renefloor deleted the fix/channellist-dispose branch August 12, 2026 09:11
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.

2 participants