feat(presence): show In a call, In a meeting and Presenting like Teams
| Before | After | |---|---| | Busy for everyone in a call | "In a call", "In a meeting", "Presenting", "Out of office" from Teams activity on profile cards and 1:1 chat headers | | Sounds suppressed only by server presence | Also no notification sounds while a native call in Rusty Teams is connecting or connected | Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -2,7 +2,7 @@
2
2
3
3
Feature parity with the Microsoft Teams desktop client.
4
4
5
**Parity: 89 %** (76 done, 4 partial, 8 missing of 88). Partial counts half.
5
**Parity: 90 %** (77 done, 5 partial, 6 missing of 88). Partial counts half.
6
6
7
7
## By area
8
8
@@ -18,7 +18,7 @@ Feature parity with the Microsoft Teams desktop client.
18
18
| [Search and navigation](#search-and-navigation) | 80 % | 4 | 0 | 1 |
19
19
| [Presence and people](#presence-and-people) | 100 % | 4 | 0 | 0 |
20
20
| [Look and settings](#look-and-settings) | 50 % | 2 | 0 | 2 |
21
| [Calls and meetings](#calls-and-meetings) | 42 % | 1 | 3 | 2 |
21
| [Calls and meetings](#calls-and-meetings) | 67 % | 2 | 4 | 0 |
22
22
23
23
## Next
24
24
@@ -168,7 +168,7 @@ Feature parity with the Microsoft Teams desktop client.
168
168
| 1:1 and group calls | Partial | Phone button, Calling and Ringing tiles, end notices, direct to mixer renegotiation. Not yet tried with a second person |
169
169
| Join a meeting from a chat | Partial | Join button from the live meeting state, joins muted, roster tiles, lobby, Leave and End meeting. Audio only. Verified with a meeting of one; not yet with other participants |
170
170
| Video and screen sharing | Partial | Send and receive over libwebrtc H264, source requests through `applyChannelParameters`, stage, strip, self view, share banner. Sent frames acknowledged by the mixer; receive only checked by a local loopback, not with a second person. Incoming calls stay audio-only |
171
| In a call shown in presence | Missing | |
171
| In a call shown in presence | Done | "In a call", "In a meeting", "Presenting" from Teams activity on profile cards and chat headers; no notification sounds during a native call |
172
172
173
173
## Agents
174
174
@@ -2,7 +2,7 @@2
2
3
Feature parity with the Microsoft Teams desktop client.3
Feature parity with the Microsoft Teams desktop client.4
4
5
**Parity: 89 %** (76 done, 4 partial, 8 missing of 88). Partial counts half.5
**Parity: 90 %** (77 done, 5 partial, 6 missing of 88). Partial counts half.6
6
7
## By area7
## By area8
8
@@ -18,7 +18,7 @@ Feature parity with the Microsoft Teams desktop client.18
| [Search and navigation](#search-and-navigation) | 80 % | 4 | 0 | 1 |18
| [Search and navigation](#search-and-navigation) | 80 % | 4 | 0 | 1 |19
| [Presence and people](#presence-and-people) | 100 % | 4 | 0 | 0 |19
| [Presence and people](#presence-and-people) | 100 % | 4 | 0 | 0 |20
| [Look and settings](#look-and-settings) | 50 % | 2 | 0 | 2 |20
| [Look and settings](#look-and-settings) | 50 % | 2 | 0 | 2 |21
| [Calls and meetings](#calls-and-meetings) | 42 % | 1 | 3 | 2 |21
| [Calls and meetings](#calls-and-meetings) | 67 % | 2 | 4 | 0 |22
22
23
## Next23
## Next24
24
@@ -168,7 +168,7 @@ Feature parity with the Microsoft Teams desktop client.168
| 1:1 and group calls | Partial | Phone button, Calling and Ringing tiles, end notices, direct to mixer renegotiation. Not yet tried with a second person |168
| 1:1 and group calls | Partial | Phone button, Calling and Ringing tiles, end notices, direct to mixer renegotiation. Not yet tried with a second person |169
| Join a meeting from a chat | Partial | Join button from the live meeting state, joins muted, roster tiles, lobby, Leave and End meeting. Audio only. Verified with a meeting of one; not yet with other participants |169
| Join a meeting from a chat | Partial | Join button from the live meeting state, joins muted, roster tiles, lobby, Leave and End meeting. Audio only. Verified with a meeting of one; not yet with other participants |170
| Video and screen sharing | Partial | Send and receive over libwebrtc H264, source requests through `applyChannelParameters`, stage, strip, self view, share banner. Sent frames acknowledged by the mixer; receive only checked by a local loopback, not with a second person. Incoming calls stay audio-only |170
| Video and screen sharing | Partial | Send and receive over libwebrtc H264, source requests through `applyChannelParameters`, stage, strip, self view, share banner. Sent frames acknowledged by the mixer; receive only checked by a local loopback, not with a second person. Incoming calls stay audio-only |171
| In a call shown in presence | Missing | |171
| In a call shown in presence | Done | "In a call", "In a meeting", "Presenting" from Teams activity on profile cards and chat headers; no notification sounds during a native call |172
172
173
## Agents173
## Agents174
174
@@ -461,8 +461,13 @@ impl AppState {
461
461
.requested_presence_ids()
462
462
.into_iter()
463
463
.filter(|user_id| {
464
data::presence_kind(&engine, user_id)
465
.is_some_and(|kind| self.directory.set_presence(user_id, kind))
464
let Some(kind) = data::presence_kind(&engine, user_id) else {
465
return false;
466
};
467
let activity_changed = self
468
.directory
469
.set_activity(user_id, data::presence_activity(&engine, user_id));
470
self.directory.set_presence(user_id, kind) || activity_changed
466
471
})
467
472
.collect()
468
473
}
@@ -461,8 +461,13 @@ impl AppState {461
.requested_presence_ids()461
.requested_presence_ids()462
.into_iter()462
.into_iter()463
.filter(|user_id| {463
.filter(|user_id| {464
data::presence_kind(&engine, user_id)464
let Some(kind) = data::presence_kind(&engine, user_id) else {465
.is_some_and(|kind| self.directory.set_presence(user_id, kind))465
return false;466
};467
let activity_changed = self468
.directory469
.set_activity(user_id, data::presence_activity(&engine, user_id));470
self.directory.set_presence(user_id, kind) || activity_changed466
})471
})467
.collect()472
.collect()468
}473
}@@ -374,6 +374,13 @@ impl CallModel {
374
374
}
375
375
}
376
376
377
pub fn is_active(&self) -> bool {
378
matches!(
379
self.state,
380
CallState::Connecting | CallState::Connected { .. } | CallState::Reconnecting { .. }
381
)
382
}
383
377
384
pub fn is_connecting(&self) -> bool {
378
385
matches!(self.state, CallState::Connecting)
379
386
}
@@ -374,6 +374,13 @@ impl CallModel {374
}374
}375
}375
}376
376
377
pub fn is_active(&self) -> bool {378
matches!(379
self.state,380
CallState::Connecting | CallState::Connected { .. } | CallState::Reconnecting { .. }381
)382
}383
377
pub fn is_connecting(&self) -> bool {384
pub fn is_connecting(&self) -> bool {378
matches!(self.state, CallState::Connecting)385
matches!(self.state, CallState::Connecting)379
}386
}@@ -6,7 +6,7 @@ use std::time::{Duration, Instant};
6
6
use gpui_kit::{Image, ImageFormat};
7
7
use store::{ChatRecord, Store};
8
8
9
use teams_core::{Availability, ChatSectionSettings};
9
use teams_core::{Activity, Availability, ChatSectionSettings};
10
10
use tokio::sync::oneshot;
11
11
12
12
use crate::backend::Engine;
@@ -127,6 +127,7 @@ pub struct Directory {
127
127
pub unread_counts: HashMap<String, u32>,
128
128
pub(crate) avatars: HashMap<String, AvatarState>,
129
129
pub(crate) presence: HashMap<String, (PresenceKind, Instant)>,
130
pub(crate) activity: HashMap<String, Activity>,
130
131
pub(crate) presence_cached: HashMap<String, PresenceKind>,
131
132
pub(crate) presence_requested: HashMap<String, Instant>,
132
133
pub(crate) presence_pending: HashSet<String>,
@@ -202,6 +203,20 @@ impl Directory {
202
203
}
203
204
}
204
205
206
pub fn set_activity(&mut self, user_id: &str, activity: Option<Activity>) -> bool {
207
match activity {
208
Some(activity) => self.activity.insert(user_id.to_owned(), activity) != Some(activity),
209
None => self.activity.remove(user_id).is_some(),
210
}
211
}
212
213
pub fn status_label(&self, user_id: &str, presence: Presence) -> &'static str {
214
match self.activity.get(user_id) {
215
Some(activity) if matches!(presence, Presence::Live(_)) => activity_label(*activity),
216
_ => presence.kind().label(),
217
}
218
}
219
205
220
pub fn load_cached_presence(&mut self, store: &Store) {
206
221
self.presence_cached = store
207
222
.presences()
@@ -437,6 +452,21 @@ pub fn presence_kind_of(availability: Availability) -> PresenceKind {
437
452
}
438
453
}
439
454
455
pub fn activity_label(activity: Activity) -> &'static str {
456
match activity {
457
Activity::InACall => "In a call",
458
Activity::InAConferenceCall | Activity::InAMeeting => "In a meeting",
459
Activity::Presenting => "Presenting",
460
Activity::OutOfOffice => "Out of office",
461
}
462
}
463
464
pub fn presence_activity(engine: &Engine, user_id: &str) -> Option<Activity> {
465
engine
466
.presence(user_id)
467
.and_then(|presence| presence.activity)
468
}
469
440
470
pub fn presence_kind(engine: &Engine, user_id: &str) -> Option<PresenceKind> {
441
471
engine
442
472
.presence(user_id)
@@ -446,7 +476,7 @@ pub fn presence_kind(engine: &Engine, user_id: &str) -> Option<PresenceKind> {
446
476
pub fn in_call(engine: &Engine, user_id: &str) -> bool {
447
477
engine
448
478
.presence(user_id)
449
.is_some_and(|presence| presence.in_call)
479
.is_some_and(|presence| presence.in_call())
450
480
}
451
481
452
482
pub type Done = oneshot::Receiver<Result<(), String>>;
@@ -504,6 +534,30 @@ pub fn remove_from_folder(engine: &Arc<Engine>, conversation_id: &str, folder_id
504
534
mod tests {
505
535
use super::*;
506
536
537
#[test]
538
fn activity_wording_replaces_availability_only_for_live_presence() {
539
let cases = [
540
(Activity::InACall, "In a call"),
541
(Activity::InAConferenceCall, "In a meeting"),
542
(Activity::InAMeeting, "In a meeting"),
543
(Activity::Presenting, "Presenting"),
544
(Activity::OutOfOffice, "Out of office"),
545
];
546
for (activity, label) in cases {
547
let mut directory = Directory::default();
548
directory.set_activity("ada", Some(activity));
549
let live = Presence::Live(PresenceKind::Busy);
550
assert_eq!(directory.status_label("ada", live), label);
551
assert_eq!(
552
directory.status_label("ada", Presence::Cached(PresenceKind::Busy)),
553
"Busy"
554
);
555
assert_eq!(directory.status_label("bob", live), "Busy");
556
assert!(directory.set_activity("ada", None));
557
assert_eq!(directory.status_label("ada", live), "Busy");
558
}
559
}
560
507
561
fn folder(id: &str, kind: FolderKind, ids: &[&str]) -> FolderInfo {
508
562
FolderInfo {
509
563
id: id.into(),
@@ -6,7 +6,7 @@ use std::time::{Duration, Instant};6
use gpui_kit::{Image, ImageFormat};6
use gpui_kit::{Image, ImageFormat};7
use store::{ChatRecord, Store};7
use store::{ChatRecord, Store};8
8
9
use teams_core::{Availability, ChatSectionSettings};9
use teams_core::{Activity, Availability, ChatSectionSettings};10
use tokio::sync::oneshot;10
use tokio::sync::oneshot;11
11
12
use crate::backend::Engine;12
use crate::backend::Engine;@@ -127,6 +127,7 @@ pub struct Directory {127
pub unread_counts: HashMap<String, u32>,127
pub unread_counts: HashMap<String, u32>,128
pub(crate) avatars: HashMap<String, AvatarState>,128
pub(crate) avatars: HashMap<String, AvatarState>,129
pub(crate) presence: HashMap<String, (PresenceKind, Instant)>,129
pub(crate) presence: HashMap<String, (PresenceKind, Instant)>,130
pub(crate) activity: HashMap<String, Activity>,130
pub(crate) presence_cached: HashMap<String, PresenceKind>,131
pub(crate) presence_cached: HashMap<String, PresenceKind>,131
pub(crate) presence_requested: HashMap<String, Instant>,132
pub(crate) presence_requested: HashMap<String, Instant>,132
pub(crate) presence_pending: HashSet<String>,133
pub(crate) presence_pending: HashSet<String>,@@ -202,6 +203,20 @@ impl Directory {202
}203
}203
}204
}204
205
206
pub fn set_activity(&mut self, user_id: &str, activity: Option<Activity>) -> bool {207
match activity {208
Some(activity) => self.activity.insert(user_id.to_owned(), activity) != Some(activity),209
None => self.activity.remove(user_id).is_some(),210
}211
}212
213
pub fn status_label(&self, user_id: &str, presence: Presence) -> &'static str {214
match self.activity.get(user_id) {215
Some(activity) if matches!(presence, Presence::Live(_)) => activity_label(*activity),216
_ => presence.kind().label(),217
}218
}219
205
pub fn load_cached_presence(&mut self, store: &Store) {220
pub fn load_cached_presence(&mut self, store: &Store) {206
self.presence_cached = store221
self.presence_cached = store207
.presences()222
.presences()@@ -437,6 +452,21 @@ pub fn presence_kind_of(availability: Availability) -> PresenceKind {437
}452
}438
}453
}439
454
455
pub fn activity_label(activity: Activity) -> &'static str {456
match activity {457
Activity::InACall => "In a call",458
Activity::InAConferenceCall | Activity::InAMeeting => "In a meeting",459
Activity::Presenting => "Presenting",460
Activity::OutOfOffice => "Out of office",461
}462
}463
464
pub fn presence_activity(engine: &Engine, user_id: &str) -> Option<Activity> {465
engine466
.presence(user_id)467
.and_then(|presence| presence.activity)468
}469
440
pub fn presence_kind(engine: &Engine, user_id: &str) -> Option<PresenceKind> {470
pub fn presence_kind(engine: &Engine, user_id: &str) -> Option<PresenceKind> {441
engine471
engine442
.presence(user_id)472
.presence(user_id)@@ -446,7 +476,7 @@ pub fn presence_kind(engine: &Engine, user_id: &str) -> Option<PresenceKind> {446
pub fn in_call(engine: &Engine, user_id: &str) -> bool {476
pub fn in_call(engine: &Engine, user_id: &str) -> bool {447
engine477
engine448
.presence(user_id)478
.presence(user_id)449
.is_some_and(|presence| presence.in_call)479
.is_some_and(|presence| presence.in_call())450
}480
}451
481
452
pub type Done = oneshot::Receiver<Result<(), String>>;482
pub type Done = oneshot::Receiver<Result<(), String>>;@@ -504,6 +534,30 @@ pub fn remove_from_folder(engine: &Arc<Engine>, conversation_id: &str, folder_id504
mod tests {534
mod tests {505
use super::*;535
use super::*;506
536
537
#[test]538
fn activity_wording_replaces_availability_only_for_live_presence() {539
let cases = [540
(Activity::InACall, "In a call"),541
(Activity::InAConferenceCall, "In a meeting"),542
(Activity::InAMeeting, "In a meeting"),543
(Activity::Presenting, "Presenting"),544
(Activity::OutOfOffice, "Out of office"),545
];546
for (activity, label) in cases {547
let mut directory = Directory::default();548
directory.set_activity("ada", Some(activity));549
let live = Presence::Live(PresenceKind::Busy);550
assert_eq!(directory.status_label("ada", live), label);551
assert_eq!(552
directory.status_label("ada", Presence::Cached(PresenceKind::Busy)),553
"Busy"554
);555
assert_eq!(directory.status_label("bob", live), "Busy");556
assert!(directory.set_activity("ada", None));557
assert_eq!(directory.status_label("ada", live), "Busy");558
}559
}560
507
fn folder(id: &str, kind: FolderKind, ids: &[&str]) -> FolderInfo {561
fn folder(id: &str, kind: FolderKind, ids: &[&str]) -> FolderInfo {508
FolderInfo {562
FolderInfo {509
id: id.into(),563
id: id.into(),@@ -9,8 +9,8 @@ use store::{
9
9
ChannelTabRecord, ChatRecord, MemberRecord, MessageRecord, Store, TeamLayoutRecord, TeamRecord,
10
10
};
11
11
use teams_core::{
12
CardActionOutcome, ChatApp, ChatSection, Gif, LinkPreview, MentionCandidate, PersonCandidate,
13
PersonSource, PinnedMessage, SavedMessage, TaskDialog, TaskDialogKind,
12
Activity, CardActionOutcome, ChatApp, ChatSection, Gif, LinkPreview, MentionCandidate,
13
PersonCandidate, PersonSource, PinnedMessage, SavedMessage, TaskDialog, TaskDialogKind,
14
14
};
15
15
16
16
use crate::activity::{Actor, Entry, Kind};
@@ -768,14 +768,16 @@ pub fn seed_directory(state: &mut AppState) {
768
768
directory.set_avatar(TOBIAS_ID, Some(photo(&TOBIAS)));
769
769
for (user_id, kind) in [
770
770
(MARA_ID, PresenceKind::Available),
771
(JONAS_ID, PresenceKind::DoNotDisturb),
771
(JONAS_ID, PresenceKind::Busy),
772
772
(PRIYA_ID, PresenceKind::Away),
773
773
(TOBIAS_ID, PresenceKind::Offline),
774
(LEA_ID, PresenceKind::DoNotDisturb),
774
(LEA_ID, PresenceKind::Busy),
775
775
(DEMO_USER_ID, PresenceKind::Available),
776
776
] {
777
777
directory.set_presence(user_id, kind);
778
778
}
779
directory.set_activity(JONAS_ID, Some(Activity::InACall));
780
directory.set_activity(LEA_ID, Some(Activity::InAConferenceCall));
779
781
let directory_path = image_directory();
780
782
if std::fs::create_dir_all(&directory_path).is_ok() {
781
783
let path = directory_path.join("staging-dashboard.png");
@@ -9,8 +9,8 @@ use store::{9
ChannelTabRecord, ChatRecord, MemberRecord, MessageRecord, Store, TeamLayoutRecord, TeamRecord,9
ChannelTabRecord, ChatRecord, MemberRecord, MessageRecord, Store, TeamLayoutRecord, TeamRecord,10
};10
};11
use teams_core::{11
use teams_core::{12
CardActionOutcome, ChatApp, ChatSection, Gif, LinkPreview, MentionCandidate, PersonCandidate,12
Activity, CardActionOutcome, ChatApp, ChatSection, Gif, LinkPreview, MentionCandidate,13
PersonSource, PinnedMessage, SavedMessage, TaskDialog, TaskDialogKind,13
PersonCandidate, PersonSource, PinnedMessage, SavedMessage, TaskDialog, TaskDialogKind,14
};14
};15
15
16
use crate::activity::{Actor, Entry, Kind};16
use crate::activity::{Actor, Entry, Kind};@@ -768,14 +768,16 @@ pub fn seed_directory(state: &mut AppState) {768
directory.set_avatar(TOBIAS_ID, Some(photo(&TOBIAS)));768
directory.set_avatar(TOBIAS_ID, Some(photo(&TOBIAS)));769
for (user_id, kind) in [769
for (user_id, kind) in [770
(MARA_ID, PresenceKind::Available),770
(MARA_ID, PresenceKind::Available),771
(JONAS_ID, PresenceKind::DoNotDisturb),771
(JONAS_ID, PresenceKind::Busy),772
(PRIYA_ID, PresenceKind::Away),772
(PRIYA_ID, PresenceKind::Away),773
(TOBIAS_ID, PresenceKind::Offline),773
(TOBIAS_ID, PresenceKind::Offline),774
(LEA_ID, PresenceKind::DoNotDisturb),774
(LEA_ID, PresenceKind::Busy),775
(DEMO_USER_ID, PresenceKind::Available),775
(DEMO_USER_ID, PresenceKind::Available),776
] {776
] {777
directory.set_presence(user_id, kind);777
directory.set_presence(user_id, kind);778
}778
}779
directory.set_activity(JONAS_ID, Some(Activity::InACall));780
directory.set_activity(LEA_ID, Some(Activity::InAConferenceCall));779
let directory_path = image_directory();781
let directory_path = image_directory();780
if std::fs::create_dir_all(&directory_path).is_ok() {782
if std::fs::create_dir_all(&directory_path).is_ok() {781
let path = directory_path.join("staging-dashboard.png");783
let path = directory_path.join("staging-dashboard.png");@@ -10,7 +10,7 @@ use super::incoming::IncomingTracker;
10
10
use super::layout::{self, Slot, ring_height};
11
11
use super::platform::{self, NativeHandle, Tray, TrayCommand, WorkArea};
12
12
use super::rules::{
13
ChatKind, Decision, Environment, Incoming, Preview, Settings, SoundThrottle, decide,
13
ChatKind, Decision, Environment, Incoming, Preview, Settings, SoundThrottle, decide, in_call,
14
14
should_flash,
15
15
};
16
16
use super::settings;
@@ -240,10 +240,11 @@ impl NotificationCenter {
240
240
let own_do_not_disturb = state.directory.me.as_ref().is_some_and(|me| {
241
241
state.directory.presence_of(&me.user_id).kind() == PresenceKind::DoNotDisturb
242
242
});
243
let in_call = match (state.engine.as_ref(), state.directory.me.as_ref()) {
243
let server_in_call = match (state.engine.as_ref(), state.directory.me.as_ref()) {
244
244
(Some(engine), Some(me)) => data::in_call(engine, &me.user_id),
245
245
_ => false,
246
246
};
247
let in_call = in_call(server_in_call, state.call.as_ref().map(|call| &call.model));
247
248
Environment {
248
249
chat_in_foreground: selected && self.main_window_active(cx),
249
250
system_quiet: platform::system_quiet(),
@@ -10,7 +10,7 @@ use super::incoming::IncomingTracker;10
use super::layout::{self, Slot, ring_height};10
use super::layout::{self, Slot, ring_height};11
use super::platform::{self, NativeHandle, Tray, TrayCommand, WorkArea};11
use super::platform::{self, NativeHandle, Tray, TrayCommand, WorkArea};12
use super::rules::{12
use super::rules::{13
ChatKind, Decision, Environment, Incoming, Preview, Settings, SoundThrottle, decide,13
ChatKind, Decision, Environment, Incoming, Preview, Settings, SoundThrottle, decide, in_call,14
should_flash,14
should_flash,15
};15
};16
use super::settings;16
use super::settings;@@ -240,10 +240,11 @@ impl NotificationCenter {240
let own_do_not_disturb = state.directory.me.as_ref().is_some_and(|me| {240
let own_do_not_disturb = state.directory.me.as_ref().is_some_and(|me| {241
state.directory.presence_of(&me.user_id).kind() == PresenceKind::DoNotDisturb241
state.directory.presence_of(&me.user_id).kind() == PresenceKind::DoNotDisturb242
});242
});243
let in_call = match (state.engine.as_ref(), state.directory.me.as_ref()) {243
let server_in_call = match (state.engine.as_ref(), state.directory.me.as_ref()) {244
(Some(engine), Some(me)) => data::in_call(engine, &me.user_id),244
(Some(engine), Some(me)) => data::in_call(engine, &me.user_id),245
_ => false,245
_ => false,246
};246
};247
let in_call = in_call(server_in_call, state.call.as_ref().map(|call| &call.model));247
Environment {248
Environment {248
chat_in_foreground: selected && self.main_window_active(cx),249
chat_in_foreground: selected && self.main_window_active(cx),249
system_quiet: platform::system_quiet(),250
system_quiet: platform::system_quiet(),@@ -4,6 +4,8 @@ use std::time::{Duration, Instant};
4
4
use chrono::{DateTime, Utc};
5
5
use store::{ChannelNotificationLevel, ChannelNotifications};
6
6
7
use crate::call::CallModel;
8
7
9
pub const SOUND_THROTTLE: Duration = Duration::from_secs(10);
8
10
9
11
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
@@ -138,6 +140,10 @@ pub struct Environment {
138
140
pub in_call: bool,
139
141
}
140
142
143
pub fn in_call(server_in_call: bool, native_call: Option<&CallModel>) -> bool {
144
server_in_call || native_call.is_some_and(CallModel::is_active)
145
}
146
141
147
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
142
148
pub struct Decision {
143
149
pub toast: bool,
@@ -217,6 +223,8 @@ pub fn should_flash(settings: &Settings, toast_shown: bool, window_active: bool)
217
223
218
224
#[cfg(test)]
219
225
mod tests {
226
use calling::{CallState, EndReason};
227
220
228
use super::*;
221
229
222
230
fn incoming(kind: ChatKind) -> Incoming {
@@ -288,6 +296,31 @@ mod tests {
288
296
assert_eq!(decide(&settings, &group(), Environment::default()), SILENT);
289
297
}
290
298
299
#[test]
300
fn in_call_follows_server_presence_or_a_live_native_call() {
301
let model = |state| {
302
let mut model = CallModel::incoming("Bea", "8:orgid:b", "Bea");
303
model.state = state;
304
model
305
};
306
let since = std::time::Instant::now();
307
assert!(!in_call(false, None));
308
assert!(in_call(true, None));
309
assert!(in_call(false, Some(&model(CallState::Connecting))));
310
assert!(in_call(false, Some(&model(CallState::Connected { since }))));
311
assert!(in_call(
312
false,
313
Some(&model(CallState::Reconnecting { since }))
314
));
315
assert!(!in_call(false, Some(&model(CallState::Idle))));
316
assert!(!in_call(
317
false,
318
Some(&model(CallState::Ended {
319
reason: EndReason::LocalHangup
320
}))
321
));
322
}
323
291
324
#[test]
292
325
fn call_keeps_toast_but_drops_sound() {
293
326
let environment = Environment {
@@ -4,6 +4,8 @@ use std::time::{Duration, Instant};4
use chrono::{DateTime, Utc};4
use chrono::{DateTime, Utc};5
use store::{ChannelNotificationLevel, ChannelNotifications};5
use store::{ChannelNotificationLevel, ChannelNotifications};6
6
7
use crate::call::CallModel;8
7
pub const SOUND_THROTTLE: Duration = Duration::from_secs(10);9
pub const SOUND_THROTTLE: Duration = Duration::from_secs(10);8
10
9
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]11
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]@@ -138,6 +140,10 @@ pub struct Environment {138
pub in_call: bool,140
pub in_call: bool,139
}141
}140
142
143
pub fn in_call(server_in_call: bool, native_call: Option<&CallModel>) -> bool {144
server_in_call || native_call.is_some_and(CallModel::is_active)145
}146
141
#[derive(Debug, Clone, Copy, PartialEq, Eq)]147
#[derive(Debug, Clone, Copy, PartialEq, Eq)]142
pub struct Decision {148
pub struct Decision {143
pub toast: bool,149
pub toast: bool,@@ -217,6 +223,8 @@ pub fn should_flash(settings: &Settings, toast_shown: bool, window_active: bool)217
223
218
#[cfg(test)]224
#[cfg(test)]219
mod tests {225
mod tests {226
use calling::{CallState, EndReason};227
220
use super::*;228
use super::*;221
229
222
fn incoming(kind: ChatKind) -> Incoming {230
fn incoming(kind: ChatKind) -> Incoming {@@ -288,6 +296,31 @@ mod tests {288
assert_eq!(decide(&settings, &group(), Environment::default()), SILENT);296
assert_eq!(decide(&settings, &group(), Environment::default()), SILENT);289
}297
}290
298
299
#[test]300
fn in_call_follows_server_presence_or_a_live_native_call() {301
let model = |state| {302
let mut model = CallModel::incoming("Bea", "8:orgid:b", "Bea");303
model.state = state;304
model305
};306
let since = std::time::Instant::now();307
assert!(!in_call(false, None));308
assert!(in_call(true, None));309
assert!(in_call(false, Some(&model(CallState::Connecting))));310
assert!(in_call(false, Some(&model(CallState::Connected { since }))));311
assert!(in_call(312
false,313
Some(&model(CallState::Reconnecting { since }))314
));315
assert!(!in_call(false, Some(&model(CallState::Idle))));316
assert!(!in_call(317
false,318
Some(&model(CallState::Ended {319
reason: EndReason::LocalHangup320
}))321
));322
}323
291
#[test]324
#[test]292
fn call_keeps_toast_but_drops_sound() {325
fn call_keeps_toast_but_drops_sound() {293
let environment = Environment {326
let environment = Environment {@@ -2874,9 +2874,12 @@ impl ConversationView {
2874
2874
.child(avatar)
2875
2875
.into_any_element(),
2876
2876
);
2877
subline = presence
2878
.map(|presence| presence.kind().label().to_owned())
2879
.unwrap_or_default();
2877
subline = match (user_id, presence) {
2878
(Some(id), Some(presence)) => {
2879
directory.status_label(id, presence).to_owned()
2880
}
2881
_ => String::new(),
2882
};
2880
2883
} else {
2881
2884
let pair = AvatarSpec::Pair(face(faces[0].clone()), face(faces[1].clone()));
2882
2885
lead = Some(spec_avatar(directory, &pair, 36., theme::background()));
@@ -2874,9 +2874,12 @@ impl ConversationView {2874
.child(avatar)2874
.child(avatar)2875
.into_any_element(),2875
.into_any_element(),2876
);2876
);2877
subline = presence2877
subline = match (user_id, presence) {2878
.map(|presence| presence.kind().label().to_owned())2878
(Some(id), Some(presence)) => {2879
.unwrap_or_default();2879
directory.status_label(id, presence).to_owned()2880
}2881
_ => String::new(),2882
};2880
} else {2883
} else {2881
let pair = AvatarSpec::Pair(face(faces[0].clone()), face(faces[1].clone()));2884
let pair = AvatarSpec::Pair(face(faces[0].clone()), face(faces[1].clone()));2882
lead = Some(spec_avatar(directory, &pair, 36., theme::background()));2885
lead = Some(spec_avatar(directory, &pair, 36., theme::background()));@@ -171,7 +171,7 @@ impl ProfileCard {
171
171
PHOTO_SIZE,
172
172
theme::surface_raised(),
173
173
);
174
let availability = presence.kind().label();
174
let availability = directory.status_label(&self.user_id, presence);
175
175
let local_time = profile.and_then(|profile| local_time_label(profile, Utc::now()));
176
176
let subline = status_line(availability, local_time.as_deref());
177
177
let details = v_flex()
@@ -171,7 +171,7 @@ impl ProfileCard {171
PHOTO_SIZE,171
PHOTO_SIZE,172
theme::surface_raised(),172
theme::surface_raised(),173
);173
);174
let availability = presence.kind().label();174
let availability = directory.status_label(&self.user_id, presence);175
let local_time = profile.and_then(|profile| local_time_label(profile, Utc::now()));175
let local_time = profile.and_then(|profile| local_time_label(profile, Utc::now()));176
let subline = status_line(availability, local_time.as_deref());176
let subline = status_line(availability, local_time.as_deref());177
let details = v_flex()177
let details = v_flex()@@ -103,7 +103,7 @@ pub use message_link::{
103
103
ChannelLinkInput, channel_message_link, channel_tab_link, chat_message_link,
104
104
};
105
105
pub use people::{MentionCandidate, PersonCandidate, PersonSource};
106
pub use presence::{Availability, Presence};
106
pub use presence::{Activity, Availability, Presence};
107
107
pub use preview::preview_text;
108
108
pub use profile::{OrgPerson, PersonProfile};
109
109
pub use receipts::{ReceiptReader, ReceiptState};
@@ -103,7 +103,7 @@ pub use message_link::{103
ChannelLinkInput, channel_message_link, channel_tab_link, chat_message_link,103
ChannelLinkInput, channel_message_link, channel_tab_link, chat_message_link,104
};104
};105
pub use people::{MentionCandidate, PersonCandidate, PersonSource};105
pub use people::{MentionCandidate, PersonCandidate, PersonSource};106
pub use presence::{Availability, Presence};106
pub use presence::{Activity, Availability, Presence};107
pub use preview::preview_text;107
pub use preview::preview_text;108
pub use profile::{OrgPerson, PersonProfile};108
pub use profile::{OrgPerson, PersonProfile};109
pub use receipts::{ReceiptReader, ReceiptState};109
pub use receipts::{ReceiptReader, ReceiptState};@@ -35,14 +35,42 @@ impl Availability {
35
35
}
36
36
}
37
37
38
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
39
pub enum Activity {
40
InACall,
41
InAConferenceCall,
42
InAMeeting,
43
Presenting,
44
OutOfOffice,
45
}
46
47
impl Activity {
48
pub fn from_service(name: &str) -> Option<Self> {
49
match name {
50
"InACall" => Some(Activity::InACall),
51
"InAConferenceCall" => Some(Activity::InAConferenceCall),
52
"InAMeeting" => Some(Activity::InAMeeting),
53
"Presenting" => Some(Activity::Presenting),
54
"OutOfOffice" => Some(Activity::OutOfOffice),
55
_ => None,
56
}
57
}
58
59
pub fn is_call(self) -> bool {
60
matches!(self, Activity::InACall | Activity::InAConferenceCall)
61
}
62
}
63
38
64
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
39
65
pub struct Presence {
40
66
pub availability: Availability,
41
pub in_call: bool,
67
pub activity: Option<Activity>,
42
68
}
43
69
44
fn is_call_activity(activity: Option<&str>) -> bool {
45
matches!(activity, Some("InACall" | "InAConferenceCall"))
70
impl Presence {
71
pub fn in_call(&self) -> bool {
72
self.activity.is_some_and(Activity::is_call)
73
}
46
74
}
47
75
48
76
impl<R: Remote> SyncEngine<R> {
@@ -203,10 +231,49 @@ impl<R: Remote> SyncEngine<R> {
203
231
for (user_id, availability, activity) in found {
204
232
let presence = Presence {
205
233
availability: Availability::from_service(availability),
206
in_call: is_call_activity(activity),
234
activity: activity.and_then(Activity::from_service),
207
235
};
208
236
changed |= known.insert(user_id.clone(), presence) != Some(presence);
209
237
}
210
238
changed
211
239
}
212
240
}
241
242
#[cfg(test)]
243
mod tests {
244
use super::*;
245
246
#[test]
247
fn activity_names_map_and_unknown_is_none() {
248
assert_eq!(Activity::from_service("InACall"), Some(Activity::InACall));
249
assert_eq!(
250
Activity::from_service("InAConferenceCall"),
251
Some(Activity::InAConferenceCall)
252
);
253
assert_eq!(
254
Activity::from_service("InAMeeting"),
255
Some(Activity::InAMeeting)
256
);
257
assert_eq!(
258
Activity::from_service("Presenting"),
259
Some(Activity::Presenting)
260
);
261
assert_eq!(
262
Activity::from_service("OutOfOffice"),
263
Some(Activity::OutOfOffice)
264
);
265
assert_eq!(Activity::from_service("Available"), None);
266
}
267
268
#[test]
269
fn only_call_activities_count_as_in_call() {
270
let presence = |activity| Presence {
271
availability: Availability::Busy,
272
activity,
273
};
274
assert!(presence(Some(Activity::InACall)).in_call());
275
assert!(presence(Some(Activity::InAConferenceCall)).in_call());
276
assert!(!presence(Some(Activity::InAMeeting)).in_call());
277
assert!(!presence(None).in_call());
278
}
279
}
@@ -35,14 +35,42 @@ impl Availability {35
}35
}36
}36
}37
37
38
#[derive(Debug, Clone, Copy, PartialEq, Eq)]39
pub enum Activity {40
InACall,41
InAConferenceCall,42
InAMeeting,43
Presenting,44
OutOfOffice,45
}46
47
impl Activity {48
pub fn from_service(name: &str) -> Option<Self> {49
match name {50
"InACall" => Some(Activity::InACall),51
"InAConferenceCall" => Some(Activity::InAConferenceCall),52
"InAMeeting" => Some(Activity::InAMeeting),53
"Presenting" => Some(Activity::Presenting),54
"OutOfOffice" => Some(Activity::OutOfOffice),55
_ => None,56
}57
}58
59
pub fn is_call(self) -> bool {60
matches!(self, Activity::InACall | Activity::InAConferenceCall)61
}62
}63
38
#[derive(Debug, Clone, Copy, PartialEq, Eq)]64
#[derive(Debug, Clone, Copy, PartialEq, Eq)]39
pub struct Presence {65
pub struct Presence {40
pub availability: Availability,66
pub availability: Availability,41
pub in_call: bool,67
pub activity: Option<Activity>,42
}68
}43
69
44
fn is_call_activity(activity: Option<&str>) -> bool {70
impl Presence {45
matches!(activity, Some("InACall" | "InAConferenceCall"))71
pub fn in_call(&self) -> bool {72
self.activity.is_some_and(Activity::is_call)73
}46
}74
}47
75
48
impl<R: Remote> SyncEngine<R> {76
impl<R: Remote> SyncEngine<R> {@@ -203,10 +231,49 @@ impl<R: Remote> SyncEngine<R> {203
for (user_id, availability, activity) in found {231
for (user_id, availability, activity) in found {204
let presence = Presence {232
let presence = Presence {205
availability: Availability::from_service(availability),233
availability: Availability::from_service(availability),206
in_call: is_call_activity(activity),234
activity: activity.and_then(Activity::from_service),207
};235
};208
changed |= known.insert(user_id.clone(), presence) != Some(presence);236
changed |= known.insert(user_id.clone(), presence) != Some(presence);209
}237
}210
changed238
changed211
}239
}212
}240
}241
242
#[cfg(test)]243
mod tests {244
use super::*;245
246
#[test]247
fn activity_names_map_and_unknown_is_none() {248
assert_eq!(Activity::from_service("InACall"), Some(Activity::InACall));249
assert_eq!(250
Activity::from_service("InAConferenceCall"),251
Some(Activity::InAConferenceCall)252
);253
assert_eq!(254
Activity::from_service("InAMeeting"),255
Some(Activity::InAMeeting)256
);257
assert_eq!(258
Activity::from_service("Presenting"),259
Some(Activity::Presenting)260
);261
assert_eq!(262
Activity::from_service("OutOfOffice"),263
Some(Activity::OutOfOffice)264
);265
assert_eq!(Activity::from_service("Available"), None);266
}267
268
#[test]269
fn only_call_activities_count_as_in_call() {270
let presence = |activity| Presence {271
availability: Availability::Busy,272
activity,273
};274
assert!(presence(Some(Activity::InACall)).in_call());275
assert!(presence(Some(Activity::InAConferenceCall)).in_call());276
assert!(!presence(Some(Activity::InAMeeting)).in_call());277
assert!(!presence(None).in_call());278
}279
}