fix(calls): show meeting reactions with unknown names instead of dropping them
- Reaction::Other keeps any received name; the chip shows the emoticon glyph from the chat catalog, else the name in a pill - Sending unchanged: only like, heart, applause, laugh, surprised (Teams' branded set in the bundle) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -582,7 +582,7 @@ async fn speak_until_hangup(
582
582
if ticks % REACTION_EVERY_TICKS == REACTION_EVERY_TICKS / 2
583
583
&& let Some((mri, _)) = people.get((ticks / REACTION_EVERY_TICKS) as usize % people.len().max(1))
584
584
{
585
let reaction = Reaction::ALL[(ticks / REACTION_EVERY_TICKS) as usize % Reaction::ALL.len()];
585
let reaction = Reaction::ALL[(ticks / REACTION_EVERY_TICKS) as usize % Reaction::ALL.len()].clone();
586
586
control.send(CallUpdate::Reaction { mri: mri.clone(), reaction });
587
587
}
588
588
if captions_on {
@@ -582,7 +582,7 @@ async fn speak_until_hangup(582
if ticks % REACTION_EVERY_TICKS == REACTION_EVERY_TICKS / 2582
if ticks % REACTION_EVERY_TICKS == REACTION_EVERY_TICKS / 2583
&& let Some((mri, _)) = people.get((ticks / REACTION_EVERY_TICKS) as usize % people.len().max(1))583
&& let Some((mri, _)) = people.get((ticks / REACTION_EVERY_TICKS) as usize % people.len().max(1))584
{584
{585
let reaction = Reaction::ALL[(ticks / REACTION_EVERY_TICKS) as usize % Reaction::ALL.len()];585
let reaction = Reaction::ALL[(ticks / REACTION_EVERY_TICKS) as usize % Reaction::ALL.len()].clone();586
control.send(CallUpdate::Reaction { mri: mri.clone(), reaction });586
control.send(CallUpdate::Reaction { mri: mri.clone(), reaction });587
}587
}588
if captions_on {588
if captions_on {@@ -1840,13 +1840,13 @@ mod tests {
1840
1840
let reaction_at = |model: &CallModel, mri: &str, seconds: u64| {
1841
1841
model
1842
1842
.chip_of(mri, start + Duration::from_secs(seconds))
1843
.map(|chip| chip.reaction)
1843
.map(|chip| chip.reaction.clone())
1844
1844
};
1845
1845
assert_eq!(reaction_at(&model, "8:orgid:a", 2), Some(Reaction::Heart));
1846
1846
assert_eq!(
1847
1847
model
1848
1848
.own_chip(start + Duration::from_secs(2))
1849
.map(|chip| chip.reaction),
1849
.map(|chip| chip.reaction.clone()),
1850
1850
Some(Reaction::Like)
1851
1851
);
1852
1852
assert_eq!(reaction_at(&model, "8:orgid:a", 3), None);
@@ -1840,13 +1840,13 @@ mod tests {1840
let reaction_at = |model: &CallModel, mri: &str, seconds: u64| {1840
let reaction_at = |model: &CallModel, mri: &str, seconds: u64| {1841
model1841
model1842
.chip_of(mri, start + Duration::from_secs(seconds))1842
.chip_of(mri, start + Duration::from_secs(seconds))1843
.map(|chip| chip.reaction)1843
.map(|chip| chip.reaction.clone())1844
};1844
};1845
assert_eq!(reaction_at(&model, "8:orgid:a", 2), Some(Reaction::Heart));1845
assert_eq!(reaction_at(&model, "8:orgid:a", 2), Some(Reaction::Heart));1846
assert_eq!(1846
assert_eq!(1847
model1847
model1848
.own_chip(start + Duration::from_secs(2))1848
.own_chip(start + Duration::from_secs(2))1849
.map(|chip| chip.reaction),1849
.map(|chip| chip.reaction.clone()),1850
Some(Reaction::Like)1850
Some(Reaction::Like)1851
);1851
);1852
assert_eq!(reaction_at(&model, "8:orgid:a", 3), None);1852
assert_eq!(reaction_at(&model, "8:orgid:a", 3), None);@@ -798,7 +798,7 @@ impl AppState {
798
798
return;
799
799
};
800
800
if let Some(own_mri) = call.model.own_mri.clone() {
801
call.model.note_reaction(own_mri, reaction, Instant::now());
801
call.model.note_reaction(own_mri, reaction.clone(), Instant::now());
802
802
}
803
803
self.send_call_command(CallCommand::SendReaction(reaction));
804
804
cx.emit(AppEvent::Call);
@@ -798,7 +798,7 @@ impl AppState {798
return;798
return;799
};799
};800
if let Some(own_mri) = call.model.own_mri.clone() {800
if let Some(own_mri) = call.model.own_mri.clone() {801
call.model.note_reaction(own_mri, reaction, Instant::now());801
call.model.note_reaction(own_mri, reaction.clone(), Instant::now());802
}802
}803
self.send_call_command(CallCommand::SendReaction(reaction));803
self.send_call_command(CallCommand::SendReaction(reaction));804
cx.emit(AppEvent::Call);804
cx.emit(AppEvent::Call);@@ -125,10 +125,10 @@ fn reactions_submenu(
125
125
for reaction in Reaction::ALL {
126
126
let app = app.clone();
127
127
menu = menu.item(
128
PopupMenuItem::new(format!("{} {}", reaction_glyph(reaction), reaction.name()))
128
PopupMenuItem::new(format!("{} {}", reaction_glyph(&reaction), reaction.name()))
129
129
.disabled(!can_react)
130
130
.on_click(move |_, _, cx| {
131
app.update(cx, |state, cx| state.send_call_reaction(reaction, cx))
131
app.update(cx, |state, cx| state.send_call_reaction(reaction.clone(), cx))
132
132
}),
133
133
);
134
134
}
@@ -125,10 +125,10 @@ fn reactions_submenu(125
for reaction in Reaction::ALL {125
for reaction in Reaction::ALL {126
let app = app.clone();126
let app = app.clone();127
menu = menu.item(127
menu = menu.item(128
PopupMenuItem::new(format!("{} {}", reaction_glyph(reaction), reaction.name()))128
PopupMenuItem::new(format!("{} {}", reaction_glyph(&reaction), reaction.name()))129
.disabled(!can_react)129
.disabled(!can_react)130
.on_click(move |_, _, cx| {130
.on_click(move |_, _, cx| {131
app.update(cx, |state, cx| state.send_call_reaction(reaction, cx))131
app.update(cx, |state, cx| state.send_call_reaction(reaction.clone(), cx))132
}),132
}),133
);133
);134
}134
}@@ -79,13 +79,17 @@ const MUSIC_MODE_LABEL: &str = "Music mode";
79
79
const PUSH_TO_TALK_HINT: &str = "Unmuted - release Ctrl+Space to mute";
80
80
const PUSH_TO_TALK_TOP: f32 = 12.;
81
81
82
pub fn reaction_glyph(reaction: Reaction) -> String {
82
pub fn reaction_glyph(reaction: &Reaction) -> String {
83
83
match reaction {
84
84
Reaction::Applause => "\u{1F44F}".to_owned(),
85
85
other => chat_reaction_glyph(other.name()),
86
86
}
87
87
}
88
88
89
fn is_emoji_glyph(glyph: &str) -> bool {
90
!glyph.is_ascii()
91
}
92
89
93
#[derive(Default)]
90
94
struct TileExtras {
91
95
hand: Option<usize>,
@@ -114,18 +118,22 @@ fn hand_badge(position: usize, own: bool) -> Div {
114
118
}
115
119
116
120
fn reaction_chip(reaction: Reaction, serial: u64) -> AnyElement {
121
let glyph = reaction_glyph(&reaction);
122
let emoji = is_emoji_glyph(&glyph);
117
123
div()
118
124
.absolute()
119
125
.right(px(12.))
120
126
.bottom(px(32.))
121
.size(px(36.))
127
.h(px(36.))
128
.min_w(px(36.))
129
.when(!emoji, |chip| chip.px(px(12.)))
122
130
.flex()
123
131
.items_center()
124
132
.justify_center()
125
133
.rounded_full()
126
134
.bg(theme::popup())
127
.text_size(px(20.))
128
.child(reaction_glyph(reaction))
135
.text_size(px(if emoji { 20. } else { 13. }))
136
.child(glyph)
129
137
.with_animation(
130
138
("call-reaction", serial as usize),
131
139
Animation::new(REACTION_SHOWN),
@@ -152,6 +160,7 @@ fn tile_overlays(extras: &TileExtras) -> Vec<AnyElement> {
152
160
});
153
161
let reaction = extras
154
162
.reaction
163
.clone()
155
164
.map(|(reaction, serial)| reaction_chip(reaction, serial));
156
165
badges.into_iter().chain(reaction).collect()
157
166
}
@@ -796,7 +805,7 @@ fn reactions_button(app: &Entity<AppState>, model: &CallModel) -> AnyElement {
796
805
let app = app.clone();
797
806
let popover = popover.clone();
798
807
div()
799
.id(reaction.name())
808
.id(ElementId::Name(reaction.name().to_owned().into()))
800
809
.size(px(REACTION_CELL))
801
810
.flex()
802
811
.items_center()
@@ -805,9 +814,9 @@ fn reactions_button(app: &Entity<AppState>, model: &CallModel) -> AnyElement {
805
814
.text_size(px(24.))
806
815
.cursor_pointer()
807
816
.hover(|cell| cell.bg(theme::border_strong()))
808
.child(reaction_glyph(reaction))
817
.child(reaction_glyph(&reaction))
809
818
.on_click(move |_, window, cx| {
810
app.update(cx, |state, cx| state.send_call_reaction(reaction, cx));
819
app.update(cx, |state, cx| state.send_call_reaction(reaction.clone(), cx));
811
820
popover
812
821
.update(cx, |state, cx| state.dismiss(window, cx))
813
822
.ok();
@@ -980,7 +989,7 @@ pub(super) fn plain_person_tile(
980
989
own: false,
981
990
reaction: model
982
991
.chip_of(&remote.mri, now)
983
.map(|chip| (chip.reaction, chip.serial)),
992
.map(|chip| (chip.reaction.clone(), chip.serial)),
984
993
spotlight: remote.spotlight.is_some(),
985
994
pinned: model.is_pinned(&remote.mri),
986
995
};
@@ -1069,7 +1078,7 @@ pub(super) fn plain_own_tile(
1069
1078
let extras = TileExtras {
1070
1079
hand: model.own_hand.map(|rank| model.hand_position(rank)),
1071
1080
own: true,
1072
reaction: model.own_chip(now).map(|chip| (chip.reaction, chip.serial)),
1081
reaction: model.own_chip(now).map(|chip| (chip.reaction.clone(), chip.serial)),
1073
1082
spotlight: model.own_spotlight.is_some(),
1074
1083
pinned: model.is_pinned(own_mri),
1075
1084
};
@@ -79,13 +79,17 @@ const MUSIC_MODE_LABEL: &str = "Music mode";79
const PUSH_TO_TALK_HINT: &str = "Unmuted - release Ctrl+Space to mute";79
const PUSH_TO_TALK_HINT: &str = "Unmuted - release Ctrl+Space to mute";80
const PUSH_TO_TALK_TOP: f32 = 12.;80
const PUSH_TO_TALK_TOP: f32 = 12.;81
81
82
pub fn reaction_glyph(reaction: Reaction) -> String {82
pub fn reaction_glyph(reaction: &Reaction) -> String {83
match reaction {83
match reaction {84
Reaction::Applause => "\u{1F44F}".to_owned(),84
Reaction::Applause => "\u{1F44F}".to_owned(),85
other => chat_reaction_glyph(other.name()),85
other => chat_reaction_glyph(other.name()),86
}86
}87
}87
}88
88
89
fn is_emoji_glyph(glyph: &str) -> bool {90
!glyph.is_ascii()91
}92
89
#[derive(Default)]93
#[derive(Default)]90
struct TileExtras {94
struct TileExtras {91
hand: Option<usize>,95
hand: Option<usize>,@@ -114,18 +118,22 @@ fn hand_badge(position: usize, own: bool) -> Div {114
}118
}115
119
116
fn reaction_chip(reaction: Reaction, serial: u64) -> AnyElement {120
fn reaction_chip(reaction: Reaction, serial: u64) -> AnyElement {121
let glyph = reaction_glyph(&reaction);122
let emoji = is_emoji_glyph(&glyph);117
div()123
div()118
.absolute()124
.absolute()119
.right(px(12.))125
.right(px(12.))120
.bottom(px(32.))126
.bottom(px(32.))121
.size(px(36.))127
.h(px(36.))128
.min_w(px(36.))129
.when(!emoji, |chip| chip.px(px(12.)))122
.flex()130
.flex()123
.items_center()131
.items_center()124
.justify_center()132
.justify_center()125
.rounded_full()133
.rounded_full()126
.bg(theme::popup())134
.bg(theme::popup())127
.text_size(px(20.))135
.text_size(px(if emoji { 20. } else { 13. }))128
.child(reaction_glyph(reaction))136
.child(glyph)129
.with_animation(137
.with_animation(130
("call-reaction", serial as usize),138
("call-reaction", serial as usize),131
Animation::new(REACTION_SHOWN),139
Animation::new(REACTION_SHOWN),@@ -152,6 +160,7 @@ fn tile_overlays(extras: &TileExtras) -> Vec<AnyElement> {152
});160
});153
let reaction = extras161
let reaction = extras154
.reaction162
.reaction163
.clone()155
.map(|(reaction, serial)| reaction_chip(reaction, serial));164
.map(|(reaction, serial)| reaction_chip(reaction, serial));156
badges.into_iter().chain(reaction).collect()165
badges.into_iter().chain(reaction).collect()157
}166
}@@ -796,7 +805,7 @@ fn reactions_button(app: &Entity<AppState>, model: &CallModel) -> AnyElement {796
let app = app.clone();805
let app = app.clone();797
let popover = popover.clone();806
let popover = popover.clone();798
div()807
div()799
.id(reaction.name())808
.id(ElementId::Name(reaction.name().to_owned().into()))800
.size(px(REACTION_CELL))809
.size(px(REACTION_CELL))801
.flex()810
.flex()802
.items_center()811
.items_center()@@ -805,9 +814,9 @@ fn reactions_button(app: &Entity<AppState>, model: &CallModel) -> AnyElement {805
.text_size(px(24.))814
.text_size(px(24.))806
.cursor_pointer()815
.cursor_pointer()807
.hover(|cell| cell.bg(theme::border_strong()))816
.hover(|cell| cell.bg(theme::border_strong()))808
.child(reaction_glyph(reaction))817
.child(reaction_glyph(&reaction))809
.on_click(move |_, window, cx| {818
.on_click(move |_, window, cx| {810
app.update(cx, |state, cx| state.send_call_reaction(reaction, cx));819
app.update(cx, |state, cx| state.send_call_reaction(reaction.clone(), cx));811
popover820
popover812
.update(cx, |state, cx| state.dismiss(window, cx))821
.update(cx, |state, cx| state.dismiss(window, cx))813
.ok();822
.ok();@@ -980,7 +989,7 @@ pub(super) fn plain_person_tile(980
own: false,989
own: false,981
reaction: model990
reaction: model982
.chip_of(&remote.mri, now)991
.chip_of(&remote.mri, now)983
.map(|chip| (chip.reaction, chip.serial)),992
.map(|chip| (chip.reaction.clone(), chip.serial)),984
spotlight: remote.spotlight.is_some(),993
spotlight: remote.spotlight.is_some(),985
pinned: model.is_pinned(&remote.mri),994
pinned: model.is_pinned(&remote.mri),986
};995
};@@ -1069,7 +1078,7 @@ pub(super) fn plain_own_tile(1069
let extras = TileExtras {1078
let extras = TileExtras {1070
hand: model.own_hand.map(|rank| model.hand_position(rank)),1079
hand: model.own_hand.map(|rank| model.hand_position(rank)),1071
own: true,1080
own: true,1072
reaction: model.own_chip(now).map(|chip| (chip.reaction, chip.serial)),1081
reaction: model.own_chip(now).map(|chip| (chip.reaction.clone(), chip.serial)),1073
spotlight: model.own_spotlight.is_some(),1082
spotlight: model.own_spotlight.is_some(),1074
pinned: model.is_pinned(own_mri),1083
pinned: model.is_pinned(own_mri),1075
};1084
};@@ -3,33 +3,43 @@ use serde_json::{Value, json};
3
3
pub const DEFAULT_SKIN_TONE: u8 = 2;
4
4
const REACTION_TYPE: &str = "Reaction";
5
5
6
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6
#[derive(Debug, Clone, PartialEq, Eq)]
7
7
pub enum Reaction {
8
8
Like,
9
9
Heart,
10
10
Applause,
11
11
Laugh,
12
12
Surprised,
13
Other(String),
13
14
}
14
15
15
16
impl Reaction {
16
17
pub const ALL: [Reaction; 5] = [Reaction::Like, Reaction::Heart, Reaction::Applause, Reaction::Laugh, Reaction::Surprised];
17
18
18
pub fn name(self) -> &'static str {
19
pub fn name(&self) -> &str {
19
20
match self {
20
21
Reaction::Like => "like",
21
22
Reaction::Heart => "heart",
22
23
Reaction::Applause => "applause",
23
24
Reaction::Laugh => "laugh",
24
25
Reaction::Surprised => "surprised",
26
Reaction::Other(name) => name,
25
27
}
26
28
}
27
29
28
30
pub fn from_name(name: &str) -> Option<Reaction> {
29
Reaction::ALL.into_iter().find(|reaction| reaction.name() == name)
31
if name.trim().is_empty() {
32
return None;
33
}
34
Some(
35
Reaction::ALL
36
.into_iter()
37
.find(|reaction| reaction.name() == name)
38
.unwrap_or_else(|| Reaction::Other(name.to_owned())),
39
)
30
40
}
31
41
32
fn takes_skin_tone(self) -> bool {
42
fn takes_skin_tone(&self) -> bool {
33
43
matches!(self, Reaction::Like | Reaction::Applause)
34
44
}
35
45
}
@@ -107,7 +117,8 @@ mod tests {
107
117
for reaction in Reaction::ALL {
108
118
assert_eq!(Reaction::from_name(reaction.name()), Some(reaction));
109
119
}
110
assert_eq!(Reaction::from_name("confetti"), None);
120
assert_eq!(Reaction::from_name("confetti"), Some(Reaction::Other("confetti".into())));
121
assert_eq!(Reaction::from_name(""), None);
111
122
}
112
123
113
124
#[test]
@@ -132,9 +143,10 @@ mod tests {
132
143
],
133
144
});
134
145
let events = parse_reactions(&body);
135
assert_eq!(events.len(), 2);
146
assert_eq!(events.len(), 3);
136
147
assert_eq!(events[0], ReactionEvent { mri: "8:orgid:a".into(), reaction: Reaction::Heart, count: 1 });
137
assert_eq!(events[1].mri, "8:orgid:b");
148
assert_eq!(events[1].reaction, Reaction::Other("unknown".into()));
149
assert_eq!(events[2].mri, "8:orgid:b");
138
150
}
139
151
140
152
#[test]
@@ -3,33 +3,43 @@ use serde_json::{Value, json};3
pub const DEFAULT_SKIN_TONE: u8 = 2;3
pub const DEFAULT_SKIN_TONE: u8 = 2;4
const REACTION_TYPE: &str = "Reaction";4
const REACTION_TYPE: &str = "Reaction";5
5
6
#[derive(Debug, Clone, Copy, PartialEq, Eq)]6
#[derive(Debug, Clone, PartialEq, Eq)]7
pub enum Reaction {7
pub enum Reaction {8
Like,8
Like,9
Heart,9
Heart,10
Applause,10
Applause,11
Laugh,11
Laugh,12
Surprised,12
Surprised,13
Other(String),13
}14
}14
15
15
impl Reaction {16
impl Reaction {16
pub const ALL: [Reaction; 5] = [Reaction::Like, Reaction::Heart, Reaction::Applause, Reaction::Laugh, Reaction::Surprised];17
pub const ALL: [Reaction; 5] = [Reaction::Like, Reaction::Heart, Reaction::Applause, Reaction::Laugh, Reaction::Surprised];17
18
18
pub fn name(self) -> &'static str {19
pub fn name(&self) -> &str {19
match self {20
match self {20
Reaction::Like => "like",21
Reaction::Like => "like",21
Reaction::Heart => "heart",22
Reaction::Heart => "heart",22
Reaction::Applause => "applause",23
Reaction::Applause => "applause",23
Reaction::Laugh => "laugh",24
Reaction::Laugh => "laugh",24
Reaction::Surprised => "surprised",25
Reaction::Surprised => "surprised",26
Reaction::Other(name) => name,25
}27
}26
}28
}27
29
28
pub fn from_name(name: &str) -> Option<Reaction> {30
pub fn from_name(name: &str) -> Option<Reaction> {29
Reaction::ALL.into_iter().find(|reaction| reaction.name() == name)31
if name.trim().is_empty() {32
return None;33
}34
Some(35
Reaction::ALL36
.into_iter()37
.find(|reaction| reaction.name() == name)38
.unwrap_or_else(|| Reaction::Other(name.to_owned())),39
)30
}40
}31
41
32
fn takes_skin_tone(self) -> bool {42
fn takes_skin_tone(&self) -> bool {33
matches!(self, Reaction::Like | Reaction::Applause)43
matches!(self, Reaction::Like | Reaction::Applause)34
}44
}35
}45
}@@ -107,7 +117,8 @@ mod tests {107
for reaction in Reaction::ALL {117
for reaction in Reaction::ALL {108
assert_eq!(Reaction::from_name(reaction.name()), Some(reaction));118
assert_eq!(Reaction::from_name(reaction.name()), Some(reaction));109
}119
}110
assert_eq!(Reaction::from_name("confetti"), None);120
assert_eq!(Reaction::from_name("confetti"), Some(Reaction::Other("confetti".into())));121
assert_eq!(Reaction::from_name(""), None);111
}122
}112
123
113
#[test]124
#[test]@@ -132,9 +143,10 @@ mod tests {132
],143
],133
});144
});134
let events = parse_reactions(&body);145
let events = parse_reactions(&body);135
assert_eq!(events.len(), 2);146
assert_eq!(events.len(), 3);136
assert_eq!(events[0], ReactionEvent { mri: "8:orgid:a".into(), reaction: Reaction::Heart, count: 1 });147
assert_eq!(events[0], ReactionEvent { mri: "8:orgid:a".into(), reaction: Reaction::Heart, count: 1 });137
assert_eq!(events[1].mri, "8:orgid:b");148
assert_eq!(events[1].reaction, Reaction::Other("unknown".into()));149
assert_eq!(events[2].mri, "8:orgid:b");138
}150
}139
151
140
#[test]152
#[test]