feat(chat): call, video call and schedule meeting on the profile card
- icon actions after Chat in Teams' order: Video call, Call, with Teams tooltips "Start a video call with {name}" / "Start an audio call with {name}"
- calls reuse the 1:1 call start on the existing 1:1 chat, else the 1:1 chat is resolved first (same path as Chat)
- Schedule meeting opens the New meeting form with the person prefilled
- Email and Copy email become icon actions with tooltips so the row fits the card
- deviation: Teams' Live Persona Card has no Schedule meeting action in this build, added on request
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -120,11 +120,33 @@ impl AppState {
120
120
}
121
121
122
122
pub fn open_chat_with(&mut self, user_id: &str, cx: &mut Context<Self>) {
123
self.with_one_on_one(user_id, cx, |state, chat_id, cx| {
124
state.select(Selection::Chat(chat_id.to_owned()), cx)
125
});
126
}
127
128
/// Teams starts a 1:1 call from the profile card; the 1:1 chat is the call thread.
129
pub fn call_person(&mut self, user_id: &str, with_video: bool, cx: &mut Context<Self>) {
130
self.with_one_on_one(user_id, cx, move |state, chat_id, cx| {
131
if with_video {
132
state.start_chat_video_call(chat_id, cx);
133
} else {
134
state.start_chat_call(chat_id, cx);
135
}
136
});
137
}
138
139
fn with_one_on_one(
140
&mut self,
141
user_id: &str,
142
cx: &mut Context<Self>,
143
then: impl FnOnce(&mut Self, &str, &mut Context<Self>) + 'static,
144
) {
123
145
let existing =
124
146
existing_one_on_one(&self.sidebar.chats, self.directory.me.as_ref(), user_id)
125
147
.map(|chat| chat.id.clone());
126
148
if let Some(chat_id) = existing {
127
self.select(Selection::Chat(chat_id), cx);
149
then(self, &chat_id, cx);
128
150
return;
129
151
}
130
152
if self.mode.read_only {
@@ -149,7 +171,7 @@ impl AppState {
149
171
this.update(cx, |state, cx| match outcome {
150
172
Ok(chat_id) => {
151
173
state.reload_sidebar(cx);
152
state.select(Selection::Chat(chat_id), cx);
174
then(state, &chat_id, cx);
153
175
}
154
176
Err(reason) => {
155
177
state.raise_notice(format!("Chat could not be opened: {reason}"), None, cx)
@@ -120,11 +120,33 @@ impl AppState {120
}120
}121
121
122
pub fn open_chat_with(&mut self, user_id: &str, cx: &mut Context<Self>) {122
pub fn open_chat_with(&mut self, user_id: &str, cx: &mut Context<Self>) {123
self.with_one_on_one(user_id, cx, |state, chat_id, cx| {124
state.select(Selection::Chat(chat_id.to_owned()), cx)125
});126
}127
128
/// Teams starts a 1:1 call from the profile card; the 1:1 chat is the call thread.129
pub fn call_person(&mut self, user_id: &str, with_video: bool, cx: &mut Context<Self>) {130
self.with_one_on_one(user_id, cx, move |state, chat_id, cx| {131
if with_video {132
state.start_chat_video_call(chat_id, cx);133
} else {134
state.start_chat_call(chat_id, cx);135
}136
});137
}138
139
fn with_one_on_one(140
&mut self,141
user_id: &str,142
cx: &mut Context<Self>,143
then: impl FnOnce(&mut Self, &str, &mut Context<Self>) + 'static,144
) {123
let existing =145
let existing =124
existing_one_on_one(&self.sidebar.chats, self.directory.me.as_ref(), user_id)146
existing_one_on_one(&self.sidebar.chats, self.directory.me.as_ref(), user_id)125
.map(|chat| chat.id.clone());147
.map(|chat| chat.id.clone());126
if let Some(chat_id) = existing {148
if let Some(chat_id) = existing {127
self.select(Selection::Chat(chat_id), cx);149
then(self, &chat_id, cx);128
return;150
return;129
}151
}130
if self.mode.read_only {152
if self.mode.read_only {@@ -149,7 +171,7 @@ impl AppState {149
this.update(cx, |state, cx| match outcome {171
this.update(cx, |state, cx| match outcome {150
Ok(chat_id) => {172
Ok(chat_id) => {151
state.reload_sidebar(cx);173
state.reload_sidebar(cx);152
state.select(Selection::Chat(chat_id), cx);174
then(state, &chat_id, cx);153
}175
}154
Err(reason) => {176
Err(reason) => {155
state.raise_notice(format!("Chat could not be opened: {reason}"), None, cx)177
state.raise_notice(format!("Chat could not be opened: {reason}"), None, cx)@@ -12,7 +12,7 @@ use gpui_kit::component::{WindowExt as _, h_flex, v_flex};
12
12
use gpui_kit::prelude::FluentBuilder as _;
13
13
use gpui_kit::*;
14
14
15
use super::new_chat::NewChatDraft;
15
use super::new_chat::{NewChatDraft, Pick};
16
16
use super::widgets::icon;
17
17
use crate::app_state::AppState;
18
18
use crate::call::{FormValues, Invitee, default_window, draft_from_form};
@@ -233,7 +233,20 @@ impl Render for MeetingForm {
233
233
}
234
234
235
235
pub fn open_new_meeting(state: Entity<AppState>, window: &mut Window, cx: &mut App) {
236
open_new_meeting_with(state, Vec::new(), window, cx);
237
}
238
239
pub fn open_new_meeting_with(
240
state: Entity<AppState>,
241
people: Vec<Pick>,
242
window: &mut Window,
243
cx: &mut App,
244
) {
236
245
let form = cx.new(|cx| MeetingForm::new(state, window, cx));
246
if !people.is_empty() {
247
let draft = form.read(cx).people.clone();
248
draft.update(cx, |draft, cx| draft.set_chips(people, cx));
249
}
237
250
let first_field = form.read(cx).title.clone();
238
251
window.open_dialog(cx, move |dialog: Dialog, _, cx| {
239
252
let submit_form = form.clone();
@@ -12,7 +12,7 @@ use gpui_kit::component::{WindowExt as _, h_flex, v_flex};12
use gpui_kit::prelude::FluentBuilder as _;12
use gpui_kit::prelude::FluentBuilder as _;13
use gpui_kit::*;13
use gpui_kit::*;14
14
15
use super::new_chat::NewChatDraft;15
use super::new_chat::{NewChatDraft, Pick};16
use super::widgets::icon;16
use super::widgets::icon;17
use crate::app_state::AppState;17
use crate::app_state::AppState;18
use crate::call::{FormValues, Invitee, default_window, draft_from_form};18
use crate::call::{FormValues, Invitee, default_window, draft_from_form};@@ -233,7 +233,20 @@ impl Render for MeetingForm {233
}233
}234
234
235
pub fn open_new_meeting(state: Entity<AppState>, window: &mut Window, cx: &mut App) {235
pub fn open_new_meeting(state: Entity<AppState>, window: &mut Window, cx: &mut App) {236
open_new_meeting_with(state, Vec::new(), window, cx);237
}238
239
pub fn open_new_meeting_with(240
state: Entity<AppState>,241
people: Vec<Pick>,242
window: &mut Window,243
cx: &mut App,244
) {236
let form = cx.new(|cx| MeetingForm::new(state, window, cx));245
let form = cx.new(|cx| MeetingForm::new(state, window, cx));246
if !people.is_empty() {247
let draft = form.read(cx).people.clone();248
draft.update(cx, |draft, cx| draft.set_chips(people, cx));249
}237
let first_field = form.read(cx).title.clone();250
let first_field = form.read(cx).title.clone();238
window.open_dialog(cx, move |dialog: Dialog, _, cx| {251
window.open_dialog(cx, move |dialog: Dialog, _, cx| {239
let submit_form = form.clone();252
let submit_form = form.clone();@@ -9,6 +9,8 @@ use gpui_kit::*;
9
9
use teams_core::{OrgPerson, PROFILE_LINK_PREFIX, PersonProfile, WorkLocationKind};
10
10
11
11
use super::avatar::{person_avatar, with_presence};
12
use super::new_chat::Pick;
13
use super::new_meeting_dialog::open_new_meeting_with;
12
14
use super::widgets::icon;
13
15
use crate::app_state::{AppHandle, AppState};
14
16
use crate::data::{Presence, PresenceKind, presence_kind_of};
@@ -31,6 +33,9 @@ const STATUS_LINES: usize = 3;
31
33
const REPORTS_MAX_HEIGHT: f32 = 168.;
32
34
const ACTION_HEIGHT: f32 = 30.;
33
35
const SKELETON_HEIGHT: f32 = 10.;
36
const SCHEDULE_MEETING: &str = "Schedule meeting";
37
const EMAIL: &str = "Email";
38
const COPY_EMAIL: &str = "Copy email";
34
39
35
40
pub enum ProfileCardEvent {
36
41
Close,
@@ -255,25 +260,76 @@ impl ProfileCard {
255
260
.me
256
261
.as_ref()
257
262
.is_some_and(|me| me.user_id == self.user_id);
263
let profile = self
264
.app
265
.read(cx)
266
.profiles
267
.get(&self.user_id)
268
.and_then(|entry| entry.profile.clone());
269
let name = self.display_name(profile.as_deref(), cx);
258
270
let user_id = self.user_id.clone();
259
271
let (mail_email, copy_email) = (email.clone(), email.clone());
272
let invitee = Pick {
273
user_id: user_id.clone(),
274
name: name.clone(),
275
mail: email,
276
};
277
let chat_id = user_id.clone();
278
let (video_id, audio_id) = (user_id.clone(), user_id.clone());
260
279
h_flex()
261
280
.gap(px(8.))
262
281
.when(!is_me, |row| {
263
282
row.child(
264
283
action_button("profile-chat", "Chat", IconName::MessageSquare, true).on_click(
265
284
cx.listener(move |this, _, _, cx| {
266
let user_id = user_id.clone();
285
let user_id = chat_id.clone();
267
286
this.app
268
287
.update(cx, |state, cx| state.open_chat_with(&user_id, cx));
269
288
cx.emit(ProfileCardEvent::Close);
270
289
}),
271
290
),
272
291
)
292
.child(
293
icon_action(
294
"profile-video-call",
295
IconName::Video,
296
video_call_tooltip(&name),
297
)
298
.on_click(cx.listener(move |this, _, _, cx| {
299
let user_id = video_id.clone();
300
this.app
301
.update(cx, |state, cx| state.call_person(&user_id, true, cx));
302
cx.emit(ProfileCardEvent::Close);
303
})),
304
)
305
.child(
306
icon_action(
307
"profile-audio-call",
308
IconName::Phone,
309
audio_call_tooltip(&name),
310
)
311
.on_click(cx.listener(move |this, _, _, cx| {
312
let user_id = audio_id.clone();
313
this.app
314
.update(cx, |state, cx| state.call_person(&user_id, false, cx));
315
cx.emit(ProfileCardEvent::Close);
316
})),
317
)
318
.child(
319
icon_action(
320
"profile-schedule-meeting",
321
IconName::Calendar,
322
SCHEDULE_MEETING.to_owned(),
323
)
324
.on_click(cx.listener(move |this, _, window, cx| {
325
open_new_meeting_with(this.app.clone(), vec![invitee.clone()], window, cx);
326
cx.emit(ProfileCardEvent::Close);
327
})),
328
)
273
329
})
274
330
.when_some(mail_email, |row, address| {
275
331
row.child(
276
action_button("profile-email", "Email", IconName::Mail, false).on_click(
332
icon_action("profile-email", IconName::Mail, EMAIL.to_owned()).on_click(
277
333
cx.listener(move |_, _, _, cx| {
278
334
cx.open_url(&mailto_url(&address));
279
335
cx.emit(ProfileCardEvent::Close);
@@ -283,7 +339,7 @@ impl ProfileCard {
283
339
})
284
340
.when_some(copy_email, |row, address| {
285
341
row.child(
286
action_button("profile-copy-email", "Copy email", IconName::Copy, false)
342
icon_action("profile-copy-email", IconName::Copy, COPY_EMAIL.to_owned())
287
343
.on_click(cx.listener(move |this, _, _, cx| {
288
344
this.app
289
345
.update(cx, |state, cx| state.copy_profile_email(&address, cx));
@@ -557,6 +613,30 @@ fn contact_row(row: ContactRow) -> Div {
557
613
)
558
614
}
559
615
616
pub fn video_call_tooltip(name: &str) -> String {
617
format!("Start a video call with {name}")
618
}
619
620
pub fn audio_call_tooltip(name: &str) -> String {
621
format!("Start an audio call with {name}")
622
}
623
624
fn icon_action(id: &'static str, glyph: IconName, tooltip: String) -> Stateful<Div> {
625
div()
626
.id(id)
627
.size(px(ACTION_HEIGHT))
628
.flex()
629
.flex_none()
630
.items_center()
631
.justify_center()
632
.rounded(px(6.))
633
.cursor_pointer()
634
.bg(theme::popup_hover())
635
.hover(|button| button.opacity(0.9))
636
.child(icon(glyph, 14., theme::text_soft()))
637
.tooltip(move |window, cx| Tooltip::new(tooltip.clone()).build(window, cx))
638
}
639
560
640
fn action_button(
561
641
id: &'static str,
562
642
label: &'static str,
@@ -664,3 +744,14 @@ impl Render for ProfileCard {
664
744
)
665
745
}
666
746
}
747
748
#[cfg(test)]
749
mod tests {
750
use super::{audio_call_tooltip, video_call_tooltip};
751
752
#[test]
753
fn call_tooltips_use_the_teams_wording() {
754
assert_eq!(video_call_tooltip("Ann"), "Start a video call with Ann");
755
assert_eq!(audio_call_tooltip("Ann"), "Start an audio call with Ann");
756
}
757
}
@@ -9,6 +9,8 @@ use gpui_kit::*;9
use teams_core::{OrgPerson, PROFILE_LINK_PREFIX, PersonProfile, WorkLocationKind};9
use teams_core::{OrgPerson, PROFILE_LINK_PREFIX, PersonProfile, WorkLocationKind};10
10
11
use super::avatar::{person_avatar, with_presence};11
use super::avatar::{person_avatar, with_presence};12
use super::new_chat::Pick;13
use super::new_meeting_dialog::open_new_meeting_with;12
use super::widgets::icon;14
use super::widgets::icon;13
use crate::app_state::{AppHandle, AppState};15
use crate::app_state::{AppHandle, AppState};14
use crate::data::{Presence, PresenceKind, presence_kind_of};16
use crate::data::{Presence, PresenceKind, presence_kind_of};@@ -31,6 +33,9 @@ const STATUS_LINES: usize = 3;31
const REPORTS_MAX_HEIGHT: f32 = 168.;33
const REPORTS_MAX_HEIGHT: f32 = 168.;32
const ACTION_HEIGHT: f32 = 30.;34
const ACTION_HEIGHT: f32 = 30.;33
const SKELETON_HEIGHT: f32 = 10.;35
const SKELETON_HEIGHT: f32 = 10.;36
const SCHEDULE_MEETING: &str = "Schedule meeting";37
const EMAIL: &str = "Email";38
const COPY_EMAIL: &str = "Copy email";34
39
35
pub enum ProfileCardEvent {40
pub enum ProfileCardEvent {36
Close,41
Close,@@ -255,25 +260,76 @@ impl ProfileCard {255
.me260
.me256
.as_ref()261
.as_ref()257
.is_some_and(|me| me.user_id == self.user_id);262
.is_some_and(|me| me.user_id == self.user_id);263
let profile = self264
.app265
.read(cx)266
.profiles267
.get(&self.user_id)268
.and_then(|entry| entry.profile.clone());269
let name = self.display_name(profile.as_deref(), cx);258
let user_id = self.user_id.clone();270
let user_id = self.user_id.clone();259
let (mail_email, copy_email) = (email.clone(), email.clone());271
let (mail_email, copy_email) = (email.clone(), email.clone());272
let invitee = Pick {273
user_id: user_id.clone(),274
name: name.clone(),275
mail: email,276
};277
let chat_id = user_id.clone();278
let (video_id, audio_id) = (user_id.clone(), user_id.clone());260
h_flex()279
h_flex()261
.gap(px(8.))280
.gap(px(8.))262
.when(!is_me, |row| {281
.when(!is_me, |row| {263
row.child(282
row.child(264
action_button("profile-chat", "Chat", IconName::MessageSquare, true).on_click(283
action_button("profile-chat", "Chat", IconName::MessageSquare, true).on_click(265
cx.listener(move |this, _, _, cx| {284
cx.listener(move |this, _, _, cx| {266
let user_id = user_id.clone();285
let user_id = chat_id.clone();267
this.app286
this.app268
.update(cx, |state, cx| state.open_chat_with(&user_id, cx));287
.update(cx, |state, cx| state.open_chat_with(&user_id, cx));269
cx.emit(ProfileCardEvent::Close);288
cx.emit(ProfileCardEvent::Close);270
}),289
}),271
),290
),272
)291
)292
.child(293
icon_action(294
"profile-video-call",295
IconName::Video,296
video_call_tooltip(&name),297
)298
.on_click(cx.listener(move |this, _, _, cx| {299
let user_id = video_id.clone();300
this.app301
.update(cx, |state, cx| state.call_person(&user_id, true, cx));302
cx.emit(ProfileCardEvent::Close);303
})),304
)305
.child(306
icon_action(307
"profile-audio-call",308
IconName::Phone,309
audio_call_tooltip(&name),310
)311
.on_click(cx.listener(move |this, _, _, cx| {312
let user_id = audio_id.clone();313
this.app314
.update(cx, |state, cx| state.call_person(&user_id, false, cx));315
cx.emit(ProfileCardEvent::Close);316
})),317
)318
.child(319
icon_action(320
"profile-schedule-meeting",321
IconName::Calendar,322
SCHEDULE_MEETING.to_owned(),323
)324
.on_click(cx.listener(move |this, _, window, cx| {325
open_new_meeting_with(this.app.clone(), vec![invitee.clone()], window, cx);326
cx.emit(ProfileCardEvent::Close);327
})),328
)273
})329
})274
.when_some(mail_email, |row, address| {330
.when_some(mail_email, |row, address| {275
row.child(331
row.child(276
action_button("profile-email", "Email", IconName::Mail, false).on_click(332
icon_action("profile-email", IconName::Mail, EMAIL.to_owned()).on_click(277
cx.listener(move |_, _, _, cx| {333
cx.listener(move |_, _, _, cx| {278
cx.open_url(&mailto_url(&address));334
cx.open_url(&mailto_url(&address));279
cx.emit(ProfileCardEvent::Close);335
cx.emit(ProfileCardEvent::Close);@@ -283,7 +339,7 @@ impl ProfileCard {283
})339
})284
.when_some(copy_email, |row, address| {340
.when_some(copy_email, |row, address| {285
row.child(341
row.child(286
action_button("profile-copy-email", "Copy email", IconName::Copy, false)342
icon_action("profile-copy-email", IconName::Copy, COPY_EMAIL.to_owned())287
.on_click(cx.listener(move |this, _, _, cx| {343
.on_click(cx.listener(move |this, _, _, cx| {288
this.app344
this.app289
.update(cx, |state, cx| state.copy_profile_email(&address, cx));345
.update(cx, |state, cx| state.copy_profile_email(&address, cx));@@ -557,6 +613,30 @@ fn contact_row(row: ContactRow) -> Div {557
)613
)558
}614
}559
615
616
pub fn video_call_tooltip(name: &str) -> String {617
format!("Start a video call with {name}")618
}619
620
pub fn audio_call_tooltip(name: &str) -> String {621
format!("Start an audio call with {name}")622
}623
624
fn icon_action(id: &'static str, glyph: IconName, tooltip: String) -> Stateful<Div> {625
div()626
.id(id)627
.size(px(ACTION_HEIGHT))628
.flex()629
.flex_none()630
.items_center()631
.justify_center()632
.rounded(px(6.))633
.cursor_pointer()634
.bg(theme::popup_hover())635
.hover(|button| button.opacity(0.9))636
.child(icon(glyph, 14., theme::text_soft()))637
.tooltip(move |window, cx| Tooltip::new(tooltip.clone()).build(window, cx))638
}639
560
fn action_button(640
fn action_button(561
id: &'static str,641
id: &'static str,562
label: &'static str,642
label: &'static str,@@ -664,3 +744,14 @@ impl Render for ProfileCard {664
)744
)665
}745
}666
}746
}747
748
#[cfg(test)]749
mod tests {750
use super::{audio_call_tooltip, video_call_tooltip};751
752
#[test]753
fn call_tooltips_use_the_teams_wording() {754
assert_eq!(video_call_tooltip("Ann"), "Start a video call with Ann");755
assert_eq!(audio_call_tooltip("Ann"), "Start an audio call with Ann");756
}757
}