Skip to content

Conversation

@pierre-lehnen-rc
Copy link
Contributor

@pierre-lehnen-rc pierre-lehnen-rc commented Sep 30, 2025

Proposed changes (including videos or screenshots)

If a client misses a call initialization signal but receives some other signal about it, then that call is being added to the internal list of calls but never initialized and also never cleared. It doesn't trigger any events so it doesn't cause any problems in the UI, but if a different call happens, then this second call will trigger the session events and once it is over, it'll roll back to the first call even though it is not initialized.
This PR makes two fixes:

  1. It ensures that a call is flagged as ended when its over, even if it was not initialized.
  2. It ensures that calls that have not been initialized will always be treated as hidden, so they do not show up on the UI.

Issue(s)

VAI-149

Steps to test or reproduce

  1. Start a call from user1 to user2
  2. As user2, refresh the browser page
  3. After the refresh, the call will no longer appear for user2 (separate bug, fixed on another PR)
  4. As user1, stop this first call and start a new one
  5. The second call will show up for user2 as usual.
  6. As user1, stop the second call.
  7. The first call that was already over will now show up for user2, with no contact information or anything on the widget.

Further comments

Summary by CodeRabbit

  • Bug Fixes
    • Prevents processing of already-ended calls to avoid unexpected behavior after hangup.
    • Handles early hangup signals immediately during setup, reducing lingering or stuck ringing states.
    • Improves call visibility: calls remain hidden until fully initialized or when ignored.
    • Enhances handling of signals before remote data is available, reducing race conditions and stuck states.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Sep 30, 2025

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Sep 30, 2025

⚠️ No Changeset found

Latest commit: 69170bf

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 30, 2025

Walkthrough

Expanded hidden-state criteria, added early exit when a call is already over, refined pre-remote signal handling to immediately hang up on hangup notifications, and added guards in initialization and signal processing to prevent work when the call is over or not ready.

Changes

Cohort / File(s) Summary
Call lifecycle and signaling guards
packages/media-signaling/src/lib/Call.ts
- Hidden now true when uninitialized, ignored, or contractState is 'ignored'
- Early return in remote initialization if call is already over
- Pre-remote signal handling: immediate hangup on hangup notifications; otherwise queue
- Guards to skip processing when call is over or not yet ready, while still filling basic info

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User/Remote
  participant C as Call
  participant R as RemoteData
  participant Q as SignalQueue

  Note over C: Initialization
  U->>C: initializeRemoteCall()
  alt Call is over
    C-->>U: exit (no further init)
  else Not over
    C->>C: set hidden if uninitialized/ignored
    C->>R: ensure basic info
  end

  Note over C: Signal processing
  U->>C: processSignal(signal)
  alt Call is over or not ready
    C-->>U: skip processing (fill basics only)
  else Remote not present
    alt signal is hangup
      C->>C: immediate hangup()
    else other signal
      C->>Q: enqueue(signal)
    end
  else Remote present
    C->>C: normal processing path
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I twitch my ears at signals’ flow,
When calls are over, I let them go.
A hangup hops—no queue today,
I boop “goodbye” and bound away.
Hidden burrows guard the start,
Until remote facts fill the chart.
Thump-thump—clean paths, a calmer heart.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly identifies the core issue addressed—a regression causing invalid call states when the initialization signal is missed—and directly aligns with the PR’s main objective of fixing missed initialization handling, making it clear and specific for anyone scanning the history.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/media-calls-visible-uninitialized

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 and usage tips.

@pierre-lehnen-rc pierre-lehnen-rc added this to the 7.11.0 milestone Sep 30, 2025
@pierre-lehnen-rc pierre-lehnen-rc marked this pull request as ready for review September 30, 2025 16:03
Copy link
Contributor

@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/media-signaling/src/lib/Call.ts (1)

435-439: LGTM! Immediate hangup on pre-initialization hangup notifications is correct.

This change appropriately handles the edge case where a hangup notification arrives before call initialization data. By immediately ending the call instead of queuing the signal, it prevents the call from remaining in limbo waiting for data that's no longer needed.

Optional: Consider clearing this.earlySignals when immediately hanging up, since queued signals will never be processed:

 if (signal.type === 'notification' && signal.notification === 'hangup') {
   this.changeState('hangup');
+  this.earlySignals.clear();
   return;
 }

This isn't critical since processSignal already guards against processing when isOver() is true (line 419), but it would make the intent clearer and free memory sooner.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3f22549 and 69170bf.

📒 Files selected for processing (1)
  • packages/media-signaling/src/lib/Call.ts (3 hunks)
⏰ 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). (2)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: Builds matrix rust bindings against alpine
🔇 Additional comments (2)
packages/media-signaling/src/lib/Call.ts (2)

92-100: LGTM! This correctly prevents uninitialized calls from appearing in the UI.

The expanded hidden state logic appropriately addresses the root cause described in the PR: calls that miss initialization signals will now remain hidden instead of appearing with incomplete data. The added documentation clearly explains the three conditions for a hidden call.


277-280: LGTM! Appropriate guard against processing already-ended calls.

This early return correctly prevents unnecessary initialization work (WebRTC setup, acknowledgment, timeouts) for calls that are already over, while still populating basic call metadata. This aligns with the fix objective of ensuring calls are properly marked as ended even without initialization.

@codecov
Copy link

codecov bot commented Sep 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.39%. Comparing base (bf35a0b) to head (69170bf).
⚠️ Report is 12 commits behind head on release-7.11.0.

Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff               @@
##           release-7.11.0   #37101   +/-   ##
===============================================
  Coverage           67.39%   67.39%           
===============================================
  Files                3328     3328           
  Lines              113341   113353   +12     
  Branches            20564    20585   +21     
===============================================
+ Hits                76387    76397   +10     
- Misses              34348    34351    +3     
+ Partials             2606     2605    -1     
Flag Coverage Δ
e2e 57.27% <ø> (-0.02%) ⬇️
unit 71.15% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ggazzo ggazzo merged commit 148e0c5 into release-7.11.0 Oct 6, 2025
53 checks passed
@ggazzo ggazzo deleted the fix/media-calls-visible-uninitialized branch October 6, 2025 14:15
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.

3 participants