fix(llc, core, ui, localization): hide raw StreamChannel errors behind themed, connection-aware states - #2846
Conversation
📝 WalkthroughWalkthroughThe update adds typed transport errors, retryable channel initialization, inherited default channel builders, localized network-aware error messages, updated scroll-view error/loading widgets, and connection-error translations across supported locales. ChangesNetwork errors and channel state
Flutter error presentation
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant App
participant StreamChannel
participant StreamChannelState
participant DefaultStreamChannelBuilders
App->>StreamChannel: build channel
StreamChannel->>StreamChannelState: initialize
StreamChannelState->>DefaultStreamChannelBuilders: resolve error builder
DefaultStreamChannelBuilders->>StreamChannelState: render localized error and retry
App->>StreamChannelState: press Try Again
StreamChannelState->>StreamChannelState: retry initialization
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (1)
packages/stream_chat/lib/src/client/channel.dart (1)
2048-2052: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRetry handshake depends on undocumented evaluation ordering across two packages. The
initializedcompleter reset inChannel.queryis only observable by callers that readchannel.initializedafterquery()/watch()has begun executing;StreamChannelState._initializeChannelsilently relies on that. Neither side states the constraint, so a harmless-looking reorder would resurrect the "stuck on stale error" bug.
packages/stream_chat/lib/src/client/channel.dart#L2048-L2052: add a comment noting this reset must remain before the firstawaitso callers observe the fresh completer.packages/stream_chat_flutter_core/lib/src/stream_channel.dart#L830-L834: add a comment (or an explicit two-statement form) stating that_maybeInitChannel()must be started beforechannel.initializedis read.🤖 Prompt for 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. In `@packages/stream_chat/lib/src/client/channel.dart` around lines 2048 - 2052, The retry handshake relies on evaluation ordering that must be documented at both sites: in packages/stream_chat/lib/src/client/channel.dart#L2048-L2052, add a comment stating the _initializedCompleter reset in Channel.query must occur before the first await so callers observe the fresh completer; in packages/stream_chat_flutter_core/lib/src/stream_channel.dart#L830-L834, add a comment or use explicit statements clarifying that _maybeInitChannel() must be started before reading channel.initialized.
🤖 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/lib/src/message_list_view/message_list_view.dart`:
- Around line 538-543: Update the resolveNetworkErrorText calls in
MessageListView at
packages/stream_chat_flutter/lib/src/message_list_view/message_list_view.dart:538-543
and StreamChannelListView at
packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_view.dart:336-347
to provide the view-specific fallbackTitle values
context.translations.loadingMessagesError and
context.translations.loadingChannelsError respectively, preserving existing
behavior for classified errors.
In
`@packages/stream_chat_flutter/lib/src/scroll_view/member_scroll_view/stream_member_grid_view.dart`:
- Around line 368-381: Pass the resolved description as errorSubtitle:
Text(text.description) in the StreamScrollViewErrorWidget builders at
packages/stream_chat_flutter/lib/src/scroll_view/member_scroll_view/stream_member_grid_view.dart#L368-L381,
packages/stream_chat_flutter/lib/src/scroll_view/message_search_scroll_view/stream_message_search_list_view.dart#L338-L351,
packages/stream_chat_flutter/lib/src/scroll_view/photo_gallery/stream_photo_gallery.dart#L393-L404,
and
packages/stream_chat_flutter/lib/src/scroll_view/poll_vote_scroll_view/stream_poll_vote_list_view.dart#L344-L357,
while preserving the existing errorTitle and retry behavior.
In
`@packages/stream_chat_flutter/lib/src/scroll_view/member_scroll_view/stream_member_list_view.dart`:
- Around line 335-348: Update the StreamScrollViewErrorWidget construction in
the errorBuilder callback to pass the resolved description from
resolveNetworkErrorText in addition to errorTitle, ensuring connection and
slow-connection messages are rendered while preserving the custom errorBuilder
and retry behavior.
In
`@packages/stream_chat_flutter/lib/src/scroll_view/reaction_scroll_view/stream_reaction_list_view.dart`:
- Around line 203-211: Pass the resolved description as errorSubtitle:
Text(text.description) in each StreamScrollViewErrorWidget construction using
resolveNetworkErrorText: stream_reaction_list_view.dart lines 203-211,
stream_thread_list_view.dart lines 341-349, stream_user_grid_view.dart lines
367-375, and stream_user_list_view.dart lines 337-345. Keep the existing
errorTitle and retry behavior unchanged.
In
`@packages/stream_chat_flutter/lib/src/scroll_view/stream_scroll_view_loading_widget.dart`:
- Around line 10-12: The deprecated height and width parameters in the loading
widget constructor must continue affecting the spinner dimensions until their
removal. Update the widget’s sizing logic to use caller-provided height and
width when supplied, while retaining the size-based defaults when they are
omitted.
In
`@packages/stream_chat_localizations/lib/src/stream_chat_localizations_ca.dart`:
- Around line 188-204: Add Dart doc comments for the six public localization
getters—connectionErrorTitle, connectionErrorDescription,
slowConnectionErrorTitle, slowConnectionErrorDescription, genericErrorTitle, and
genericErrorDescription—in
packages/stream_chat_localizations/lib/src/stream_chat_localizations_ca.dart
lines 188-204,
packages/stream_chat_localizations/lib/src/stream_chat_localizations_de.dart
lines 182-198, and
packages/stream_chat_localizations/lib/src/stream_chat_localizations_en.dart
lines 187-203.
---
Nitpick comments:
In `@packages/stream_chat/lib/src/client/channel.dart`:
- Around line 2048-2052: The retry handshake relies on evaluation ordering that
must be documented at both sites: in
packages/stream_chat/lib/src/client/channel.dart#L2048-L2052, add a comment
stating the _initializedCompleter reset in Channel.query must occur before the
first await so callers observe the fresh completer; in
packages/stream_chat_flutter_core/lib/src/stream_channel.dart#L830-L834, add a
comment or use explicit statements clarifying that _maybeInitChannel() must be
started before reading channel.initialized.
🪄 Autofix (Beta)
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: 2df328c8-eca7-4f7d-9244-64b8c8cac126
📒 Files selected for processing (42)
packages/stream_chat/CHANGELOG.mdpackages/stream_chat/lib/src/client/channel.dartpackages/stream_chat/lib/src/core/error/stream_chat_error.dartpackages/stream_chat/test/src/client/channel_test.dartpackages/stream_chat/test/src/core/error/stream_chat_error_test.dartpackages/stream_chat_flutter/CHANGELOG.mdpackages/stream_chat_flutter/lib/src/localization/translations.dartpackages/stream_chat_flutter/lib/src/message_list_view/message_list_view.dartpackages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_view.dartpackages/stream_chat_flutter/lib/src/scroll_view/member_scroll_view/stream_member_grid_view.dartpackages/stream_chat_flutter/lib/src/scroll_view/member_scroll_view/stream_member_list_view.dartpackages/stream_chat_flutter/lib/src/scroll_view/message_search_scroll_view/stream_message_search_list_view.dartpackages/stream_chat_flutter/lib/src/scroll_view/photo_gallery/stream_photo_gallery.dartpackages/stream_chat_flutter/lib/src/scroll_view/poll_vote_scroll_view/stream_poll_vote_list_view.dartpackages/stream_chat_flutter/lib/src/scroll_view/reaction_scroll_view/stream_reaction_list_view.dartpackages/stream_chat_flutter/lib/src/scroll_view/stream_scroll_view_error_widget.dartpackages/stream_chat_flutter/lib/src/scroll_view/stream_scroll_view_loading_widget.dartpackages/stream_chat_flutter/lib/src/scroll_view/thread_scroll_view/stream_thread_list_view.dartpackages/stream_chat_flutter/lib/src/scroll_view/user_scroll_view/stream_user_grid_view.dartpackages/stream_chat_flutter/lib/src/scroll_view/user_scroll_view/stream_user_list_view.dartpackages/stream_chat_flutter/lib/src/stream_chat.dartpackages/stream_chat_flutter/lib/src/utils/network_error_text.dartpackages/stream_chat_flutter/lib/stream_chat_flutter.dartpackages/stream_chat_flutter/test/src/localization/default_translations_test.dartpackages/stream_chat_flutter/test/src/stream_chat_default_channel_error_test.dartpackages/stream_chat_flutter_core/CHANGELOG.mdpackages/stream_chat_flutter_core/lib/src/stream_channel.dartpackages/stream_chat_flutter_core/test/stream_channel_test.dartpackages/stream_chat_localizations/CHANGELOG.mdpackages/stream_chat_localizations/example/lib/add_new_lang.dartpackages/stream_chat_localizations/lib/src/stream_chat_localizations_ca.dartpackages/stream_chat_localizations/lib/src/stream_chat_localizations_de.dartpackages/stream_chat_localizations/lib/src/stream_chat_localizations_en.dartpackages/stream_chat_localizations/lib/src/stream_chat_localizations_es.dartpackages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dartpackages/stream_chat_localizations/lib/src/stream_chat_localizations_hi.dartpackages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dartpackages/stream_chat_localizations/lib/src/stream_chat_localizations_ja.dartpackages/stream_chat_localizations/lib/src/stream_chat_localizations_ko.dartpackages/stream_chat_localizations/lib/src/stream_chat_localizations_no.dartpackages/stream_chat_localizations/lib/src/stream_chat_localizations_pt.dartpackages/stream_chat_localizations/test/translations_test.dart
ffdad0c to
18b557e
Compare
There was a problem hiding this comment.
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/CHANGELOG.md`:
- Line 14: Update the changelog entry describing StreamWebSocketError.toString()
to document the actual StreamWebSocketError(...) prefix, while preserving the
existing notes about code and transport type.
🪄 Autofix (Beta)
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: 797a9876-e8df-4207-bac0-0da629b3fdab
📒 Files selected for processing (42)
packages/stream_chat/CHANGELOG.mdpackages/stream_chat/lib/src/client/channel.dartpackages/stream_chat/lib/src/core/error/stream_chat_error.dartpackages/stream_chat/test/src/client/channel_test.dartpackages/stream_chat/test/src/core/error/stream_chat_error_test.dartpackages/stream_chat_flutter/CHANGELOG.mdpackages/stream_chat_flutter/lib/src/localization/translations.dartpackages/stream_chat_flutter/lib/src/message_list_view/message_list_view.dartpackages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_view.dartpackages/stream_chat_flutter/lib/src/scroll_view/member_scroll_view/stream_member_grid_view.dartpackages/stream_chat_flutter/lib/src/scroll_view/member_scroll_view/stream_member_list_view.dartpackages/stream_chat_flutter/lib/src/scroll_view/message_search_scroll_view/stream_message_search_list_view.dartpackages/stream_chat_flutter/lib/src/scroll_view/photo_gallery/stream_photo_gallery.dartpackages/stream_chat_flutter/lib/src/scroll_view/poll_vote_scroll_view/stream_poll_vote_list_view.dartpackages/stream_chat_flutter/lib/src/scroll_view/reaction_scroll_view/stream_reaction_list_view.dartpackages/stream_chat_flutter/lib/src/scroll_view/stream_scroll_view_error_widget.dartpackages/stream_chat_flutter/lib/src/scroll_view/stream_scroll_view_loading_widget.dartpackages/stream_chat_flutter/lib/src/scroll_view/thread_scroll_view/stream_thread_list_view.dartpackages/stream_chat_flutter/lib/src/scroll_view/user_scroll_view/stream_user_grid_view.dartpackages/stream_chat_flutter/lib/src/scroll_view/user_scroll_view/stream_user_list_view.dartpackages/stream_chat_flutter/lib/src/stream_chat.dartpackages/stream_chat_flutter/lib/src/utils/network_error_text.dartpackages/stream_chat_flutter/lib/stream_chat_flutter.dartpackages/stream_chat_flutter/test/src/localization/default_translations_test.dartpackages/stream_chat_flutter/test/src/stream_chat_default_channel_error_test.dartpackages/stream_chat_flutter_core/CHANGELOG.mdpackages/stream_chat_flutter_core/lib/src/stream_channel.dartpackages/stream_chat_flutter_core/test/stream_channel_test.dartpackages/stream_chat_localizations/CHANGELOG.mdpackages/stream_chat_localizations/example/lib/add_new_lang.dartpackages/stream_chat_localizations/lib/src/stream_chat_localizations_ca.dartpackages/stream_chat_localizations/lib/src/stream_chat_localizations_de.dartpackages/stream_chat_localizations/lib/src/stream_chat_localizations_en.dartpackages/stream_chat_localizations/lib/src/stream_chat_localizations_es.dartpackages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dartpackages/stream_chat_localizations/lib/src/stream_chat_localizations_hi.dartpackages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dartpackages/stream_chat_localizations/lib/src/stream_chat_localizations_ja.dartpackages/stream_chat_localizations/lib/src/stream_chat_localizations_ko.dartpackages/stream_chat_localizations/lib/src/stream_chat_localizations_no.dartpackages/stream_chat_localizations/lib/src/stream_chat_localizations_pt.dartpackages/stream_chat_localizations/test/translations_test.dart
🚧 Files skipped from review as they are similar to previous changes (38)
- packages/stream_chat_flutter/lib/stream_chat_flutter.dart
- packages/stream_chat_flutter/lib/src/utils/network_error_text.dart
- packages/stream_chat_localizations/lib/src/stream_chat_localizations_ja.dart
- packages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dart
- packages/stream_chat_localizations/CHANGELOG.md
- packages/stream_chat_localizations/lib/src/stream_chat_localizations_ca.dart
- packages/stream_chat_flutter/lib/src/scroll_view/photo_gallery/stream_photo_gallery.dart
- packages/stream_chat_flutter/lib/src/scroll_view/user_scroll_view/stream_user_grid_view.dart
- packages/stream_chat_localizations/example/lib/add_new_lang.dart
- packages/stream_chat_flutter/test/src/localization/default_translations_test.dart
- packages/stream_chat_flutter/lib/src/scroll_view/member_scroll_view/stream_member_list_view.dart
- packages/stream_chat_flutter/test/src/stream_chat_default_channel_error_test.dart
- packages/stream_chat_localizations/lib/src/stream_chat_localizations_pt.dart
- packages/stream_chat_flutter_core/CHANGELOG.md
- packages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dart
- packages/stream_chat_flutter/lib/src/stream_chat.dart
- packages/stream_chat/test/src/core/error/stream_chat_error_test.dart
- packages/stream_chat_flutter/lib/src/scroll_view/member_scroll_view/stream_member_grid_view.dart
- packages/stream_chat_flutter/lib/src/message_list_view/message_list_view.dart
- packages/stream_chat_localizations/lib/src/stream_chat_localizations_hi.dart
- packages/stream_chat_flutter/lib/src/scroll_view/user_scroll_view/stream_user_list_view.dart
- packages/stream_chat_localizations/lib/src/stream_chat_localizations_de.dart
- packages/stream_chat/lib/src/client/channel.dart
- packages/stream_chat_flutter_core/test/stream_channel_test.dart
- packages/stream_chat_localizations/lib/src/stream_chat_localizations_es.dart
- packages/stream_chat_localizations/lib/src/stream_chat_localizations_en.dart
- packages/stream_chat_flutter/lib/src/scroll_view/thread_scroll_view/stream_thread_list_view.dart
- packages/stream_chat_flutter/lib/src/scroll_view/stream_scroll_view_error_widget.dart
- packages/stream_chat_flutter/lib/src/scroll_view/message_search_scroll_view/stream_message_search_list_view.dart
- packages/stream_chat_localizations/lib/src/stream_chat_localizations_ko.dart
- packages/stream_chat_flutter/lib/src/scroll_view/reaction_scroll_view/stream_reaction_list_view.dart
- packages/stream_chat_flutter/lib/src/localization/translations.dart
- packages/stream_chat_flutter/lib/src/scroll_view/stream_scroll_view_loading_widget.dart
- packages/stream_chat_localizations/lib/src/stream_chat_localizations_no.dart
- packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_view.dart
- packages/stream_chat/lib/src/core/error/stream_chat_error.dart
- packages/stream_chat/test/src/client/channel_test.dart
- packages/stream_chat_flutter_core/lib/src/stream_channel.dart
18b557e to
3fa19b4
Compare
…e states
Route StreamChannel's default loading and error UI through themed, localized
builders (DefaultStreamChannelBuilders) so end users see connection-aware copy
("No Internet Connection" / "Slow Internet Connection" / generic) instead of
raw error objects. Adds StreamChatNetworkError.type for transport-level
classification, a retry() on StreamChannel, and localized error
title/description keys across all locales.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
3fa19b4 to
f865bb0
Compare
FLU-628
Raw
StreamChannelinitialization errors — and the default list/scroll-view error states — were leaking unthemed, unlocalized error details to end users. This routes them through themed, localized, connection-aware default states (no internet / slow connection / generic), overridable at every level.What changed
stream_chatStreamChatNetworkError.type(StreamChatNetworkErrorType) exposing the transport failure kind; deprecateisRequestCancelledErrorin favor oftype == StreamChatNetworkErrorType.cancel.Channel.initializederrored or itsname/image/extraDatasetters throwing — a subsequent successful (re)init recovers cleanly (supports the retry flow).toString()forStreamWebSocketError/StreamChatNetworkError.stream_chat_flutter_coreStreamChannelState.retry()to re-run a failed channel init (the retry action forStreamChannel.errorBuilder).DefaultStreamChannelBuilders, an inherited widget supplying default loading/error builders to descendantStreamChannels.StreamChannelerror state no longer exposes raw error details.stream_chat_flutterStreamChatnow installs themed, connection-aware default loading & error states forStreamChannel— overridable per-StreamChannelor viaDefaultStreamChannelBuilders.StreamScrollViewErrorWidgetgainserrorSubtitle;StreamScrollViewLoadingWidgetgainssize(StreamLoadingSpinnerSize) and deprecates the now-unusedheight/width.stream_chat_localizationsconnectionError*,slowConnectionError*,genericError*) for all supported locales.Testing
dart analyze --fatal-infosclean.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
resolveNetworkErrorTextand improved default channel loading/error UI via inherited default builders, includingretry()for failed channel initialization.StreamScrollViewLoadingWidget.sizeandStreamScrollViewErrorWidget.errorSubtitle.Bug Fixes
type), cancellation detection, and errortoString()formatting.Deprecations
StreamScrollViewLoadingWidgetwidth/height.