BlueGit

ict rusty-teams

fix(chat): meeting chats show a calendar avatar, out of office shows in presence

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

metis Daniel Däschle · pushed by metis

Authored 2026-10-15 · 6 weeks ago

Hash
c90a5568d13f5cbffee8250c75bd20e433692f5c
Parent
ef56e7b8
6 files changed +54 −1
crates/app/src/data.rs +24 −1
@@ -50,6 +50,7 @@ pub enum PresenceKind {
50 50 Busy,
51 51 DoNotDisturb,
52 52 Away,
53 OutOfOffice,
53 54 Offline,
54 55 Unknown,
55 56 }
@@ -61,6 +62,7 @@ impl PresenceKind {
61 62 PresenceKind::Busy => "Busy",
62 63 PresenceKind::DoNotDisturb => "Do not disturb",
63 64 PresenceKind::Away => "Away",
65 PresenceKind::OutOfOffice => "Out of office",
64 66 PresenceKind::Offline => "Offline",
65 67 PresenceKind::Unknown => "",
66 68 }
@@ -72,6 +74,7 @@ impl PresenceKind {
72 74 PresenceKind::Busy => "Busy",
73 75 PresenceKind::DoNotDisturb => "DoNotDisturb",
74 76 PresenceKind::Away => "Away",
77 PresenceKind::OutOfOffice => "OutOfOffice",
75 78 PresenceKind::Offline => "Offline",
76 79 PresenceKind::Unknown => "Unknown",
77 80 }
@@ -83,6 +86,7 @@ impl PresenceKind {
83 86 "Busy" => PresenceKind::Busy,
84 87 "DoNotDisturb" => PresenceKind::DoNotDisturb,
85 88 "Away" => PresenceKind::Away,
89 "OutOfOffice" => PresenceKind::OutOfOffice,
86 90 "Offline" => PresenceKind::Offline,
87 91 _ => PresenceKind::Unknown,
88 92 }
@@ -532,6 +536,13 @@ pub fn presence_kind_of(availability: Availability) -> PresenceKind {
532 536 }
533 537 }
534 538
539 pub fn shown_presence(availability: Availability, activity: Option<Activity>) -> PresenceKind {
540 match activity {
541 Some(Activity::OutOfOffice) => PresenceKind::OutOfOffice,
542 _ => presence_kind_of(availability),
543 }
544 }
545
535 546 pub fn activity_label(activity: Activity) -> &'static str {
536 547 match activity {
537 548 Activity::InACall => "In a call",
@@ -550,7 +561,7 @@ pub fn presence_activity(engine: &Engine, user_id: &str) -> Option<Activity> {
550 561 pub fn presence_kind(engine: &Engine, user_id: &str) -> Option<PresenceKind> {
551 562 engine
552 563 .presence(user_id)
553 .map(|presence| presence_kind_of(presence.availability))
564 .map(|presence| shown_presence(presence.availability, presence.activity))
554 565 }
555 566
556 567 pub fn in_call(engine: &Engine, user_id: &str) -> bool {
@@ -614,6 +625,18 @@ pub fn remove_from_folder(engine: &Arc<Engine>, conversation_id: &str, folder_id
614 625 mod tests {
615 626 use super::*;
616 627
628 #[test]
629 fn out_of_office_shows_over_the_availability() {
630 assert_eq!(
631 shown_presence(Availability::Offline, Some(Activity::OutOfOffice)),
632 PresenceKind::OutOfOffice
633 );
634 assert_eq!(
635 shown_presence(Availability::Available, Some(Activity::InAMeeting)),
636 PresenceKind::Available
637 );
638 }
639
617 640 #[test]
618 641 fn activity_wording_replaces_availability_only_for_live_presence() {
619 642 let cases = [
@@ -50,6 +50,7 @@ pub enum PresenceKind {
50 Busy,
50 Busy,
51 DoNotDisturb,
51 DoNotDisturb,
52 Away,
52 Away,
53 OutOfOffice,
53 Offline,
54 Offline,
54 Unknown,
55 Unknown,
55}
56}
@@ -61,6 +62,7 @@ impl PresenceKind {
61 PresenceKind::Busy => "Busy",
62 PresenceKind::Busy => "Busy",
62 PresenceKind::DoNotDisturb => "Do not disturb",
63 PresenceKind::DoNotDisturb => "Do not disturb",
63 PresenceKind::Away => "Away",
64 PresenceKind::Away => "Away",
65 PresenceKind::OutOfOffice => "Out of office",
64 PresenceKind::Offline => "Offline",
66 PresenceKind::Offline => "Offline",
65 PresenceKind::Unknown => "",
67 PresenceKind::Unknown => "",
66 }
68 }
@@ -72,6 +74,7 @@ impl PresenceKind {
72 PresenceKind::Busy => "Busy",
74 PresenceKind::Busy => "Busy",
73 PresenceKind::DoNotDisturb => "DoNotDisturb",
75 PresenceKind::DoNotDisturb => "DoNotDisturb",
74 PresenceKind::Away => "Away",
76 PresenceKind::Away => "Away",
77 PresenceKind::OutOfOffice => "OutOfOffice",
75 PresenceKind::Offline => "Offline",
78 PresenceKind::Offline => "Offline",
76 PresenceKind::Unknown => "Unknown",
79 PresenceKind::Unknown => "Unknown",
77 }
80 }
@@ -83,6 +86,7 @@ impl PresenceKind {
83 "Busy" => PresenceKind::Busy,
86 "Busy" => PresenceKind::Busy,
84 "DoNotDisturb" => PresenceKind::DoNotDisturb,
87 "DoNotDisturb" => PresenceKind::DoNotDisturb,
85 "Away" => PresenceKind::Away,
88 "Away" => PresenceKind::Away,
89 "OutOfOffice" => PresenceKind::OutOfOffice,
86 "Offline" => PresenceKind::Offline,
90 "Offline" => PresenceKind::Offline,
87 _ => PresenceKind::Unknown,
91 _ => PresenceKind::Unknown,
88 }
92 }
@@ -532,6 +536,13 @@ pub fn presence_kind_of(availability: Availability) -> PresenceKind {
532 }
536 }
533}
537}
534
538
539pub fn shown_presence(availability: Availability, activity: Option<Activity>) -> PresenceKind {
540 match activity {
541 Some(Activity::OutOfOffice) => PresenceKind::OutOfOffice,
542 _ => presence_kind_of(availability),
543 }
544}
545
535pub fn activity_label(activity: Activity) -> &'static str {
546pub fn activity_label(activity: Activity) -> &'static str {
536 match activity {
547 match activity {
537 Activity::InACall => "In a call",
548 Activity::InACall => "In a call",
@@ -550,7 +561,7 @@ pub fn presence_activity(engine: &Engine, user_id: &str) -> Option<Activity> {
550pub fn presence_kind(engine: &Engine, user_id: &str) -> Option<PresenceKind> {
561pub fn presence_kind(engine: &Engine, user_id: &str) -> Option<PresenceKind> {
551 engine
562 engine
552 .presence(user_id)
563 .presence(user_id)
553 .map(|presence| presence_kind_of(presence.availability))
564 .map(|presence| shown_presence(presence.availability, presence.activity))
554}
565}
555
566
556pub fn in_call(engine: &Engine, user_id: &str) -> bool {
567pub fn in_call(engine: &Engine, user_id: &str) -> bool {
@@ -614,6 +625,18 @@ pub fn remove_from_folder(engine: &Arc<Engine>, conversation_id: &str, folder_id
614mod tests {
625mod tests {
615 use super::*;
626 use super::*;
616
627
628 #[test]
629 fn out_of_office_shows_over_the_availability() {
630 assert_eq!(
631 shown_presence(Availability::Offline, Some(Activity::OutOfOffice)),
632 PresenceKind::OutOfOffice
633 );
634 assert_eq!(
635 shown_presence(Availability::Available, Some(Activity::InAMeeting)),
636 PresenceKind::Available
637 );
638 }
639
617 #[test]
640 #[test]
618 fn activity_wording_replaces_availability_only_for_live_presence() {
641 fn activity_wording_replaces_availability_only_for_live_presence() {
619 let cases = [
642 let cases = [
crates/app/src/sidebar_model.rs +5 −0
@@ -57,6 +57,7 @@ pub struct Face {
57 57 pub enum AvatarSpec {
58 58 Single(Face),
59 59 Pair(Face, Face),
60 Meeting,
60 61 }
61 62
62 63 #[derive(Debug, Clone, PartialEq, Eq)]
@@ -139,6 +140,9 @@ pub fn preview_for(chat: &ChatRecord, me: Option<&Person>) -> Preview {
139 140 }
140 141
141 142 pub fn avatar_for(chat: &ChatRecord, me: Option<&Person>) -> AvatarSpec {
143 if chat.kind.eq_ignore_ascii_case("meeting") {
144 return AvatarSpec::Meeting;
145 }
142 146 let faces = face_members(chat, me);
143 147 let face = |(user_id, name): (Option<String>, String)| Face { user_id, name };
144 148 if is_one_on_one(chat) || faces.len() < 2 {
@@ -906,6 +910,7 @@ mod tests {
906 910 let group = chat_item(&chats[1], &context, None);
907 911 assert_eq!(group.presence_user, None);
908 912 assert!(matches!(group.avatar, AvatarSpec::Pair(..)));
913 assert_eq!(avatar_for(&meeting_chat("meeting-1"), None), AvatarSpec::Meeting);
909 914 }
910 915
911 916 #[test]
@@ -57,6 +57,7 @@ pub struct Face {
57pub enum AvatarSpec {
57pub enum AvatarSpec {
58 Single(Face),
58 Single(Face),
59 Pair(Face, Face),
59 Pair(Face, Face),
60 Meeting,
60}
61}
61
62
62#[derive(Debug, Clone, PartialEq, Eq)]
63#[derive(Debug, Clone, PartialEq, Eq)]
@@ -139,6 +140,9 @@ pub fn preview_for(chat: &ChatRecord, me: Option<&Person>) -> Preview {
139}
140}
140
141
141pub fn avatar_for(chat: &ChatRecord, me: Option<&Person>) -> AvatarSpec {
142pub fn avatar_for(chat: &ChatRecord, me: Option<&Person>) -> AvatarSpec {
143 if chat.kind.eq_ignore_ascii_case("meeting") {
144 return AvatarSpec::Meeting;
145 }
142 let faces = face_members(chat, me);
146 let faces = face_members(chat, me);
143 let face = |(user_id, name): (Option<String>, String)| Face { user_id, name };
147 let face = |(user_id, name): (Option<String>, String)| Face { user_id, name };
144 if is_one_on_one(chat) || faces.len() < 2 {
148 if is_one_on_one(chat) || faces.len() < 2 {
@@ -906,6 +910,7 @@ mod tests {
906 let group = chat_item(&chats[1], &context, None);
910 let group = chat_item(&chats[1], &context, None);
907 assert_eq!(group.presence_user, None);
911 assert_eq!(group.presence_user, None);
908 assert!(matches!(group.avatar, AvatarSpec::Pair(..)));
912 assert!(matches!(group.avatar, AvatarSpec::Pair(..)));
913 assert_eq!(avatar_for(&meeting_chat("meeting-1"), None), AvatarSpec::Meeting);
909 }
914 }
910
915
911 #[test]
916 #[test]
crates/app/src/theme.rs +10 −0
@@ -59,6 +59,8 @@ const CLOSE_BUTTON_ICON: u32 = 0xffffff;
59 59 const RED_SOFT: u32 = 0xf87171;
60 60 const RED_TINT: u32 = 0xfca5a5;
61 61 const AMBER: u32 = 0xfbbf24;
62 const OUT_OF_OFFICE: u32 = 0xc239b3;
63 const MEETING_AVATAR: u32 = 0x4f52b2;
62 64 const AVATAR_PALETTE: [u32; 6] = [0x9a4a22, 0x44606e, 0x8a3434, 0x4f6a3c, 0x6a4f7a, 0x2f6b63];
63 65
64 66 pub fn color(hex: u32) -> Hsla {
@@ -321,6 +323,14 @@ pub fn amber() -> Hsla {
321 323 color(AMBER)
322 324 }
323 325
326 pub fn out_of_office() -> Hsla {
327 color(OUT_OF_OFFICE)
328 }
329
330 pub fn meeting_avatar() -> Hsla {
331 color(MEETING_AVATAR)
332 }
333
324 334 pub fn avatar_color(index: usize) -> Hsla {
325 335 color(AVATAR_PALETTE[index % AVATAR_PALETTE.len()])
326 336 }
@@ -59,6 +59,8 @@ const CLOSE_BUTTON_ICON: u32 = 0xffffff;
59const RED_SOFT: u32 = 0xf87171;
59const RED_SOFT: u32 = 0xf87171;
60const RED_TINT: u32 = 0xfca5a5;
60const RED_TINT: u32 = 0xfca5a5;
61const AMBER: u32 = 0xfbbf24;
61const AMBER: u32 = 0xfbbf24;
62const OUT_OF_OFFICE: u32 = 0xc239b3;
63const MEETING_AVATAR: u32 = 0x4f52b2;
62const AVATAR_PALETTE: [u32; 6] = [0x9a4a22, 0x44606e, 0x8a3434, 0x4f6a3c, 0x6a4f7a, 0x2f6b63];
64const AVATAR_PALETTE: [u32; 6] = [0x9a4a22, 0x44606e, 0x8a3434, 0x4f6a3c, 0x6a4f7a, 0x2f6b63];
63
65
64pub fn color(hex: u32) -> Hsla {
66pub fn color(hex: u32) -> Hsla {
@@ -321,6 +323,14 @@ pub fn amber() -> Hsla {
321 color(AMBER)
323 color(AMBER)
322}
324}
323
325
326pub fn out_of_office() -> Hsla {
327 color(OUT_OF_OFFICE)
328}
329
330pub fn meeting_avatar() -> Hsla {
331 color(MEETING_AVATAR)
332}
333
324pub fn avatar_color(index: usize) -> Hsla {
334pub fn avatar_color(index: usize) -> Hsla {
325 color(AVATAR_PALETTE[index % AVATAR_PALETTE.len()])
335 color(AVATAR_PALETTE[index % AVATAR_PALETTE.len()])
326}
336}
crates/app/src/views/avatar.rs +13 −0
@@ -22,6 +22,7 @@ const PRESENCE_SPIN_PERIOD: Duration = Duration::from_millis(1600);
22 22 const CACHED_PRESENCE_OPACITY: f32 = 0.5;
23 23 const INITIALS_RATIO: f32 = 0.36;
24 24 const PAIR_INITIALS_RATIO: f32 = 0.42;
25 const MEETING_ICON_RATIO: f32 = 0.5;
25 26
26 27 fn initials_circle(name: &str, key: &str, size: f32, pending: bool, text_ratio: f32) -> Div {
27 28 let (background, foreground) = if pending {
@@ -125,6 +126,7 @@ pub fn presence_dot(kind: PresenceKind, ring: Hsla, avatar_size: f32) -> Option<
125 126 PresenceKind::Available => theme::green(),
126 127 PresenceKind::Busy | PresenceKind::DoNotDisturb => theme::red(),
127 128 PresenceKind::Away => theme::amber(),
129 PresenceKind::OutOfOffice => theme::out_of_office(),
128 130 PresenceKind::Offline => ring,
129 131 PresenceKind::Unknown => return None,
130 132 };
@@ -140,6 +142,7 @@ pub fn presence_dot(kind: PresenceKind, ring: Hsla, avatar_size: f32) -> Option<
140 142 center.child(div().w(px(inner - 4.)).h(px(2.)).rounded(px(1.)).bg(ring))
141 143 }
142 144 PresenceKind::Offline => center.border(px(1.5)).border_color(theme::text_muted()),
145 PresenceKind::OutOfOffice => center.child(icon(IconName::ArrowLeft, inner - 2., theme::white())),
143 146 _ => center,
144 147 };
145 148 Some(
@@ -186,6 +189,16 @@ pub fn with_presence(avatar: AnyElement, presence: Presence, size: f32, ring: Hs
186 189 pub fn spec_avatar(directory: &Directory, spec: &AvatarSpec, size: f32, ring: Hsla) -> AnyElement {
187 190 match spec {
188 191 AvatarSpec::Single(face) => face_circle(directory, face, size, INITIALS_RATIO),
192 AvatarSpec::Meeting => div()
193 .size(px(size))
194 .flex_none()
195 .rounded_full()
196 .bg(theme::meeting_avatar())
197 .flex()
198 .items_center()
199 .justify_center()
200 .child(icon(IconName::Calendar, (size * MEETING_ICON_RATIO).round(), theme::white()))
201 .into_any_element(),
189 202 AvatarSpec::Pair(first, second) => {
190 203 let small = (size * PAIR_RATIO).round();
191 204 div()
@@ -22,6 +22,7 @@ const PRESENCE_SPIN_PERIOD: Duration = Duration::from_millis(1600);
22const CACHED_PRESENCE_OPACITY: f32 = 0.5;
22const CACHED_PRESENCE_OPACITY: f32 = 0.5;
23const INITIALS_RATIO: f32 = 0.36;
23const INITIALS_RATIO: f32 = 0.36;
24const PAIR_INITIALS_RATIO: f32 = 0.42;
24const PAIR_INITIALS_RATIO: f32 = 0.42;
25const MEETING_ICON_RATIO: f32 = 0.5;
25
26
26fn initials_circle(name: &str, key: &str, size: f32, pending: bool, text_ratio: f32) -> Div {
27fn initials_circle(name: &str, key: &str, size: f32, pending: bool, text_ratio: f32) -> Div {
27 let (background, foreground) = if pending {
28 let (background, foreground) = if pending {
@@ -125,6 +126,7 @@ pub fn presence_dot(kind: PresenceKind, ring: Hsla, avatar_size: f32) -> Option<
125 PresenceKind::Available => theme::green(),
126 PresenceKind::Available => theme::green(),
126 PresenceKind::Busy | PresenceKind::DoNotDisturb => theme::red(),
127 PresenceKind::Busy | PresenceKind::DoNotDisturb => theme::red(),
127 PresenceKind::Away => theme::amber(),
128 PresenceKind::Away => theme::amber(),
129 PresenceKind::OutOfOffice => theme::out_of_office(),
128 PresenceKind::Offline => ring,
130 PresenceKind::Offline => ring,
129 PresenceKind::Unknown => return None,
131 PresenceKind::Unknown => return None,
130 };
132 };
@@ -140,6 +142,7 @@ pub fn presence_dot(kind: PresenceKind, ring: Hsla, avatar_size: f32) -> Option<
140 center.child(div().w(px(inner - 4.)).h(px(2.)).rounded(px(1.)).bg(ring))
142 center.child(div().w(px(inner - 4.)).h(px(2.)).rounded(px(1.)).bg(ring))
141 }
143 }
142 PresenceKind::Offline => center.border(px(1.5)).border_color(theme::text_muted()),
144 PresenceKind::Offline => center.border(px(1.5)).border_color(theme::text_muted()),
145 PresenceKind::OutOfOffice => center.child(icon(IconName::ArrowLeft, inner - 2., theme::white())),
143 _ => center,
146 _ => center,
144 };
147 };
145 Some(
148 Some(
@@ -186,6 +189,16 @@ pub fn with_presence(avatar: AnyElement, presence: Presence, size: f32, ring: Hs
186pub fn spec_avatar(directory: &Directory, spec: &AvatarSpec, size: f32, ring: Hsla) -> AnyElement {
189pub fn spec_avatar(directory: &Directory, spec: &AvatarSpec, size: f32, ring: Hsla) -> AnyElement {
187 match spec {
190 match spec {
188 AvatarSpec::Single(face) => face_circle(directory, face, size, INITIALS_RATIO),
191 AvatarSpec::Single(face) => face_circle(directory, face, size, INITIALS_RATIO),
192 AvatarSpec::Meeting => div()
193 .size(px(size))
194 .flex_none()
195 .rounded_full()
196 .bg(theme::meeting_avatar())
197 .flex()
198 .items_center()
199 .justify_center()
200 .child(icon(IconName::Calendar, (size * MEETING_ICON_RATIO).round(), theme::white()))
201 .into_any_element(),
189 AvatarSpec::Pair(first, second) => {
202 AvatarSpec::Pair(first, second) => {
190 let small = (size * PAIR_RATIO).round();
203 let small = (size * PAIR_RATIO).round();
191 div()
204 div()
crates/app/src/views/sidebar.rs +1 −0
@@ -1716,6 +1716,7 @@ fn collect_faces(spec: &AvatarSpec, faces: &mut Vec<String>) {
1716 1716 faces.extend(first.user_id.clone());
1717 1717 faces.extend(second.user_id.clone());
1718 1718 }
1719 AvatarSpec::Meeting => {}
1719 1720 }
1720 1721 }
1721 1722
@@ -1716,6 +1716,7 @@ fn collect_faces(spec: &AvatarSpec, faces: &mut Vec<String>) {
1716 faces.extend(first.user_id.clone());
1716 faces.extend(first.user_id.clone());
1717 faces.extend(second.user_id.clone());
1717 faces.extend(second.user_id.clone());
1718 }
1718 }
1719 AvatarSpec::Meeting => {}
1719 }
1720 }
1720}
1721}
1721
1722
crates/app/src/views/status_menu.rs +1 −0
@@ -120,6 +120,7 @@ fn status_icon(kind: PresenceKind) -> gpui_kit::component::Icon {
120 120 PresenceKind::Busy => ("status_dot", theme::red()),
121 121 PresenceKind::DoNotDisturb => ("status_dnd", theme::red()),
122 122 PresenceKind::Away => ("status_away", theme::amber()),
123 PresenceKind::OutOfOffice => ("status_dot", theme::out_of_office()),
123 124 PresenceKind::Offline => ("status_ring", theme::text_muted()),
124 125 PresenceKind::Unknown => ("status_ring", theme::text_faint()),
125 126 };
@@ -120,6 +120,7 @@ fn status_icon(kind: PresenceKind) -> gpui_kit::component::Icon {
120 PresenceKind::Busy => ("status_dot", theme::red()),
120 PresenceKind::Busy => ("status_dot", theme::red()),
121 PresenceKind::DoNotDisturb => ("status_dnd", theme::red()),
121 PresenceKind::DoNotDisturb => ("status_dnd", theme::red()),
122 PresenceKind::Away => ("status_away", theme::amber()),
122 PresenceKind::Away => ("status_away", theme::amber()),
123 PresenceKind::OutOfOffice => ("status_dot", theme::out_of_office()),
123 PresenceKind::Offline => ("status_ring", theme::text_muted()),
124 PresenceKind::Offline => ("status_ring", theme::text_muted()),
124 PresenceKind::Unknown => ("status_ring", theme::text_faint()),
125 PresenceKind::Unknown => ("status_ring", theme::text_faint()),
125 };
126 };