BlueGit

ict rusty-teams

feat(activity): Meeting Recaps rows show the Teams title and meeting time

- activity keeps templateParameters and the location DateTimeRange
- app templates for the recap types fill "Recap ready: {subject}"
- third row line with the meeting time in local time
- demo feed has a recap row

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
101d371b586ed919d031bd629687142208790d6a
Parent
d2d1b149
5 files changed +168 −4
crates/app-state/src/activity/feed.rs +2 −0
@@ -160,6 +160,8 @@ pub struct Entry {
160 160 pub source_label: Option<String>,
161 161 pub link: Option<String>,
162 162 pub reply_id: Option<String>,
163 pub title: Option<String>,
164 pub event_range: Option<(DateTime<Utc>, DateTime<Utc>)>,
163 165 }
164 166
165 167 impl Entry {
@@ -160,6 +160,8 @@ pub struct Entry {
160 pub source_label: Option<String>,
160 pub source_label: Option<String>,
161 pub link: Option<String>,
161 pub link: Option<String>,
162 pub reply_id: Option<String>,
162 pub reply_id: Option<String>,
163 pub title: Option<String>,
164 pub event_range: Option<(DateTime<Utc>, DateTime<Utc>)>,
163}
165}
164
166
165impl Entry {
167impl Entry {
crates/app-state/src/activity/server.rs +48 −0
@@ -6,6 +6,12 @@ use crate::rows::reaction_glyph;
6 6
7 7 const ORG_USER_PREFIX: &str = "8:orgid:";
8 8 const CHANNEL_THREAD_TYPES: [&str; 2] = ["topic", "space"];
9 const APP_TEMPLATES: [(&str, &str); 4] = [
10 ("recapIsReady", "Meeting recap is ready"),
11 ("recapIsReadyForFollowedMeetings", "Meeting recap is ready"),
12 ("recapIsReadyV2", "Recap ready: {subject}"),
13 ("recapIsReadyForFollowedMeetingsV2", "Recap ready: {subject}"),
14 ];
9 15
10 16 pub fn feed_of(snapshot: &ActivitySnapshot, seen_locally_ms: i64) -> Feed {
11 17 Feed::new(
@@ -60,9 +66,35 @@ fn entry_of(item: &ActivityItem) -> Entry {
60 66 source_label: item.source_app_name.clone().or_else(|| item.thread_topic.clone()),
61 67 link: item.tap_url.clone(),
62 68 reply_id: channel_reply(item, kind),
69 title: app_title(item),
70 event_range: item
71 .event_start_ms
72 .zip(item.event_end_ms)
73 .and_then(|(start_ms, end_ms)| {
74 Some((
75 DateTime::from_timestamp_millis(start_ms)?,
76 DateTime::from_timestamp_millis(end_ms)?,
77 ))
78 }),
63 79 }
64 80 }
65 81
82 fn app_title(item: &ActivityItem) -> Option<String> {
83 let (_, template) = APP_TEMPLATES
84 .iter()
85 .find(|(subtype, _)| *subtype == item.activity_subtype)?;
86 let mut title = String::new();
87 let mut rest = *template;
88 while let Some(open) = rest.find('{') {
89 let close = open + rest[open..].find('}')?;
90 title.push_str(&rest[..open]);
91 title.push_str(item.template_parameters.get(&rest[open + 1..close])?.trim());
92 rest = &rest[close + 1..];
93 }
94 title.push_str(rest);
95 Some(title.trim().to_owned())
96 }
97
66 98 pub fn kind_of(item: &ActivityItem) -> Kind {
67 99 match item.activity_type.as_str() {
68 100 "mention" | "mentionInChat" | "mentionInCommunity" | "mentionInSubCommunity"
@@ -144,6 +176,22 @@ mod tests {
144 176 }
145 177 }
146 178
179 #[test]
180 fn a_recap_activity_gets_the_app_title_and_meeting_time() {
181 let mut recap = item("msGraph", "recapIsReadyForFollowedMeetingsV2");
182 recap
183 .template_parameters
184 .insert("subject".into(), "Following: Sprint {Demo} ".into());
185 recap.event_start_ms = Some(1793865600000);
186 recap.event_end_ms = Some(1793869200000);
187 let entry = entry_of(&recap);
188 assert_eq!(entry.title.as_deref(), Some("Recap ready: Following: Sprint {Demo}"));
189 let (start, end) = entry.event_range.unwrap();
190 assert_eq!((end - start).num_minutes(), 60);
191 assert_eq!(entry_of(&item("msGraph", "recapIsReadyV2")).title, None);
192 assert_eq!(entry_of(&item("msGraph", "somethingElse")).title, None);
193 }
194
147 195 #[test]
148 196 fn maps_the_teams_activity_types() {
149 197 let cases = [
@@ -6,6 +6,12 @@ use crate::rows::reaction_glyph;
6
6
7const ORG_USER_PREFIX: &str = "8:orgid:";
7const ORG_USER_PREFIX: &str = "8:orgid:";
8const CHANNEL_THREAD_TYPES: [&str; 2] = ["topic", "space"];
8const CHANNEL_THREAD_TYPES: [&str; 2] = ["topic", "space"];
9const APP_TEMPLATES: [(&str, &str); 4] = [
10 ("recapIsReady", "Meeting recap is ready"),
11 ("recapIsReadyForFollowedMeetings", "Meeting recap is ready"),
12 ("recapIsReadyV2", "Recap ready: {subject}"),
13 ("recapIsReadyForFollowedMeetingsV2", "Recap ready: {subject}"),
14];
9
15
10pub fn feed_of(snapshot: &ActivitySnapshot, seen_locally_ms: i64) -> Feed {
16pub fn feed_of(snapshot: &ActivitySnapshot, seen_locally_ms: i64) -> Feed {
11 Feed::new(
17 Feed::new(
@@ -60,9 +66,35 @@ fn entry_of(item: &ActivityItem) -> Entry {
60 source_label: item.source_app_name.clone().or_else(|| item.thread_topic.clone()),
66 source_label: item.source_app_name.clone().or_else(|| item.thread_topic.clone()),
61 link: item.tap_url.clone(),
67 link: item.tap_url.clone(),
62 reply_id: channel_reply(item, kind),
68 reply_id: channel_reply(item, kind),
69 title: app_title(item),
70 event_range: item
71 .event_start_ms
72 .zip(item.event_end_ms)
73 .and_then(|(start_ms, end_ms)| {
74 Some((
75 DateTime::from_timestamp_millis(start_ms)?,
76 DateTime::from_timestamp_millis(end_ms)?,
77 ))
78 }),
63 }
79 }
64}
80}
65
81
82fn app_title(item: &ActivityItem) -> Option<String> {
83 let (_, template) = APP_TEMPLATES
84 .iter()
85 .find(|(subtype, _)| *subtype == item.activity_subtype)?;
86 let mut title = String::new();
87 let mut rest = *template;
88 while let Some(open) = rest.find('{') {
89 let close = open + rest[open..].find('}')?;
90 title.push_str(&rest[..open]);
91 title.push_str(item.template_parameters.get(&rest[open + 1..close])?.trim());
92 rest = &rest[close + 1..];
93 }
94 title.push_str(rest);
95 Some(title.trim().to_owned())
96}
97
66pub fn kind_of(item: &ActivityItem) -> Kind {
98pub fn kind_of(item: &ActivityItem) -> Kind {
67 match item.activity_type.as_str() {
99 match item.activity_type.as_str() {
68 "mention" | "mentionInChat" | "mentionInCommunity" | "mentionInSubCommunity"
100 "mention" | "mentionInChat" | "mentionInCommunity" | "mentionInSubCommunity"
@@ -144,6 +176,22 @@ mod tests {
144 }
176 }
145 }
177 }
146
178
179 #[test]
180 fn a_recap_activity_gets_the_app_title_and_meeting_time() {
181 let mut recap = item("msGraph", "recapIsReadyForFollowedMeetingsV2");
182 recap
183 .template_parameters
184 .insert("subject".into(), "Following: Sprint {Demo} ".into());
185 recap.event_start_ms = Some(1793865600000);
186 recap.event_end_ms = Some(1793869200000);
187 let entry = entry_of(&recap);
188 assert_eq!(entry.title.as_deref(), Some("Recap ready: Following: Sprint {Demo}"));
189 let (start, end) = entry.event_range.unwrap();
190 assert_eq!((end - start).num_minutes(), 60);
191 assert_eq!(entry_of(&item("msGraph", "recapIsReadyV2")).title, None);
192 assert_eq!(entry_of(&item("msGraph", "somethingElse")).title, None);
193 }
194
147 #[test]
195 #[test]
148 fn maps_the_teams_activity_types() {
196 fn maps_the_teams_activity_types() {
149 let cases = [
197 let cases = [
crates/app-state/src/demo.rs +23 −0
@@ -805,6 +805,29 @@ pub fn activity_snapshot() -> ActivitySnapshot {
805 805 at(1, 16, 0),
806 806 true,
807 807 ),
808 ActivityItem {
809 source_thread_id: String::new(),
810 source_message_id: Some("1".to_owned()),
811 source_reply_chain_id: None,
812 source_user_id: None,
813 source_app_name: Some("Meeting Recaps".to_owned()),
814 preview_template: "previewUnavailable".to_owned(),
815 template_parameters: [("subject".to_owned(), "Following: Sprint Review ".to_owned())].into(),
816 event_start_ms: Some(at(1, 10, 0).timestamp_millis()),
817 event_end_ms: Some(at(1, 11, 0).timestamp_millis()),
818 ..item(
819 "demo-activity-7",
820 "msGraph",
821 "recapIsReadyForFollowedMeetingsV2",
822 "",
823 "",
824 "",
825 ("", "Meeting Recaps"),
826 "You're following this meeting",
827 at(1, 11, 30),
828 true,
829 )
830 },
808 831 ];
809 832 ActivitySnapshot {
810 833 items,
@@ -805,6 +805,29 @@ pub fn activity_snapshot() -> ActivitySnapshot {
805 at(1, 16, 0),
805 at(1, 16, 0),
806 true,
806 true,
807 ),
807 ),
808 ActivityItem {
809 source_thread_id: String::new(),
810 source_message_id: Some("1".to_owned()),
811 source_reply_chain_id: None,
812 source_user_id: None,
813 source_app_name: Some("Meeting Recaps".to_owned()),
814 preview_template: "previewUnavailable".to_owned(),
815 template_parameters: [("subject".to_owned(), "Following: Sprint Review ".to_owned())].into(),
816 event_start_ms: Some(at(1, 10, 0).timestamp_millis()),
817 event_end_ms: Some(at(1, 11, 0).timestamp_millis()),
818 ..item(
819 "demo-activity-7",
820 "msGraph",
821 "recapIsReadyForFollowedMeetingsV2",
822 "",
823 "",
824 "",
825 ("", "Meeting Recaps"),
826 "You're following this meeting",
827 at(1, 11, 30),
828 true,
829 )
830 },
808 ];
831 ];
809 ActivitySnapshot {
832 ActivitySnapshot {
810 items,
833 items,
crates/app/src/views/activity_panel.rs +46 −4
@@ -2,7 +2,7 @@ use std::collections::{HashMap, HashSet};
2 2 use std::ops::Range;
3 3 use std::rc::Rc;
4 4
5 use chrono::{DateTime, Local, NaiveDate, Offset};
5 use chrono::{DateTime, Local, NaiveDate, Offset, TimeZone, Utc};
6 6 use gpui_kit::assets::IconName;
7 7 use gpui_kit::component::{h_flex, tooltip::Tooltip, v_flex};
8 8 use gpui_kit::prelude::FluentBuilder as _;
@@ -30,6 +30,7 @@ const KIND_MARKER_SIZE: f32 = 16.;
30 30 const BUTTON_SIZE: f32 = 32.;
31 31 const MARK_READ_SIZE: f32 = 20.;
32 32 const ROW_HEIGHT: f32 = 58.;
33 const EVENT_LINE_HEIGHT: f32 = 16.;
33 34 const HEADER_HEIGHT: f32 = 30.;
34 35 const EMPTY_HEIGHT: f32 = 84.;
35 36 const FALLBACK_VIEWPORT: f32 = 900.;
@@ -279,6 +280,9 @@ impl ActivityPanel {
279 280 group,
280 281 headline: headline(entry, sidebar, &self.resolved_names),
281 282 detail: detail(entry),
283 event_line: entry
284 .event_range
285 .map(|(start, end)| event_line(start, end, &Local)),
282 286 unread: !entry.read,
283 287 time: format::list_time_label(entry.updated_at, today, offset),
284 288 mark_read: Rc::new({
@@ -309,6 +313,7 @@ impl ActivityPanel {
309 313 group,
310 314 headline: pending.headline(label.as_deref()),
311 315 detail: pending.detail(),
316 event_line: None,
312 317 unread: !pending.seen,
313 318 time: format::list_time_label(pending.created_at, today, offset),
314 319 mark_read: Rc::new(move |cx: &mut App| agent_api::mark_proposal_seen(&proposal_id, cx)),
@@ -334,6 +339,7 @@ struct RowParts {
334 339 marker: Div,
335 340 headline: String,
336 341 detail: String,
342 event_line: Option<String>,
337 343 unread: bool,
338 344 time: String,
339 345 mark_read: MarkRead,
@@ -349,16 +355,18 @@ fn row_frame(parts: RowParts) -> Stateful<Div> {
349 355 marker,
350 356 headline,
351 357 detail,
358 event_line,
352 359 unread,
353 360 time,
354 361 mark_read,
355 362 } = parts;
363 let height = ROW_HEIGHT + event_line.as_ref().map_or(0., |_| EVENT_LINE_HEIGHT);
356 364 let selector = element_id.clone();
357 365 h_flex()
358 366 .id(ElementId::Name(element_id.clone().into()))
359 367 .debug_selector(move || selector)
360 368 .group(group.clone())
361 .h(px(ROW_HEIGHT))
369 .h(px(height))
362 370 .flex_none()
363 371 .mx(px(6.))
364 372 .px(px(10.))
@@ -407,7 +415,14 @@ fn row_frame(parts: RowParts) -> Stateful<Div> {
407 415 theme::text_muted()
408 416 })
409 417 .child(detail),
410 ),
418 )
419 .children(event_line.map(|line| {
420 div()
421 .truncate()
422 .text_size(px(12.))
423 .text_color(theme::text_muted())
424 .child(line)
425 })),
411 426 )
412 427 .child(
413 428 v_flex()
@@ -569,7 +584,10 @@ fn headline(entry: &Entry, sidebar: &Sidebar, resolved_names: &HashMap<String, S
569 584 (Kind::Team, _) => {
570 585 return format!("{actor} added you to {}", team_label(entry, channel));
571 586 }
572 (Kind::App, _) => entry.source_label.clone().unwrap_or(actor),
587 (Kind::App, _) => match &entry.title {
588 Some(title) => return title.clone(),
589 None => entry.source_label.clone().unwrap_or(actor),
590 },
573 591 (Kind::Other, _) => actor,
574 592 };
575 593 match conversation_label(sidebar, &entry.conversation_id) {
@@ -578,6 +596,19 @@ fn headline(entry: &Entry, sidebar: &Sidebar, resolved_names: &HashMap<String, S
578 596 }
579 597 }
580 598
599 fn event_line<Zone: TimeZone>(start: DateTime<Utc>, end: DateTime<Utc>, zone: &Zone) -> String
600 where
601 Zone::Offset: std::fmt::Display,
602 {
603 let (start, end) = (start.with_timezone(zone), end.with_timezone(zone));
604 let end_format = if end.date_naive() == start.date_naive() {
605 "%H:%M"
606 } else {
607 "%b %-d, %H:%M"
608 };
609 format!("{} - {}", start.format("%b %-d, %H:%M"), end.format(end_format))
610 }
611
581 612 fn reply_headline(entry: &Entry, names: &str) -> String {
582 613 match entry.activity_type.as_str() {
583 614 "reply" => format!("{names} replied to your post"),
@@ -650,6 +681,7 @@ impl Slot<'_> {
650 681 match self {
651 682 Slot::Proposals(proposals) => HEADER_HEIGHT + proposals.len() as f32 * ROW_HEIGHT,
652 683 Slot::Header(_) => HEADER_HEIGHT,
684 Slot::Row(entry) if entry.event_range.is_some() => ROW_HEIGHT + EVENT_LINE_HEIGHT,
653 685 Slot::Row(_) => ROW_HEIGHT,
654 686 Slot::Empty => EMPTY_HEIGHT,
655 687 }
@@ -873,6 +905,16 @@ mod tests {
873 905 assert_eq!(detail(&entry(Kind::Reply, 2)), "hello");
874 906 }
875 907
908 #[test]
909 fn event_line_shows_the_meeting_time_in_local_time() {
910 let start = chrono::DateTime::from_timestamp_millis(1793865600000).unwrap();
911 let end = chrono::DateTime::from_timestamp_millis(1793869200000).unwrap();
912 let berlin = chrono::FixedOffset::east_opt(3600).unwrap();
913 assert_eq!(super::event_line(start, end, &berlin), "Nov 5, 09:00 - 10:00");
914 let next_day = chrono::DateTime::from_timestamp_millis(1793955600000).unwrap();
915 assert_eq!(super::event_line(start, next_day, &berlin), "Nov 5, 09:00 - Nov 6, 10:00");
916 }
917
876 918 #[test]
877 919 fn headline_uses_the_teams_activity_texts() {
878 920 let sidebar = Sidebar {
@@ -2,7 +2,7 @@ use std::collections::{HashMap, HashSet};
2use std::ops::Range;
2use std::ops::Range;
3use std::rc::Rc;
3use std::rc::Rc;
4
4
5use chrono::{DateTime, Local, NaiveDate, Offset};
5use chrono::{DateTime, Local, NaiveDate, Offset, TimeZone, Utc};
6use gpui_kit::assets::IconName;
6use gpui_kit::assets::IconName;
7use gpui_kit::component::{h_flex, tooltip::Tooltip, v_flex};
7use gpui_kit::component::{h_flex, tooltip::Tooltip, v_flex};
8use gpui_kit::prelude::FluentBuilder as _;
8use gpui_kit::prelude::FluentBuilder as _;
@@ -30,6 +30,7 @@ const KIND_MARKER_SIZE: f32 = 16.;
30const BUTTON_SIZE: f32 = 32.;
30const BUTTON_SIZE: f32 = 32.;
31const MARK_READ_SIZE: f32 = 20.;
31const MARK_READ_SIZE: f32 = 20.;
32const ROW_HEIGHT: f32 = 58.;
32const ROW_HEIGHT: f32 = 58.;
33const EVENT_LINE_HEIGHT: f32 = 16.;
33const HEADER_HEIGHT: f32 = 30.;
34const HEADER_HEIGHT: f32 = 30.;
34const EMPTY_HEIGHT: f32 = 84.;
35const EMPTY_HEIGHT: f32 = 84.;
35const FALLBACK_VIEWPORT: f32 = 900.;
36const FALLBACK_VIEWPORT: f32 = 900.;
@@ -279,6 +280,9 @@ impl ActivityPanel {
279 group,
280 group,
280 headline: headline(entry, sidebar, &self.resolved_names),
281 headline: headline(entry, sidebar, &self.resolved_names),
281 detail: detail(entry),
282 detail: detail(entry),
283 event_line: entry
284 .event_range
285 .map(|(start, end)| event_line(start, end, &Local)),
282 unread: !entry.read,
286 unread: !entry.read,
283 time: format::list_time_label(entry.updated_at, today, offset),
287 time: format::list_time_label(entry.updated_at, today, offset),
284 mark_read: Rc::new({
288 mark_read: Rc::new({
@@ -309,6 +313,7 @@ impl ActivityPanel {
309 group,
313 group,
310 headline: pending.headline(label.as_deref()),
314 headline: pending.headline(label.as_deref()),
311 detail: pending.detail(),
315 detail: pending.detail(),
316 event_line: None,
312 unread: !pending.seen,
317 unread: !pending.seen,
313 time: format::list_time_label(pending.created_at, today, offset),
318 time: format::list_time_label(pending.created_at, today, offset),
314 mark_read: Rc::new(move |cx: &mut App| agent_api::mark_proposal_seen(&proposal_id, cx)),
319 mark_read: Rc::new(move |cx: &mut App| agent_api::mark_proposal_seen(&proposal_id, cx)),
@@ -334,6 +339,7 @@ struct RowParts {
334 marker: Div,
339 marker: Div,
335 headline: String,
340 headline: String,
336 detail: String,
341 detail: String,
342 event_line: Option<String>,
337 unread: bool,
343 unread: bool,
338 time: String,
344 time: String,
339 mark_read: MarkRead,
345 mark_read: MarkRead,
@@ -349,16 +355,18 @@ fn row_frame(parts: RowParts) -> Stateful<Div> {
349 marker,
355 marker,
350 headline,
356 headline,
351 detail,
357 detail,
358 event_line,
352 unread,
359 unread,
353 time,
360 time,
354 mark_read,
361 mark_read,
355 } = parts;
362 } = parts;
363 let height = ROW_HEIGHT + event_line.as_ref().map_or(0., |_| EVENT_LINE_HEIGHT);
356 let selector = element_id.clone();
364 let selector = element_id.clone();
357 h_flex()
365 h_flex()
358 .id(ElementId::Name(element_id.clone().into()))
366 .id(ElementId::Name(element_id.clone().into()))
359 .debug_selector(move || selector)
367 .debug_selector(move || selector)
360 .group(group.clone())
368 .group(group.clone())
361 .h(px(ROW_HEIGHT))
369 .h(px(height))
362 .flex_none()
370 .flex_none()
363 .mx(px(6.))
371 .mx(px(6.))
364 .px(px(10.))
372 .px(px(10.))
@@ -407,7 +415,14 @@ fn row_frame(parts: RowParts) -> Stateful<Div> {
407 theme::text_muted()
415 theme::text_muted()
408 })
416 })
409 .child(detail),
417 .child(detail),
410 ),
418 )
419 .children(event_line.map(|line| {
420 div()
421 .truncate()
422 .text_size(px(12.))
423 .text_color(theme::text_muted())
424 .child(line)
425 })),
411 )
426 )
412 .child(
427 .child(
413 v_flex()
428 v_flex()
@@ -569,7 +584,10 @@ fn headline(entry: &Entry, sidebar: &Sidebar, resolved_names: &HashMap<String, S
569 (Kind::Team, _) => {
584 (Kind::Team, _) => {
570 return format!("{actor} added you to {}", team_label(entry, channel));
585 return format!("{actor} added you to {}", team_label(entry, channel));
571 }
586 }
572 (Kind::App, _) => entry.source_label.clone().unwrap_or(actor),
587 (Kind::App, _) => match &entry.title {
588 Some(title) => return title.clone(),
589 None => entry.source_label.clone().unwrap_or(actor),
590 },
573 (Kind::Other, _) => actor,
591 (Kind::Other, _) => actor,
574 };
592 };
575 match conversation_label(sidebar, &entry.conversation_id) {
593 match conversation_label(sidebar, &entry.conversation_id) {
@@ -578,6 +596,19 @@ fn headline(entry: &Entry, sidebar: &Sidebar, resolved_names: &HashMap<String, S
578 }
596 }
579}
597}
580
598
599fn event_line<Zone: TimeZone>(start: DateTime<Utc>, end: DateTime<Utc>, zone: &Zone) -> String
600where
601 Zone::Offset: std::fmt::Display,
602{
603 let (start, end) = (start.with_timezone(zone), end.with_timezone(zone));
604 let end_format = if end.date_naive() == start.date_naive() {
605 "%H:%M"
606 } else {
607 "%b %-d, %H:%M"
608 };
609 format!("{} - {}", start.format("%b %-d, %H:%M"), end.format(end_format))
610}
611
581fn reply_headline(entry: &Entry, names: &str) -> String {
612fn reply_headline(entry: &Entry, names: &str) -> String {
582 match entry.activity_type.as_str() {
613 match entry.activity_type.as_str() {
583 "reply" => format!("{names} replied to your post"),
614 "reply" => format!("{names} replied to your post"),
@@ -650,6 +681,7 @@ impl Slot<'_> {
650 match self {
681 match self {
651 Slot::Proposals(proposals) => HEADER_HEIGHT + proposals.len() as f32 * ROW_HEIGHT,
682 Slot::Proposals(proposals) => HEADER_HEIGHT + proposals.len() as f32 * ROW_HEIGHT,
652 Slot::Header(_) => HEADER_HEIGHT,
683 Slot::Header(_) => HEADER_HEIGHT,
684 Slot::Row(entry) if entry.event_range.is_some() => ROW_HEIGHT + EVENT_LINE_HEIGHT,
653 Slot::Row(_) => ROW_HEIGHT,
685 Slot::Row(_) => ROW_HEIGHT,
654 Slot::Empty => EMPTY_HEIGHT,
686 Slot::Empty => EMPTY_HEIGHT,
655 }
687 }
@@ -873,6 +905,16 @@ mod tests {
873 assert_eq!(detail(&entry(Kind::Reply, 2)), "hello");
905 assert_eq!(detail(&entry(Kind::Reply, 2)), "hello");
874 }
906 }
875
907
908 #[test]
909 fn event_line_shows_the_meeting_time_in_local_time() {
910 let start = chrono::DateTime::from_timestamp_millis(1793865600000).unwrap();
911 let end = chrono::DateTime::from_timestamp_millis(1793869200000).unwrap();
912 let berlin = chrono::FixedOffset::east_opt(3600).unwrap();
913 assert_eq!(super::event_line(start, end, &berlin), "Nov 5, 09:00 - 10:00");
914 let next_day = chrono::DateTime::from_timestamp_millis(1793955600000).unwrap();
915 assert_eq!(super::event_line(start, next_day, &berlin), "Nov 5, 09:00 - Nov 6, 10:00");
916 }
917
876 #[test]
918 #[test]
877 fn headline_uses_the_teams_activity_texts() {
919 fn headline_uses_the_teams_activity_texts() {
878 let sidebar = Sidebar {
920 let sidebar = Sidebar {
crates/chatsvc/src/activity_feed.rs +49 −0
@@ -1,3 +1,5 @@
1 use std::collections::BTreeMap;
2
1 3 use chrono::DateTime;
2 4 use serde::{Deserialize, Serialize};
3 5 use serde_json::{Value, json};
@@ -38,6 +40,10 @@ pub struct ActivityItem {
38 40 pub read_flag: bool,
39 41 pub tap_url: Option<String>,
40 42 pub meeting_thread_id: Option<String>,
43 #[serde(default)]
44 pub template_parameters: BTreeMap<String, String>,
45 pub event_start_ms: Option<i64>,
46 pub event_end_ms: Option<i64>,
41 47 }
42 48
43 49 /// `seen_ms`: the bell horizon (`consumptionhorizon`), `bookmark_ms`: Mark all as read (`consumptionHorizonBookmark`).
@@ -201,6 +207,11 @@ fn activity_item(message: &Value) -> Option<ActivityItem> {
201 207 }
202 208 let activity = object_property(properties, "activity")?;
203 209 let text = |key: &str| activity.get(key).and_then(text_of);
210 let context = activity.get("activityContext");
211 let location = context
212 .and_then(|context| object_property(context, "location"))
213 .and_then(|location| location.get("Custom").and_then(Value::as_str).map(str::to_owned))
214 .unwrap_or_default();
204 215 let message_id = message.get("id").and_then(text_of)?;
205 216 let version_ms = message
206 217 .get("version")
@@ -234,9 +245,28 @@ fn activity_item(message: &Value) -> Option<ActivityItem> {
234 245 read_flag: flag(properties.get(READ_PROPERTY)),
235 246 tap_url: text("customTapAction"),
236 247 meeting_thread_id: meeting_thread_in(&activity.to_string()),
248 template_parameters: context
249 .and_then(|context| object_property(context, "templateParameters"))
250 .and_then(|parameters| parameters.as_object().cloned())
251 .map(|parameters| {
252 parameters
253 .iter()
254 .filter_map(|(key, value)| Some((key.clone(), text_of(value)?)))
255 .collect()
256 })
257 .unwrap_or_default(),
258 event_start_ms: tag_time(&location, "StartDateTime"),
259 event_end_ms: tag_time(&location, "EndDateTime"),
237 260 })
238 261 }
239 262
263 fn tag_time(text: &str, tag: &str) -> Option<i64> {
264 let open = format!("<{tag}>");
265 let start = text.find(&open)? + open.len();
266 let end = start + text[start..].find(&format!("</{tag}>"))?;
267 timestamp_ms(&Value::String(text[start..end].to_owned()))
268 }
269
240 270 fn meeting_thread_in(text: &str) -> Option<String> {
241 271 let decoded = text
242 272 .replace("%3a", ":")
@@ -371,6 +401,7 @@ mod tests {
371 401 read_flag: false,
372 402 tap_url: None,
373 403 meeting_thread_id: None,
404 ..ActivityItem::default()
374 405 }]
375 406 );
376 407 }
@@ -394,6 +425,24 @@ mod tests {
394 425 assert_eq!(items[1].meeting_thread_id.as_deref(), Some("19:meeting_YmFy@thread.v2"));
395 426 }
396 427
428 #[test]
429 fn an_app_activity_keeps_its_template_parameters_and_time_range() {
430 let body = json!({"messages": [message("1", 1, json!({
431 "activityType": "msGraph", "activitySubtype": "recapIsReadyForFollowedMeetingsV2",
432 "activityContext": {
433 "location": "{\"Custom\":\"<DateTimeRange><StartDateTime>2026-11-05T08:00:00.0000000Z</StartDateTime><EndDateTime>2026-11-05T09:00:00.0000000Z</EndDateTime></DateTimeRange>\"}",
434 "templateParameters": "{\"subject\":\"Following: Sprint Demo \"}",
435 },
436 }), "false")]});
437 let item = &parse_page(&body).unwrap()[0];
438 assert_eq!(
439 item.template_parameters.get("subject").map(String::as_str),
440 Some("Following: Sprint Demo ")
441 );
442 assert_eq!(item.event_start_ms, Some(1793865600000));
443 assert_eq!(item.event_end_ms, Some(1793869200000));
444 }
445
397 446 #[test]
398 447 fn reads_both_horizons_of_the_feed_conversation() {
399 448 let conversation = json!({"properties": {
@@ -1,3 +1,5 @@
1use std::collections::BTreeMap;
2
1use chrono::DateTime;
3use chrono::DateTime;
2use serde::{Deserialize, Serialize};
4use serde::{Deserialize, Serialize};
3use serde_json::{Value, json};
5use serde_json::{Value, json};
@@ -38,6 +40,10 @@ pub struct ActivityItem {
38 pub read_flag: bool,
40 pub read_flag: bool,
39 pub tap_url: Option<String>,
41 pub tap_url: Option<String>,
40 pub meeting_thread_id: Option<String>,
42 pub meeting_thread_id: Option<String>,
43 #[serde(default)]
44 pub template_parameters: BTreeMap<String, String>,
45 pub event_start_ms: Option<i64>,
46 pub event_end_ms: Option<i64>,
41}
47}
42
48
43/// `seen_ms`: the bell horizon (`consumptionhorizon`), `bookmark_ms`: Mark all as read (`consumptionHorizonBookmark`).
49/// `seen_ms`: the bell horizon (`consumptionhorizon`), `bookmark_ms`: Mark all as read (`consumptionHorizonBookmark`).
@@ -201,6 +207,11 @@ fn activity_item(message: &Value) -> Option<ActivityItem> {
201 }
207 }
202 let activity = object_property(properties, "activity")?;
208 let activity = object_property(properties, "activity")?;
203 let text = |key: &str| activity.get(key).and_then(text_of);
209 let text = |key: &str| activity.get(key).and_then(text_of);
210 let context = activity.get("activityContext");
211 let location = context
212 .and_then(|context| object_property(context, "location"))
213 .and_then(|location| location.get("Custom").and_then(Value::as_str).map(str::to_owned))
214 .unwrap_or_default();
204 let message_id = message.get("id").and_then(text_of)?;
215 let message_id = message.get("id").and_then(text_of)?;
205 let version_ms = message
216 let version_ms = message
206 .get("version")
217 .get("version")
@@ -234,9 +245,28 @@ fn activity_item(message: &Value) -> Option<ActivityItem> {
234 read_flag: flag(properties.get(READ_PROPERTY)),
245 read_flag: flag(properties.get(READ_PROPERTY)),
235 tap_url: text("customTapAction"),
246 tap_url: text("customTapAction"),
236 meeting_thread_id: meeting_thread_in(&activity.to_string()),
247 meeting_thread_id: meeting_thread_in(&activity.to_string()),
248 template_parameters: context
249 .and_then(|context| object_property(context, "templateParameters"))
250 .and_then(|parameters| parameters.as_object().cloned())
251 .map(|parameters| {
252 parameters
253 .iter()
254 .filter_map(|(key, value)| Some((key.clone(), text_of(value)?)))
255 .collect()
256 })
257 .unwrap_or_default(),
258 event_start_ms: tag_time(&location, "StartDateTime"),
259 event_end_ms: tag_time(&location, "EndDateTime"),
237 })
260 })
238}
261}
239
262
263fn tag_time(text: &str, tag: &str) -> Option<i64> {
264 let open = format!("<{tag}>");
265 let start = text.find(&open)? + open.len();
266 let end = start + text[start..].find(&format!("</{tag}>"))?;
267 timestamp_ms(&Value::String(text[start..end].to_owned()))
268}
269
240fn meeting_thread_in(text: &str) -> Option<String> {
270fn meeting_thread_in(text: &str) -> Option<String> {
241 let decoded = text
271 let decoded = text
242 .replace("%3a", ":")
272 .replace("%3a", ":")
@@ -371,6 +401,7 @@ mod tests {
371 read_flag: false,
401 read_flag: false,
372 tap_url: None,
402 tap_url: None,
373 meeting_thread_id: None,
403 meeting_thread_id: None,
404 ..ActivityItem::default()
374 }]
405 }]
375 );
406 );
376 }
407 }
@@ -394,6 +425,24 @@ mod tests {
394 assert_eq!(items[1].meeting_thread_id.as_deref(), Some("19:meeting_YmFy@thread.v2"));
425 assert_eq!(items[1].meeting_thread_id.as_deref(), Some("19:meeting_YmFy@thread.v2"));
395 }
426 }
396
427
428 #[test]
429 fn an_app_activity_keeps_its_template_parameters_and_time_range() {
430 let body = json!({"messages": [message("1", 1, json!({
431 "activityType": "msGraph", "activitySubtype": "recapIsReadyForFollowedMeetingsV2",
432 "activityContext": {
433 "location": "{\"Custom\":\"<DateTimeRange><StartDateTime>2026-11-05T08:00:00.0000000Z</StartDateTime><EndDateTime>2026-11-05T09:00:00.0000000Z</EndDateTime></DateTimeRange>\"}",
434 "templateParameters": "{\"subject\":\"Following: Sprint Demo \"}",
435 },
436 }), "false")]});
437 let item = &parse_page(&body).unwrap()[0];
438 assert_eq!(
439 item.template_parameters.get("subject").map(String::as_str),
440 Some("Following: Sprint Demo ")
441 );
442 assert_eq!(item.event_start_ms, Some(1793865600000));
443 assert_eq!(item.event_end_ms, Some(1793869200000));
444 }
445
397 #[test]
446 #[test]
398 fn reads_both_horizons_of_the_feed_conversation() {
447 fn reads_both_horizons_of_the_feed_conversation() {
399 let conversation = json!({"properties": {
448 let conversation = json!({"properties": {