feat: presence sync engine integrations#40557
Conversation
|
Looks like this PR is ready to merge! 🎉 |
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThe PR moves busy presence management to the Presence engine: calendar event starts set active BUSY presence with localized text and expiry; scheduler schedules only at the next future event start. Media-call and video-conference services set/clear BUSY presence on lifecycle events. Presence engine and tests updated for disconnected/service-user semantics and equal-priority claim handling. ChangesPresence-driven busy status refactoring
Sequence DiagramssequenceDiagram
participant Scheduler as Status Scheduler
participant CalendarService
participant Presence
Scheduler->>CalendarService: processStatusChangesAtTime
CalendarService->>Presence: setActiveState(event start, localized "in a meeting", statusExpiresAt=endTime)
CalendarService->>Presence: endActiveState(uid) on delete if no overlapping busy
sequenceDiagram
participant CallDirector
participant MediaCallService
participant Presence
CallDirector->>MediaCallService: callActivated(callId, uids)
MediaCallService->>Presence: setActiveState(BUSY, "On a call", per-user language)
CallDirector->>MediaCallService: callEnded(callId, uids)
MediaCallService->>Presence: endActiveState(uid)
sequenceDiagram
participant VideoConfService
participant Presence
VideoConfService->>Presence: setActiveState(user join, language -> "In a meeting")
VideoConfService->>Presence: endActiveState(call end for all users)
🎯 4 (Complex) | ⏱️ ~45 minutes Suggested reviewers:
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (2)
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 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## feat/presence-expiration-ui #40557 +/- ##
===============================================================
- Coverage 70.12% 70.09% -0.04%
===============================================================
Files 3366 3362 -4
Lines 130001 129959 -42
Branches 22490 22469 -21
===============================================================
- Hits 91165 91090 -75
- Misses 35511 35554 +43
+ Partials 3325 3315 -10
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
807228e to
a62ad69
Compare
cbd523c to
ef46ca9
Compare
a62ad69 to
9ad1e60
Compare
ef46ca9 to
64b2bb2
Compare
9ad1e60 to
c283812
Compare
05b4e89 to
6e8cf4a
Compare
75684ed to
d29edd2
Compare
6e8cf4a to
5c1a902
Compare
e88cee9 to
c6ebe7e
Compare
9c87407 to
7c0d0fd
Compare
5c1a902 to
2111dc5
Compare
7c0d0fd to
e83964f
Compare
2111dc5 to
61e199f
Compare
369da18 to
b1043f4
Compare
61e199f to
f24e992
Compare
718e76a to
3b25380
Compare
3b25380 to
99020c3
Compare
2609433 to
1618513
Compare
ab67b49 to
e09249b
Compare
e09249b to
f06aa11
Compare
f06aa11 to
d320d36
Compare
338942b to
d320d36
Compare
There was a problem hiding this comment.
2 issues found and verified against the latest diff
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/meteor/server/services/media-call/service.ts">
<violation number="1" location="apps/meteor/server/services/media-call/service.ts:38">
P1: Presence updates for `callActivated` and `callEnded` can race, leaving users stuck as busy after quick call end. Serialize per-call presence transitions (or make activation/end idempotent with ordering guarantees) before writing claims.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
bd244e1
into
feat/presence-expiration-ui
Proposed changes
Integrates the presence sync engine into calendar, voice call, and video conference services, replacing direct DB status updates with the unified
Presence.setActiveState()/Presence.endActiveState()API.How the integration works
Each source claims presence through the engine and tags its claim with a
statusId, so it can later release exactly that claim:MediaCallServicelistens tocallActivated/callEndedfromCallDirector(newMediaCallServerEvents) and sets/clears a busy claim keyed bycallId. Text "On a call",statusSource: 'internal'(highest priority).statusSource: 'internal'.'calendar',statusSource: 'external'. The engine expires it viastatusExpiresAt, so the scheduler only schedules event starts. This replaces the oldapplyStatusChangeflow andpreviousStatustracking (~550 lines + tests removed) and dropspreviousStatusfromICalendarEvent.Why
statusIdA user can hold two equal-priority
internalclaims at once (e.g. a voice call and a video conference). The engine stashes the displaced claim so it can be restored — but with only astatusSourceto go on,endActiveStatecouldn't tell which claim was ending, so ending the older one first restored a stale claim over the still-active newer one.Each claim now carries a
statusId, soendActiveState(uid, statusId)removes the exact claim and restores correctly in any end order. It also makes a declined/never-active call a no-op (its id was never claimed), so it can't clobber a manual or calendar status.statusIdis internal-only and excluded from client projections.The Apps-Engine API also exposes
statusId: an app can pass it insetActiveState's state and toendActiveState(userId, statusId?), so an app scopes and clears its own claim the same way.Issue(s)
Steps to test or reproduce
See the use case matrix for the full set of scenarios.
Further comments
Depends on #40469 (frontend) and #40274 (backend engine).
Final PR in the stack: all presence writers (manual, calendar, voice, video) now go through the unified engine, and direct DB writes for status are fully eliminated.
Summary by CodeRabbit
New Features
Bug Fixes
Tests