BlueGit

ict rusty-teams

fix(presence): idle shows as Away, badges carry the Teams glyphs

- AvailableIdle maps to Away like Teams (was green Available)
- presence badges use the status glyphs: check (available), clock (away), cross (offline), shared with the status menu

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

metis Daniel Däschle · pushed by metis

Authored 2026-11-05 · 3 weeks ago

Hash
3650b05d38c9c99bbc47b3805e2a24eb0dea2cbd
Parent
04ea4893
7 files changed +42 −42
crates/app-base/src/assets.rs +3 −1
@@ -8,7 +8,7 @@ macro_rules! symbols {
8 8 };
9 9 }
10 10
11 const SYMBOLS: [(&str, &[u8]); 73] = symbols![
11 const SYMBOLS: [(&str, &[u8]); 75] = symbols![
12 12 "bot",
13 13 "done",
14 14 "table",
@@ -43,6 +43,8 @@ const SYMBOLS: [(&str, &[u8]); 73] = symbols![
43 43 "status_dnd",
44 44 "status_away",
45 45 "status_ring",
46 "status_available",
47 "status_offline",
46 48 "zoom_in",
47 49 "zoom_out",
48 50 "rotate_right",
@@ -8,7 +8,7 @@ macro_rules! symbols {
8 };
8 };
9}
9}
10
10
11const SYMBOLS: [(&str, &[u8]); 73] = symbols![
11const SYMBOLS: [(&str, &[u8]); 75] = symbols![
12 "bot",
12 "bot",
13 "done",
13 "done",
14 "table",
14 "table",
@@ -43,6 +43,8 @@ const SYMBOLS: [(&str, &[u8]); 73] = symbols![
43 "status_dnd",
43 "status_dnd",
44 "status_away",
44 "status_away",
45 "status_ring",
45 "status_ring",
46 "status_available",
47 "status_offline",
46 "zoom_in",
48 "zoom_in",
47 "zoom_out",
49 "zoom_out",
48 "rotate_right",
50 "rotate_right",
crates/app/assets/symbols/status_available.svg added +1 −0
@@ -0,0 +1 @@
1 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 3a9 9 0 1 0 0 18a9 9 0 0 0 0-18ZM7.4 12.3l1.5-1.5 2 2 4.2-4.2 1.5 1.5-5.7 5.7Z"/></svg>
@@ -0,0 +1 @@
1<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 3a9 9 0 1 0 0 18a9 9 0 0 0 0-18ZM7.4 12.3l1.5-1.5 2 2 4.2-4.2 1.5 1.5-5.7 5.7Z"/></svg>
crates/app/assets/symbols/status_offline.svg added +1 −0
@@ -0,0 +1 @@
1 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 3a9 9 0 1 0 0 18a9 9 0 0 0 0-18ZM12 5.2a6.8 6.8 0 1 1 0 13.6a6.8 6.8 0 0 1 0-13.6Z"/><path d="M9.4 9.4l5.2 5.2M14.6 9.4l-5.2 5.2" fill="none" stroke="#000" stroke-width="2" stroke-linecap="round"/></svg>
@@ -0,0 +1 @@
1<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 3a9 9 0 1 0 0 18a9 9 0 0 0 0-18ZM12 5.2a6.8 6.8 0 1 1 0 13.6a6.8 6.8 0 0 1 0-13.6Z"/><path d="M9.4 9.4l5.2 5.2M14.6 9.4l-5.2 5.2" fill="none" stroke="#000" stroke-width="2" stroke-linecap="round"/></svg>
crates/app/src/layout_guard.rs +0 −5
@@ -2605,11 +2605,6 @@ const OUTLINE_ALLOWLIST: &[(&str, &str, &str)] = &[
2605 2605 "theme::surface()",
2606 2606 "cutout ring in the background color, invisible against its surface",
2607 2607 ),
2608 (
2609 "views/avatar.rs",
2610 "theme::text_muted()",
2611 "offline presence glyph, Teams icon",
2612 ),
2613 2608 (
2614 2609 "views/message_row.rs",
2615 2610 "theme::border_strong()",
@@ -2605,11 +2605,6 @@ const OUTLINE_ALLOWLIST: &[(&str, &str, &str)] = &[
2605 "theme::surface()",
2605 "theme::surface()",
2606 "cutout ring in the background color, invisible against its surface",
2606 "cutout ring in the background color, invisible against its surface",
2607 ),
2607 ),
2608 (
2609 "views/avatar.rs",
2610 "theme::text_muted()",
2611 "offline presence glyph, Teams icon",
2612 ),
2613 (
2608 (
2614 "views/message_row.rs",
2609 "views/message_row.rs",
2615 "theme::border_strong()",
2610 "theme::border_strong()",
crates/app/src/views/avatar.rs +27 −24
@@ -20,6 +20,7 @@ const PRESENCE_MIN: f32 = 10.;
20 20 const PRESENCE_MAX: f32 = 15.;
21 21 const PRESENCE_RATIO: f32 = 0.38;
22 22 const PRESENCE_RING: f32 = 2.;
23 const STATUS_GLYPH_DISC: f32 = 0.75;
23 24 const PRESENCE_SPIN_PERIOD: Duration = Duration::from_millis(1600);
24 25 const CACHED_PRESENCE_OPACITY: f32 = 0.5;
25 26 const INITIALS_RATIO: f32 = 0.36;
@@ -172,32 +173,34 @@ pub fn presence_size(avatar_size: f32) -> f32 {
172 173 .clamp(PRESENCE_MIN, PRESENCE_MAX)
173 174 }
174 175
176 pub fn status_glyph(kind: PresenceKind) -> Option<(&'static str, Hsla)> {
177 Some(match kind {
178 PresenceKind::Available => ("status_available", theme::green()),
179 PresenceKind::Busy => ("status_dot", theme::red()),
180 PresenceKind::DoNotDisturb => ("status_dnd", theme::red()),
181 PresenceKind::Away => ("status_away", theme::amber()),
182 PresenceKind::OutOfOffice => ("status_dot", theme::out_of_office()),
183 PresenceKind::Offline => ("status_offline", theme::text_muted()),
184 PresenceKind::Unknown => return None,
185 })
186 }
187
175 188 fn presence_badge(kind: PresenceKind, ring: Hsla, outer: f32) -> Option<Div> {
176 189 let inner = outer - 2. * PRESENCE_RING;
177 let fill = match kind {
178 PresenceKind::Available => theme::green(),
179 PresenceKind::Busy | PresenceKind::DoNotDisturb => theme::red(),
180 PresenceKind::Away => theme::amber(),
181 PresenceKind::OutOfOffice => theme::out_of_office(),
182 PresenceKind::Offline => ring,
183 PresenceKind::Unknown => return None,
184 };
185 let mut center = div()
186 .size(px(inner))
187 .rounded_full()
188 .bg(fill)
189 .flex()
190 .items_center()
191 .justify_center();
192 center = match kind {
193 PresenceKind::DoNotDisturb => {
194 center.child(div().w(px(inner - 4.)).h(px(2.)).rounded(px(1.)).bg(ring))
195 }
196 PresenceKind::Offline => center.border(px(1.5)).border_color(theme::text_muted()),
197 PresenceKind::OutOfOffice => {
198 center.child(icon(IconName::ArrowLeft, inner - 2., theme::white()))
190 let glyph = match kind {
191 PresenceKind::OutOfOffice => div()
192 .size(px(inner))
193 .rounded_full()
194 .bg(theme::out_of_office())
195 .flex()
196 .items_center()
197 .justify_center()
198 .child(icon(IconName::ArrowLeft, inner - 2., theme::white()))
199 .into_any_element(),
200 _ => {
201 let (name, color) = status_glyph(kind)?;
202 symbol(name, inner / STATUS_GLYPH_DISC, color).into_any_element()
199 203 }
200 _ => center,
201 204 };
202 205 Some(
203 206 corner_badge(Corner::BottomRight, 2.)
@@ -207,7 +210,7 @@ fn presence_badge(kind: PresenceKind, ring: Hsla, outer: f32) -> Option<Div> {
207 210 .flex()
208 211 .items_center()
209 212 .justify_center()
210 .child(center),
213 .child(glyph),
211 214 )
212 215 }
213 216
@@ -20,6 +20,7 @@ const PRESENCE_MIN: f32 = 10.;
20const PRESENCE_MAX: f32 = 15.;
20const PRESENCE_MAX: f32 = 15.;
21const PRESENCE_RATIO: f32 = 0.38;
21const PRESENCE_RATIO: f32 = 0.38;
22const PRESENCE_RING: f32 = 2.;
22const PRESENCE_RING: f32 = 2.;
23const STATUS_GLYPH_DISC: f32 = 0.75;
23const PRESENCE_SPIN_PERIOD: Duration = Duration::from_millis(1600);
24const PRESENCE_SPIN_PERIOD: Duration = Duration::from_millis(1600);
24const CACHED_PRESENCE_OPACITY: f32 = 0.5;
25const CACHED_PRESENCE_OPACITY: f32 = 0.5;
25const INITIALS_RATIO: f32 = 0.36;
26const INITIALS_RATIO: f32 = 0.36;
@@ -172,32 +173,34 @@ pub fn presence_size(avatar_size: f32) -> f32 {
172 .clamp(PRESENCE_MIN, PRESENCE_MAX)
173 .clamp(PRESENCE_MIN, PRESENCE_MAX)
173}
174}
174
175
176pub fn status_glyph(kind: PresenceKind) -> Option<(&'static str, Hsla)> {
177 Some(match kind {
178 PresenceKind::Available => ("status_available", theme::green()),
179 PresenceKind::Busy => ("status_dot", theme::red()),
180 PresenceKind::DoNotDisturb => ("status_dnd", theme::red()),
181 PresenceKind::Away => ("status_away", theme::amber()),
182 PresenceKind::OutOfOffice => ("status_dot", theme::out_of_office()),
183 PresenceKind::Offline => ("status_offline", theme::text_muted()),
184 PresenceKind::Unknown => return None,
185 })
186}
187
175fn presence_badge(kind: PresenceKind, ring: Hsla, outer: f32) -> Option<Div> {
188fn presence_badge(kind: PresenceKind, ring: Hsla, outer: f32) -> Option<Div> {
176 let inner = outer - 2. * PRESENCE_RING;
189 let inner = outer - 2. * PRESENCE_RING;
177 let fill = match kind {
190 let glyph = match kind {
178 PresenceKind::Available => theme::green(),
191 PresenceKind::OutOfOffice => div()
179 PresenceKind::Busy | PresenceKind::DoNotDisturb => theme::red(),
192 .size(px(inner))
180 PresenceKind::Away => theme::amber(),
193 .rounded_full()
181 PresenceKind::OutOfOffice => theme::out_of_office(),
194 .bg(theme::out_of_office())
182 PresenceKind::Offline => ring,
195 .flex()
183 PresenceKind::Unknown => return None,
196 .items_center()
184 };
197 .justify_center()
185 let mut center = div()
198 .child(icon(IconName::ArrowLeft, inner - 2., theme::white()))
186 .size(px(inner))
199 .into_any_element(),
187 .rounded_full()
200 _ => {
188 .bg(fill)
201 let (name, color) = status_glyph(kind)?;
189 .flex()
202 symbol(name, inner / STATUS_GLYPH_DISC, color).into_any_element()
190 .items_center()
191 .justify_center();
192 center = match kind {
193 PresenceKind::DoNotDisturb => {
194 center.child(div().w(px(inner - 4.)).h(px(2.)).rounded(px(1.)).bg(ring))
195 }
196 PresenceKind::Offline => center.border(px(1.5)).border_color(theme::text_muted()),
197 PresenceKind::OutOfOffice => {
198 center.child(icon(IconName::ArrowLeft, inner - 2., theme::white()))
199 }
203 }
200 _ => center,
201 };
204 };
202 Some(
205 Some(
203 corner_badge(Corner::BottomRight, 2.)
206 corner_badge(Corner::BottomRight, 2.)
@@ -207,7 +210,7 @@ fn presence_badge(kind: PresenceKind, ring: Hsla, outer: f32) -> Option<Div> {
207 .flex()
210 .flex()
208 .items_center()
211 .items_center()
209 .justify_center()
212 .justify_center()
210 .child(center),
213 .child(glyph),
211 )
214 )
212}
215}
213
216
crates/app/src/views/status_menu.rs +2 −10
@@ -10,7 +10,7 @@ use gpui_kit::component::{
10 10 use gpui_kit::*;
11 11 use teams_core::{ForcedAvailability, ForcedKind, PresenceStatus, WorkLocationKind};
12 12
13 use super::avatar::{person_avatar, with_presence, with_presence_badge};
13 use super::avatar::{person_avatar, status_glyph, with_presence, with_presence_badge};
14 14 use super::widgets::{menu_icon, symbol};
15 15 use crate::app_state::AppState;
16 16 use crate::data::{Person, PresenceKind};
@@ -109,15 +109,7 @@ fn version_tooltip() -> String {
109 109 }
110 110
111 111 fn status_icon(kind: PresenceKind) -> gpui_kit::component::Icon {
112 let (name, color) = match kind {
113 PresenceKind::Available => ("status_dot", theme::green()),
114 PresenceKind::Busy => ("status_dot", theme::red()),
115 PresenceKind::DoNotDisturb => ("status_dnd", theme::red()),
116 PresenceKind::Away => ("status_away", theme::amber()),
117 PresenceKind::OutOfOffice => ("status_dot", theme::out_of_office()),
118 PresenceKind::Offline => ("status_ring", theme::text_muted()),
119 PresenceKind::Unknown => ("status_ring", theme::text_faint()),
120 };
112 let (name, color) = status_glyph(kind).unwrap_or(("status_ring", theme::text_faint()));
121 113 symbol(name, PRESENCE_ICON_SIZE, color)
122 114 }
123 115
@@ -10,7 +10,7 @@ use gpui_kit::component::{
10use gpui_kit::*;
10use gpui_kit::*;
11use teams_core::{ForcedAvailability, ForcedKind, PresenceStatus, WorkLocationKind};
11use teams_core::{ForcedAvailability, ForcedKind, PresenceStatus, WorkLocationKind};
12
12
13use super::avatar::{person_avatar, with_presence, with_presence_badge};
13use super::avatar::{person_avatar, status_glyph, with_presence, with_presence_badge};
14use super::widgets::{menu_icon, symbol};
14use super::widgets::{menu_icon, symbol};
15use crate::app_state::AppState;
15use crate::app_state::AppState;
16use crate::data::{Person, PresenceKind};
16use crate::data::{Person, PresenceKind};
@@ -109,15 +109,7 @@ fn version_tooltip() -> String {
109}
109}
110
110
111fn status_icon(kind: PresenceKind) -> gpui_kit::component::Icon {
111fn status_icon(kind: PresenceKind) -> gpui_kit::component::Icon {
112 let (name, color) = match kind {
112 let (name, color) = status_glyph(kind).unwrap_or(("status_ring", theme::text_faint()));
113 PresenceKind::Available => ("status_dot", theme::green()),
114 PresenceKind::Busy => ("status_dot", theme::red()),
115 PresenceKind::DoNotDisturb => ("status_dnd", theme::red()),
116 PresenceKind::Away => ("status_away", theme::amber()),
117 PresenceKind::OutOfOffice => ("status_dot", theme::out_of_office()),
118 PresenceKind::Offline => ("status_ring", theme::text_muted()),
119 PresenceKind::Unknown => ("status_ring", theme::text_faint()),
120 };
121 symbol(name, PRESENCE_ICON_SIZE, color)
113 symbol(name, PRESENCE_ICON_SIZE, color)
122}
114}
123
115
crates/core/src/presence.rs +8 −2
@@ -25,10 +25,10 @@ pub enum Availability {
25 25 impl Availability {
26 26 pub fn from_service(name: &str) -> Self {
27 27 match name {
28 "Available" | "AvailableIdle" => Availability::Available,
28 "Available" => Availability::Available,
29 29 "Busy" | "BusyIdle" => Availability::Busy,
30 30 "DoNotDisturb" => Availability::DoNotDisturb,
31 "Away" | "BeRightBack" => Availability::Away,
31 "Away" | "BeRightBack" | "AvailableIdle" => Availability::Away,
32 32 "Offline" => Availability::Offline,
33 33 _ => Availability::Unknown,
34 34 }
@@ -243,6 +243,12 @@ impl<R: Remote> SyncEngine<R> {
243 243 mod tests {
244 244 use super::*;
245 245
246 #[test]
247 fn idle_available_shows_as_away_like_teams() {
248 assert_eq!(Availability::from_service("AvailableIdle"), Availability::Away);
249 assert_eq!(Availability::from_service("BusyIdle"), Availability::Busy);
250 }
251
246 252 #[test]
247 253 fn activity_names_map_and_unknown_is_none() {
248 254 assert_eq!(Activity::from_service("InACall"), Some(Activity::InACall));
@@ -25,10 +25,10 @@ pub enum Availability {
25impl Availability {
25impl Availability {
26 pub fn from_service(name: &str) -> Self {
26 pub fn from_service(name: &str) -> Self {
27 match name {
27 match name {
28 "Available" | "AvailableIdle" => Availability::Available,
28 "Available" => Availability::Available,
29 "Busy" | "BusyIdle" => Availability::Busy,
29 "Busy" | "BusyIdle" => Availability::Busy,
30 "DoNotDisturb" => Availability::DoNotDisturb,
30 "DoNotDisturb" => Availability::DoNotDisturb,
31 "Away" | "BeRightBack" => Availability::Away,
31 "Away" | "BeRightBack" | "AvailableIdle" => Availability::Away,
32 "Offline" => Availability::Offline,
32 "Offline" => Availability::Offline,
33 _ => Availability::Unknown,
33 _ => Availability::Unknown,
34 }
34 }
@@ -243,6 +243,12 @@ impl<R: Remote> SyncEngine<R> {
243mod tests {
243mod tests {
244 use super::*;
244 use super::*;
245
245
246 #[test]
247 fn idle_available_shows_as_away_like_teams() {
248 assert_eq!(Availability::from_service("AvailableIdle"), Availability::Away);
249 assert_eq!(Availability::from_service("BusyIdle"), Availability::Busy);
250 }
251
246 #[test]
252 #[test]
247 fn activity_names_map_and_unknown_is_none() {
253 fn activity_names_map_and_unknown_is_none() {
248 assert_eq!(Activity::from_service("InACall"), Some(Activity::InACall));
254 assert_eq!(Activity::from_service("InACall"), Some(Activity::InACall));