Skip to content

fix(llc): rewatch calls after coordinator reconnects #1029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 17, 2025

Conversation

Brazol
Copy link
Contributor

@Brazol Brazol commented Jul 17, 2025

resolves FLU-115

We need to re-watch the previously watched calls after the coordinator connection is restored. That applies to active calls as well as calls watched by calling the call.get(watch: true) method.

Summary by CodeRabbit

  • Bug Fixes

    • Resolved an issue where coordinator events were not being listened to after a fast reconnect during a call.
  • New Features

    • The system now automatically re-subscribes to updates for calls being watched after a connection is reestablished.
    • Users' watched calls are better tracked and managed, ensuring a smoother experience during connection interruptions.

@Brazol Brazol requested a review from a team as a code owner July 17, 2025 13:58
Copy link

coderabbitai bot commented Jul 17, 2025

"""

Walkthrough

This change introduces logic to track and manage "watched calls" in the stream_video package. It adds a mechanism to re-subscribe to these calls after a fast reconnect by emitting and handling a new CoordinatorReconnectedEvent. State management and event handling are updated to support this workflow.

Changes

File(s) Change Summary
packages/stream_video/lib/src/core/client_state.dart Added watchedCalls state emitter, setWatchedCall method, and updated logic to manage watched calls in client state.
packages/stream_video/lib/src/call/call.dart Updated _performGetOperation to set the watched call when watch is true.
packages/stream_video/lib/src/coordinator/models/coordinator_events.dart Introduced CoordinatorReconnectedEvent for handling websocket reconnection events.
packages/stream_video/lib/src/coordinator/open_api/coordinator_ws.dart Modified CoordinatorWebSocket to emit CoordinatorReconnectedEvent on reconnect.
packages/stream_video/lib/src/stream_video.dart Added handler for CoordinatorReconnectedEvent to re-query watched calls after reconnect.
packages/stream_video/CHANGELOG.md Documented the bug fix regarding coordinator event listening after fast reconnect.

Sequence Diagram(s)

sequenceDiagram
    participant CoordinatorWebSocket
    participant StreamVideo
    participant ClientState
    participant Call

    CoordinatorWebSocket->StreamVideo: Emits CoordinatorReconnectedEvent on reconnect
    StreamVideo->ClientState: Checks watchedCalls
    alt watchedCalls not empty
        StreamVideo->StreamVideo: Re-query calls with watch=true for watched call CIDs
        StreamVideo->Call: _performGetOperation(watch: true)
        Call->ClientState: setWatchedCall(this)
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Address issue of close captions sometimes stopping and not showing (FLU-115) Changes focus on call reconnection and watched calls; no mention of captions or related logic.

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Addition of CoordinatorReconnectedEvent and reconnection handling logic (multiple files) These changes focus on call reconnection and watched call state management, unrelated to close captions issue FLU-115.

Possibly related PRs

Suggested reviewers

  • renefloor

Poem

🐇
When connections break and swiftly mend,
Our watched calls now resume, my friend.
With events that signal, "We're back online!"
The state is tracked, the calls align.
So hop along, no need to fear—
Your calls will always reappear!

"""


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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/stream_video/CHANGELOG.md (1)

11-11: Minor wording tweak for consistency

Most bullet points in this section refer to “a call” in lowercase, and use active “when X happens” phrasing. Consider aligning wording:

-* Fixed an issue where coordinator events were not listened to after a fast reconnect in a Call.
+* Fixed an issue where coordinator events were not listened to after a fast reconnect in a call.

Purely stylistic – feel free to ignore if “Call” is intentionally capitalised.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7b782aa and be0930e.

📒 Files selected for processing (6)
  • packages/stream_video/CHANGELOG.md (1 hunks)
  • packages/stream_video/lib/src/call/call.dart (1 hunks)
  • packages/stream_video/lib/src/coordinator/models/coordinator_events.dart (1 hunks)
  • packages/stream_video/lib/src/coordinator/open_api/coordinator_ws.dart (1 hunks)
  • packages/stream_video/lib/src/core/client_state.dart (6 hunks)
  • packages/stream_video/lib/src/stream_video.dart (1 hunks)
🧰 Additional context used
🪛 LanguageTool
packages/stream_video/CHANGELOG.md

[style] ~11-~11: Consider using a different verb for a more formal wording.
Context: ...l now be correctly set upon unmuting. * Fixed an issue where coordinator events were ...

(FIX_RESOLVE)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: stream_video_flutter
  • GitHub Check: stream_video_noise_cancellation
  • GitHub Check: stream_video
  • GitHub Check: stream_video_push_notification
  • GitHub Check: analyze_legacy_version
  • GitHub Check: build
  • GitHub Check: analyze
🔇 Additional comments (9)
packages/stream_video/lib/src/call/call.dart (1)

1946-1949: LGTM! Correct implementation of watched call tracking.

The addition of _streamVideo.state.setWatchedCall(this) when watch is true is well-placed and implements the core functionality needed for re-watching calls after coordinator reconnection. The placement after _observeEvents() follows a logical sequence: first set up event observation, then register the call as watched.

packages/stream_video/lib/src/coordinator/models/coordinator_events.dart (1)

55-67: LGTM! Well-structured event class.

The CoordinatorReconnectedEvent follows the established patterns in the codebase with proper equality comparison through the props getter and consistent optional field types. The implementation aligns well with similar events like CoordinatorDisconnectedEvent.

packages/stream_video/lib/src/coordinator/open_api/coordinator_ws.dart (1)

51-62: LGTM! Proper reconnection event handling.

The implementation correctly identifies the reconnection scenario by checking the state transition from reconnecting to connected and emits the appropriate CoordinatorReconnectedEvent with the current userId and connectionId. This follows the existing pattern for event emission in the WebSocket class.

packages/stream_video/lib/src/stream_video.dart (1)

477-500: LGTM! Effective reconnection handling for watched calls.

The implementation correctly addresses the core issue by re-querying watched calls after reconnection. The logic is sound:

  • Checks if there are watched calls to re-subscribe to
  • Uses the watch: true flag to maintain subscription state
  • Filters by call CIDs to target only previously watched calls
  • Includes proper error handling with logging
  • Uses unawaited appropriately for fire-and-forget operation

This ensures call watching state is maintained consistently after coordinator reconnection.

packages/stream_video/lib/src/core/client_state.dart (5)

25-26: LGTM! Clean interface extension.

The new watchedCalls state emitter and setWatchedCall method are properly added to the interface, following the established patterns in the codebase.

Also applies to: 46-47


59-59: LGTM! Proper mutable state implementation.

The MutableClientState correctly implements the new watchedCalls state emitter with proper initialization to an empty list.

Also applies to: 74-75


124-127: LGTM! Logical integration with active call management.

Adding the call to watched calls when setting it as active ensures consistency - active calls should naturally be watched for updates.


141-145: LGTM! Consistent cleanup on call removal.

Removing calls from both active and watched lists maintains state consistency when calls are removed.


147-154: LGTM! Proper duplicate prevention.

The setWatchedCall implementation correctly prevents duplicate entries by checking if a call with the same CID already exists in the watched calls list.

Copy link

codecov bot commented Jul 17, 2025

Codecov Report

Attention: Patch coverage is 21.21212% with 26 lines in your changes missing coverage. Please review.

Project coverage is 4.41%. Comparing base (c9a01cf) to head (b3fb238).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/stream_video/lib/src/stream_video.dart 0.00% 15 Missing ⚠️
...o/lib/src/coordinator/open_api/coordinator_ws.dart 0.00% 7 Missing ⚠️
...lib/src/coordinator/models/coordinator_events.dart 0.00% 3 Missing ⚠️
packages/stream_video/lib/src/call/call.dart 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##            main   #1029      +/-   ##
========================================
+ Coverage   4.40%   4.41%   +0.01%     
========================================
  Files        574     574              
  Lines      38593   38626      +33     
========================================
+ Hits        1700    1707       +7     
- Misses     36893   36919      +26     

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/stream_video/CHANGELOG.md (1)

11-11: Refine wording for clarity & formality

“were not listened to” reads awkwardly; “were not handled” (or “processed”) is clearer and matches the surrounding bullet style.

-* Fixed an issue where coordinator events were not listened to after a fast reconnect in a Call.
+* Fixed an issue where coordinator events were not handled after a fast reconnect in a Call.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between be0930e and b3fb238.

📒 Files selected for processing (2)
  • packages/stream_video/CHANGELOG.md (1 hunks)
  • packages/stream_video/lib/src/call/call.dart (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/stream_video/lib/src/call/call.dart
🧰 Additional context used
🪛 LanguageTool
packages/stream_video/CHANGELOG.md

[style] ~11-~11: Consider using a different verb for a more formal wording.
Context: ...l now be correctly set upon unmuting. * Fixed an issue where coordinator events were ...

(FIX_RESOLVE)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: stream_video_noise_cancellation
  • GitHub Check: stream_video_push_notification
  • GitHub Check: stream_video_flutter
  • GitHub Check: stream_video
  • GitHub Check: analyze
  • GitHub Check: build
  • GitHub Check: analyze_legacy_version

@Brazol Brazol merged commit e709178 into main Jul 17, 2025
15 checks passed
@Brazol Brazol deleted the fix/rewatch-calls-after-reconnect branch July 17, 2025 15:05
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