BlueGit

ict rusty-teams

fix(calls): Teams on the web joins without the app launcher (1p)

- Meeting and chat links ask the launcher to stay in the browser
- Call window cancels msteams: and other external app launches

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-11-07 · 3 weeks ago

Hash
1837b8d7742ed5c7f2659ed5e3db6d971cd1abf7
Parent
a17e7d58
2 files changed +20 −4
crates/app-state/src/call/web_call.rs +5 −4
@@ -7,6 +7,7 @@ use crate::app_state::AppState;
7 7 pub const META_WEB_CALLS: &str = "calls.teams_web";
8 8 const TEAMS_WEB: &str = "https://teams.microsoft.com/l";
9 9 const WEB_CALL_TITLE: &str = "Teams call";
10 const STAY_IN_BROWSER: &str = "directDl=true&msLaunch=false&enableMobilePage=false&suppressPrompt=true";
10 11
11 12 pub fn stored_web_calls(store: &store::Store) -> bool {
12 13 store.meta(META_WEB_CALLS).ok().flatten().as_deref() == Some("true")
@@ -15,7 +16,7 @@ pub fn stored_web_calls(store: &store::Store) -> bool {
15 16 pub fn meeting_web_url(target: &MeetingTarget) -> String {
16 17 let context = json!({"Tid": target.tenant_id, "Oid": target.organizer_id}).to_string();
17 18 format!(
18 "{TEAMS_WEB}/meetup-join/{}/0?context={}",
19 "{TEAMS_WEB}/meetup-join/{}/0?context={}&{STAY_IN_BROWSER}",
19 20 encode(&target.thread_id),
20 21 encode(&context)
21 22 )
@@ -23,7 +24,7 @@ pub fn meeting_web_url(target: &MeetingTarget) -> String {
23 24
24 25 /// Teams on the web has no call link for a chat id, so the chat opens and the call starts there.
25 26 pub fn chat_web_url(thread_id: &str) -> String {
26 format!("{TEAMS_WEB}/chat/{}/0", encode(thread_id))
27 format!("{TEAMS_WEB}/chat/{}/0?{STAY_IN_BROWSER}", encode(thread_id))
27 28 }
28 29
29 30 fn encode(text: &str) -> String {
@@ -83,7 +84,7 @@ mod tests {
83 84 };
84 85 assert_eq!(
85 86 meeting_web_url(&target),
86 "https://teams.microsoft.com/l/meetup-join/19%3Ameeting_abc%40thread.v2/0?context=%7B%22Tid%22%3A%22tenant-1%22%2C%22Oid%22%3A%22organizer-1%22%7D"
87 "https://teams.microsoft.com/l/meetup-join/19%3Ameeting_abc%40thread.v2/0?context=%7B%22Tid%22%3A%22tenant-1%22%2C%22Oid%22%3A%22organizer-1%22%7D&directDl=true&msLaunch=false&enableMobilePage=false&suppressPrompt=true"
87 88 );
88 89 }
89 90
@@ -91,7 +92,7 @@ mod tests {
91 92 fn a_chat_opens_its_teams_chat_link() {
92 93 assert_eq!(
93 94 chat_web_url("19:abc@thread.v2"),
94 "https://teams.microsoft.com/l/chat/19%3Aabc%40thread.v2/0"
95 "https://teams.microsoft.com/l/chat/19%3Aabc%40thread.v2/0?directDl=true&msLaunch=false&enableMobilePage=false&suppressPrompt=true"
95 96 );
96 97 }
97 98 }
@@ -7,6 +7,7 @@ use crate::app_state::AppState;
7pub const META_WEB_CALLS: &str = "calls.teams_web";
7pub const META_WEB_CALLS: &str = "calls.teams_web";
8const TEAMS_WEB: &str = "https://teams.microsoft.com/l";
8const TEAMS_WEB: &str = "https://teams.microsoft.com/l";
9const WEB_CALL_TITLE: &str = "Teams call";
9const WEB_CALL_TITLE: &str = "Teams call";
10const STAY_IN_BROWSER: &str = "directDl=true&msLaunch=false&enableMobilePage=false&suppressPrompt=true";
10
11
11pub fn stored_web_calls(store: &store::Store) -> bool {
12pub fn stored_web_calls(store: &store::Store) -> bool {
12 store.meta(META_WEB_CALLS).ok().flatten().as_deref() == Some("true")
13 store.meta(META_WEB_CALLS).ok().flatten().as_deref() == Some("true")
@@ -15,7 +16,7 @@ pub fn stored_web_calls(store: &store::Store) -> bool {
15pub fn meeting_web_url(target: &MeetingTarget) -> String {
16pub fn meeting_web_url(target: &MeetingTarget) -> String {
16 let context = json!({"Tid": target.tenant_id, "Oid": target.organizer_id}).to_string();
17 let context = json!({"Tid": target.tenant_id, "Oid": target.organizer_id}).to_string();
17 format!(
18 format!(
18 "{TEAMS_WEB}/meetup-join/{}/0?context={}",
19 "{TEAMS_WEB}/meetup-join/{}/0?context={}&{STAY_IN_BROWSER}",
19 encode(&target.thread_id),
20 encode(&target.thread_id),
20 encode(&context)
21 encode(&context)
21 )
22 )
@@ -23,7 +24,7 @@ pub fn meeting_web_url(target: &MeetingTarget) -> String {
23
24
24/// Teams on the web has no call link for a chat id, so the chat opens and the call starts there.
25/// Teams on the web has no call link for a chat id, so the chat opens and the call starts there.
25pub fn chat_web_url(thread_id: &str) -> String {
26pub fn chat_web_url(thread_id: &str) -> String {
26 format!("{TEAMS_WEB}/chat/{}/0", encode(thread_id))
27 format!("{TEAMS_WEB}/chat/{}/0?{STAY_IN_BROWSER}", encode(thread_id))
27}
28}
28
29
29fn encode(text: &str) -> String {
30fn encode(text: &str) -> String {
@@ -83,7 +84,7 @@ mod tests {
83 };
84 };
84 assert_eq!(
85 assert_eq!(
85 meeting_web_url(&target),
86 meeting_web_url(&target),
86 "https://teams.microsoft.com/l/meetup-join/19%3Ameeting_abc%40thread.v2/0?context=%7B%22Tid%22%3A%22tenant-1%22%2C%22Oid%22%3A%22organizer-1%22%7D"
87 "https://teams.microsoft.com/l/meetup-join/19%3Ameeting_abc%40thread.v2/0?context=%7B%22Tid%22%3A%22tenant-1%22%2C%22Oid%22%3A%22organizer-1%22%7D&directDl=true&msLaunch=false&enableMobilePage=false&suppressPrompt=true"
87 );
88 );
88 }
89 }
89
90
@@ -91,7 +92,7 @@ mod tests {
91 fn a_chat_opens_its_teams_chat_link() {
92 fn a_chat_opens_its_teams_chat_link() {
92 assert_eq!(
93 assert_eq!(
93 chat_web_url("19:abc@thread.v2"),
94 chat_web_url("19:abc@thread.v2"),
94 "https://teams.microsoft.com/l/chat/19%3Aabc%40thread.v2/0"
95 "https://teams.microsoft.com/l/chat/19%3Aabc%40thread.v2/0?directDl=true&msLaunch=false&enableMobilePage=false&suppressPrompt=true"
95 );
96 );
96 }
97 }
97}
98}
crates/webview/src/host_dialog.rs +15 −0
@@ -324,6 +324,7 @@ fn attach(
324 324 DialogMode::Call => {
325 325 allow_teams_media(&webview)?;
326 326 shadow_calls(&webview)?;
327 block_app_launch(&webview)?;
327 328 forward_messages(&webview, id, is_media_origin)?;
328 329 }
329 330 }
@@ -440,6 +441,20 @@ fn shadow_calls(webview: &ICoreWebView2) -> windows::core::Result<()> {
440 441 }
441 442 }
442 443
444 fn block_app_launch(webview: &ICoreWebView2) -> windows::core::Result<()> {
445 let Ok(webview) = webview.cast::<ICoreWebView2_18>() else {
446 return Ok(());
447 };
448 let handler = LaunchingExternalUriSchemeEventHandler::create(Box::new(|_, arguments| {
449 if let Some(arguments) = arguments {
450 unsafe { arguments.SetCancel(true) }?;
451 }
452 Ok(())
453 }));
454 let mut token = 0;
455 unsafe { webview.add_LaunchingExternalUriScheme(&handler, &mut token) }
456 }
457
443 458 fn forward_new_windows(webview: &ICoreWebView2, id: u64) -> windows::core::Result<()> {
444 459 let handler = NewWindowRequestedEventHandler::create(Box::new(move |_, arguments| {
445 460 let Some(arguments) = arguments else {
@@ -324,6 +324,7 @@ fn attach(
324 DialogMode::Call => {
324 DialogMode::Call => {
325 allow_teams_media(&webview)?;
325 allow_teams_media(&webview)?;
326 shadow_calls(&webview)?;
326 shadow_calls(&webview)?;
327 block_app_launch(&webview)?;
327 forward_messages(&webview, id, is_media_origin)?;
328 forward_messages(&webview, id, is_media_origin)?;
328 }
329 }
329 }
330 }
@@ -440,6 +441,20 @@ fn shadow_calls(webview: &ICoreWebView2) -> windows::core::Result<()> {
440 }
441 }
441}
442}
442
443
444fn block_app_launch(webview: &ICoreWebView2) -> windows::core::Result<()> {
445 let Ok(webview) = webview.cast::<ICoreWebView2_18>() else {
446 return Ok(());
447 };
448 let handler = LaunchingExternalUriSchemeEventHandler::create(Box::new(|_, arguments| {
449 if let Some(arguments) = arguments {
450 unsafe { arguments.SetCancel(true) }?;
451 }
452 Ok(())
453 }));
454 let mut token = 0;
455 unsafe { webview.add_LaunchingExternalUriScheme(&handler, &mut token) }
456}
457
443fn forward_new_windows(webview: &ICoreWebView2, id: u64) -> windows::core::Result<()> {
458fn forward_new_windows(webview: &ICoreWebView2, id: u64) -> windows::core::Result<()> {
444 let handler = NewWindowRequestedEventHandler::create(Box::new(move |_, arguments| {
459 let handler = NewWindowRequestedEventHandler::create(Box::new(move |_, arguments| {
445 let Some(arguments) = arguments else {
460 let Some(arguments) = arguments else {