fix(calls): the Echo chat call buttons start the test call
- is_echo_chat by chat id or bot member, like Teams Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -24,7 +24,7 @@ use super::report::{
24
24
CallRecorder, OwnIdentity, SETTING_META_KEY, SharedRecorder, report_directory, save_report, shared,
25
25
};
26
26
use super::ring::{MissedCall, RingOutcome};
27
use super::target::{is_organizer, plan_for_chat};
27
use super::target::{is_echo_chat, is_organizer, plan_for_chat};
28
28
use crate::app_state::{AppEvent, AppState, Selection, chat_title, selection_for};
29
29
use crate::notice::NoticeAction;
30
30
@@ -134,12 +134,12 @@ impl AppState {
134
134
self.show_call(true, cx);
135
135
return;
136
136
}
137
let plan = self
138
.sidebar
139
.chats
140
.iter()
141
.find(|chat| chat.id == conversation_id)
142
.and_then(|chat| plan_for_chat(chat, self.directory.me.as_ref()));
137
let chat = self.sidebar.chats.iter().find(|chat| chat.id == conversation_id);
138
if chat.is_some_and(is_echo_chat) {
139
self.start_test_call(cx);
140
return;
141
}
142
let plan = chat.and_then(|chat| plan_for_chat(chat, self.directory.me.as_ref()));
143
143
let Some(plan) = plan else {
144
144
self.raise_notice(NOT_CALLABLE_NOTICE.to_owned(), None, cx);
145
145
return;
@@ -24,7 +24,7 @@ use super::report::{24
CallRecorder, OwnIdentity, SETTING_META_KEY, SharedRecorder, report_directory, save_report, shared,24
CallRecorder, OwnIdentity, SETTING_META_KEY, SharedRecorder, report_directory, save_report, shared,25
};25
};26
use super::ring::{MissedCall, RingOutcome};26
use super::ring::{MissedCall, RingOutcome};27
use super::target::{is_organizer, plan_for_chat};27
use super::target::{is_echo_chat, is_organizer, plan_for_chat};28
use crate::app_state::{AppEvent, AppState, Selection, chat_title, selection_for};28
use crate::app_state::{AppEvent, AppState, Selection, chat_title, selection_for};29
use crate::notice::NoticeAction;29
use crate::notice::NoticeAction;30
30
@@ -134,12 +134,12 @@ impl AppState {134
self.show_call(true, cx);134
self.show_call(true, cx);135
return;135
return;136
}136
}137
let plan = self137
let chat = self.sidebar.chats.iter().find(|chat| chat.id == conversation_id);138
.sidebar138
if chat.is_some_and(is_echo_chat) {139
.chats139
self.start_test_call(cx);140
.iter()140
return;141
.find(|chat| chat.id == conversation_id)141
}142
.and_then(|chat| plan_for_chat(chat, self.directory.me.as_ref()));142
let plan = chat.and_then(|chat| plan_for_chat(chat, self.directory.me.as_ref()));143
let Some(plan) = plan else {143
let Some(plan) = plan else {144
self.raise_notice(NOT_CALLABLE_NOTICE.to_owned(), None, cx);144
self.raise_notice(NOT_CALLABLE_NOTICE.to_owned(), None, cx);145
return;145
return;@@ -66,6 +66,6 @@ pub use schedule::{FormValues, Invitee, default_window, draft_from_form};
66
66
pub use record_rights::{RecordBlock, RecordFeature};
67
67
pub use recording_menu::{RecordAction, RecordingChip, record_actions, recording_chip};
68
68
pub use report::load_enabled as load_report_enabled;
69
pub use target::plan_for_chat;
69
pub use target::{is_echo_chat, plan_for_chat};
70
70
pub use transcript::clock_label;
71
71
pub use view_settings::{CallLayout, ViewSettings};
@@ -66,6 +66,6 @@ pub use schedule::{FormValues, Invitee, default_window, draft_from_form};66
pub use record_rights::{RecordBlock, RecordFeature};66
pub use record_rights::{RecordBlock, RecordFeature};67
pub use recording_menu::{RecordAction, RecordingChip, record_actions, recording_chip};67
pub use recording_menu::{RecordAction, RecordingChip, record_actions, recording_chip};68
pub use report::load_enabled as load_report_enabled;68
pub use report::load_enabled as load_report_enabled;69
pub use target::plan_for_chat;69
pub use target::{is_echo_chat, plan_for_chat};70
pub use transcript::clock_label;70
pub use transcript::clock_label;71
pub use view_settings::{CallLayout, ViewSettings};71
pub use view_settings::{CallLayout, ViewSettings};@@ -31,6 +31,19 @@ pub fn plan_for_chat(chat: &ChatRecord, me: Option<&Person>) -> Option<CallPlan>
31
31
Some(CallPlan { title, callees })
32
32
}
33
33
34
/// Teams starts the Echo test call from the Echo chat's call buttons.
35
pub fn is_echo_chat(chat: &ChatRecord) -> bool {
36
let echo_id = calling::signaling::ECHO_BOT_MRI;
37
let bare_id = echo_id.trim_start_matches("28:");
38
is_one_on_one(chat)
39
&& (chat.id.contains(bare_id)
40
|| chat
41
.members
42
.iter()
43
.filter_map(|member| member.user_id.as_deref())
44
.any(|user_id| user_id == echo_id || user_id == bare_id))
45
}
46
34
47
pub fn is_organizer(meeting: &LiveMeeting, me: Option<&Person>) -> bool {
35
48
match (meeting.organizer_id.as_deref(), me) {
36
49
(Some(organizer), Some(me)) => organizer.eq_ignore_ascii_case(&me.user_id),
@@ -115,6 +128,22 @@ mod tests {
115
128
assert!(plan_for_chat(¬es, Some(&me())).is_none());
116
129
}
117
130
131
#[test]
132
fn the_echo_chat_is_recognised_by_its_id_or_its_bot_member() {
133
let mut echo = chat(
134
"oneOnOne",
135
"Echo",
136
&[(Some("me-id"), "Me"), (Some(calling::signaling::ECHO_BOT_MRI), "Echo")],
137
);
138
assert!(is_echo_chat(&echo));
139
echo.members.truncate(1);
140
assert!(!is_echo_chat(&echo));
141
echo.id = "19:me-id_cf28171e-fcfd-47e4-a1d6-79460b0b3ca0@unq.gbl.spaces".into();
142
assert!(is_echo_chat(&echo));
143
let other = chat("oneOnOne", "", &[(Some("me-id"), "Me"), (Some("bea-id"), "Bea")]);
144
assert!(!is_echo_chat(&other));
145
}
146
118
147
#[test]
119
148
fn the_organizer_may_end_the_meeting() {
120
149
let meeting = LiveMeeting {
@@ -31,6 +31,19 @@ pub fn plan_for_chat(chat: &ChatRecord, me: Option<&Person>) -> Option<CallPlan>31
Some(CallPlan { title, callees })31
Some(CallPlan { title, callees })32
}32
}33
33
34
/// Teams starts the Echo test call from the Echo chat's call buttons.35
pub fn is_echo_chat(chat: &ChatRecord) -> bool {36
let echo_id = calling::signaling::ECHO_BOT_MRI;37
let bare_id = echo_id.trim_start_matches("28:");38
is_one_on_one(chat)39
&& (chat.id.contains(bare_id)40
|| chat41
.members42
.iter()43
.filter_map(|member| member.user_id.as_deref())44
.any(|user_id| user_id == echo_id || user_id == bare_id))45
}46
34
pub fn is_organizer(meeting: &LiveMeeting, me: Option<&Person>) -> bool {47
pub fn is_organizer(meeting: &LiveMeeting, me: Option<&Person>) -> bool {35
match (meeting.organizer_id.as_deref(), me) {48
match (meeting.organizer_id.as_deref(), me) {36
(Some(organizer), Some(me)) => organizer.eq_ignore_ascii_case(&me.user_id),49
(Some(organizer), Some(me)) => organizer.eq_ignore_ascii_case(&me.user_id),@@ -115,6 +128,22 @@ mod tests {115
assert!(plan_for_chat(¬es, Some(&me())).is_none());128
assert!(plan_for_chat(¬es, Some(&me())).is_none());116
}129
}117
130
131
#[test]132
fn the_echo_chat_is_recognised_by_its_id_or_its_bot_member() {133
let mut echo = chat(134
"oneOnOne",135
"Echo",136
&[(Some("me-id"), "Me"), (Some(calling::signaling::ECHO_BOT_MRI), "Echo")],137
);138
assert!(is_echo_chat(&echo));139
echo.members.truncate(1);140
assert!(!is_echo_chat(&echo));141
echo.id = "19:me-id_cf28171e-fcfd-47e4-a1d6-79460b0b3ca0@unq.gbl.spaces".into();142
assert!(is_echo_chat(&echo));143
let other = chat("oneOnOne", "", &[(Some("me-id"), "Me"), (Some("bea-id"), "Bea")]);144
assert!(!is_echo_chat(&other));145
}146
118
#[test]147
#[test]119
fn the_organizer_may_end_the_meeting() {148
fn the_organizer_may_end_the_meeting() {120
let meeting = LiveMeeting {149
let meeting = LiveMeeting {@@ -7,7 +7,7 @@ use gpui_kit::*;
7
7
8
8
use super::widgets::icon;
9
9
use crate::app_state::{AppState, Selection};
10
use crate::call::plan_for_chat;
10
use crate::call::{is_echo_chat, plan_for_chat};
11
11
use crate::theme;
12
12
13
13
const BUTTON_SIZE: f32 = 30.;
@@ -53,7 +53,9 @@ pub fn header_call_controls(
53
53
.chats
54
54
.iter()
55
55
.find(|chat| &chat.id == chat_id)
56
.is_some_and(|chat| plan_for_chat(chat, state.directory.me.as_ref()).is_some()));
56
.is_some_and(|chat| {
57
is_echo_chat(chat) || plan_for_chat(chat, state.directory.me.as_ref()).is_some()
58
}));
57
59
if callable {
58
60
for (id, tooltip, glyph, with_video) in [
59
61
("header-video-call", "Video call", IconName::Video, true),
@@ -7,7 +7,7 @@ use gpui_kit::*;7
7
8
use super::widgets::icon;8
use super::widgets::icon;9
use crate::app_state::{AppState, Selection};9
use crate::app_state::{AppState, Selection};10
use crate::call::plan_for_chat;10
use crate::call::{is_echo_chat, plan_for_chat};11
use crate::theme;11
use crate::theme;12
12
13
const BUTTON_SIZE: f32 = 30.;13
const BUTTON_SIZE: f32 = 30.;@@ -53,7 +53,9 @@ pub fn header_call_controls(53
.chats53
.chats54
.iter()54
.iter()55
.find(|chat| &chat.id == chat_id)55
.find(|chat| &chat.id == chat_id)56
.is_some_and(|chat| plan_for_chat(chat, state.directory.me.as_ref()).is_some()));56
.is_some_and(|chat| {57
is_echo_chat(chat) || plan_for_chat(chat, state.directory.me.as_ref()).is_some()58
}));57
if callable {59
if callable {58
for (id, tooltip, glyph, with_video) in [60
for (id, tooltip, glyph, with_video) in [59
("header-video-call", "Video call", IconName::Video, true),61
("header-video-call", "Video call", IconName::Video, true),