Expose core StreamConnectionState as the public connection state (breaking)#1739
Conversation
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
WalkthroughThe client replaces its local ChangesConnection state unification
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant StreamClientListener
participant StreamVideoClient
participant ClientState
StreamClientListener->>StreamVideoClient: onState(StreamConnectionState)
StreamVideoClient->>ClientState: handleStreamState(state)
ClientState->>ClientState: publish connection state
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
eda7d6c to
5b4832d
Compare
092085e to
a632706
Compare
f5c9138 to
b01d2d2
Compare
97f4003 to
fa2eeb2
Compare
c14482e to
5378836
Compare
c761587 to
6ecf46f
Compare
c55f56f to
05ef80c
Compare
11e6329 to
d03a473
Compare
393ef1f to
c05d2f7
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/ClientState.kt (1)
138-140: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider adding a debug log in
handleStreamStatefor observability.The class already has a
logger(line 50). A one-line debug log would help trace connection-state transitions during development without leaking sensitive data (StreamConnectionStatecarries user IDs, not JWTs/ICE tokens).♻️ Optional: add debug log
internal fun handleStreamState(streamState: StreamConnectionState) { + logger.d { "[handleStreamState] $streamState" } _connection.value = streamState }🤖 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 `@stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/ClientState.kt` around lines 138 - 140, Add a one-line debug log at the start of ClientState.handleStreamState using the existing logger, recording the incoming StreamConnectionState to trace connection transitions without logging sensitive credentials.
🤖 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.
Nitpick comments:
In
`@stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/ClientState.kt`:
- Around line 138-140: Add a one-line debug log at the start of
ClientState.handleStreamState using the existing logger, recording the incoming
StreamConnectionState to trace connection transitions without logging sensitive
credentials.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 3c7aa3f2-6fdc-4b6e-879d-384aef18cd9b
📒 Files selected for processing (16)
stream-video-android-core/api/stream-video-android-core.apistream-video-android-core/src/androidTest/kotlin/io/getstream/video/android/core/AndroidDeviceTest.ktstream-video-android-core/src/main/kotlin/io/getstream/video/android/core/ClientState.ktstream-video-android-core/src/main/kotlin/io/getstream/video/android/core/StreamVideoClient.ktstream-video-android-core/src/main/kotlin/io/getstream/video/android/core/socket/coordinator/v2/ConnectionStateMapper.ktstream-video-android-core/src/test/kotlin/io/getstream/video/android/core/ClientAndAuthTest.ktstream-video-android-core/src/test/kotlin/io/getstream/video/android/core/ClientStateConnectionMappingTest.ktstream-video-android-core/src/test/kotlin/io/getstream/video/android/core/ClientStateTest.ktstream-video-android-core/src/test/kotlin/io/getstream/video/android/core/StreamVideoClientTest.ktstream-video-android-core/src/test/kotlin/io/getstream/video/android/core/rtc/RtcSessionTest.ktstream-video-android-ui-xml/api/stream-video-android-ui-xml.apistream-video-android-ui-xml/src/main/kotlin/io/getstream/video/android/xml/widget/appbar/CallAppBarContent.ktstream-video-android-ui-xml/src/main/kotlin/io/getstream/video/android/xml/widget/appbar/CallAppBarView.ktstream-video-android-ui-xml/src/main/kotlin/io/getstream/video/android/xml/widget/appbar/internal/DefaultCallAppBarCenterContent.ktstream-video-android-ui-xml/src/main/kotlin/io/getstream/video/android/xml/widget/appbar/internal/DefaultCallAppBarLeadingContent.ktstream-video-android-ui-xml/src/main/kotlin/io/getstream/video/android/xml/widget/appbar/internal/DefaultCallAppBarTrailingContent.kt
💤 Files with no reviewable changes (3)
- stream-video-android-core/src/test/kotlin/io/getstream/video/android/core/ClientStateConnectionMappingTest.kt
- stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/socket/coordinator/v2/ConnectionStateMapper.kt
- stream-video-android-core/api/stream-video-android-core.api
|
Nice PR. @aleksandar-apostolov Low priority: |
…tate Delete the video-owned ConnectionState sealed interface instead of reshaping it into a 1:1 mirror of core's StreamConnectionState: a mirror forbidden from diverging is pure maintenance (copy + mapper + mapping tests + drift risk) with no insulation benefit, since core is already an api() dependency. The Feeds SDK sets the precedent — its FeedsClient.state exposes StreamConnectionState directly, so both core-v5 SDKs now surface the same connection state type. ClientState.connection becomes StateFlow<StreamConnectionState>, fed by handleStreamState as a plain assignment from the StreamClient listener. Delete the dead legacy paths (handleState(VideoSocketState), handleError, the ConnectedEvent branch — core consumes the auth event internally) and ConnectionStateMapper with its mapping test. XML appbar renderState signatures and the connection assertions in ClientAndAuthTest, AndroidDeviceTest and RtcSessionTest move to the core type; RtcSessionTest's assertion also switches to RealtimeConnection, the type call.state.connection actually is.
Pure deletion: the video ConnectionState surface (44 lines) leaves the dump; the public connection state now comes from stream-android-core.
The deletion-heavy diff leaves ~4 new lines, so the single uncovered one (the onState body) fails Sonar's 80% new-code gate on its own.
c05d2f7 to
ca4f3d9
Compare
|



Goal
Refs AND-1283
⚠ Breaking public API change. Removes the video-owned
ConnectionStateentirely —ClientState.connectionnow exposes core'sStreamConnectionStatedirectly, the same pattern the Feeds SDK uses (FeedsClient.state). No copy, no mapper, no drift risk.Depends on #1738 (StreamClient wiring). Merge after parent.
Implementation
ClientState.connectionbecomesStateFlow<StreamConnectionState>;handleStreamStateis a plain assignment fed by theStreamClientlistener (onState).ConnectionStatesealed interface,ConnectionStateMapper+ mapping test, and the dead legacy paths (handleState(VideoSocketState),handleError, theConnectedEventbranch — core consumes the auth event internally).renderState(...)signatures move to the core type (pass-through, no behavior change).stream-video-android-core.api; the connection-state surface now ships instream-android-core.Testing
./gradlew :stream-video-android-core:testDebugUnitTest—ClientStateTestasserts every reported core state is published unchanged;ClientAndAuthTest/AndroidDeviceTestassertions moved to the core type../gradlew apiCheck spotlessCheckSummary by CodeRabbit
Breaking Changes
Bug Fixes
Tests