BlueGit

ict rusty-teams

feat(activity): location line and recap tile like Teams

- mentions, replies, reactions and posts show Team > Channel or the group chat on a third line instead of in the headline
- unnamed group chats read Chat with <members>
- recap rows: accent tile with the recap glyph, title over two lines when it does not fit

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
b77a51ce3a5d6d6195789989497702f0aa27b45c
Parent
d6884098
3 files changed +125 −31
crates/app-base/src/assets.rs +2 −1
@@ -8,7 +8,7 @@ macro_rules! symbols {
8 8 };
9 9 }
10 10
11 const SYMBOLS: [(&str, &[u8]); 75] = symbols![
11 const SYMBOLS: [(&str, &[u8]); 76] = symbols![
12 12 "bot",
13 13 "done",
14 14 "table",
@@ -45,6 +45,7 @@ const SYMBOLS: [(&str, &[u8]); 75] = symbols![
45 45 "status_ring",
46 46 "status_available",
47 47 "status_offline",
48 "recap",
48 49 "zoom_in",
49 50 "zoom_out",
50 51 "rotate_right",
@@ -8,7 +8,7 @@ macro_rules! symbols {
8 };
8 };
9}
9}
10
10
11const SYMBOLS: [(&str, &[u8]); 75] = symbols![
11const SYMBOLS: [(&str, &[u8]); 76] = symbols![
12 "bot",
12 "bot",
13 "done",
13 "done",
14 "table",
14 "table",
@@ -45,6 +45,7 @@ const SYMBOLS: [(&str, &[u8]); 75] = symbols![
45 "status_ring",
45 "status_ring",
46 "status_available",
46 "status_available",
47 "status_offline",
47 "status_offline",
48 "recap",
48 "zoom_in",
49 "zoom_in",
49 "zoom_out",
50 "zoom_out",
50 "rotate_right",
51 "rotate_right",
crates/app/assets/symbols/recap.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 4.6a7.4 7.4 0 1 1 0 14.8a7.4 7.4 0 0 1 0-14.8Z"/><path d="M10 8.6v6.8c0 .5.5.8.9.5l5.2-3.4a.6.6 0 0 0 0-1L10.9 8.1c-.4-.3-.9 0-.9.5Z"/></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 4.6a7.4 7.4 0 1 1 0 14.8a7.4 7.4 0 0 1 0-14.8Z"/><path d="M10 8.6v6.8c0 .5.5.8.9.5l5.2-3.4a.6.6 0 0 0 0-1L10.9 8.1c-.4-.3-.9 0-.9.5Z"/></svg>
crates/app/src/views/activity_panel.rs +122 −30
@@ -13,7 +13,7 @@ use store::Sidebar;
13 13 use super::avatar::person_avatar;
14 14 use super::scroll_edge::{scroll_offset, with_top_edge};
15 15 use super::sidebar::SIDEBAR_SCROLL_DIVIDER;
16 use super::widgets::{Corner, corner_badge, dot, icon};
16 use super::widgets::{Corner, corner_badge, dot, icon, symbol};
17 17 use crate::activity::{ActivityCenter, Entry, Filter, Kind};
18 18 use crate::agent_api::{
19 19 self,
@@ -32,6 +32,10 @@ const BUTTON_SIZE: f32 = 32.;
32 32 const MARK_READ_SIZE: f32 = 20.;
33 33 const ROW_HEIGHT: f32 = 58.;
34 34 const EVENT_LINE_HEIGHT: f32 = 16.;
35 const HEADLINE_LINE_HEIGHT: f32 = 18.;
36 const ROW_CHROME_WIDTH: f32 = 12. + 20. + AVATAR_SIZE + 2. * 12. + 56.;
37 const RECAP_TILE_RADIUS: f32 = 6.;
38 const RECAP_GLYPH_SIZE: f32 = 20.;
35 39 const HEADER_HEIGHT: f32 = 30.;
36 40 const EMPTY_HEIGHT: f32 = 84.;
37 41 const FALLBACK_VIEWPORT: f32 = 900.;
@@ -258,6 +262,7 @@ impl ActivityPanel {
258 262 fn row(
259 263 &self,
260 264 entry: &Entry,
265 text: &RowText,
261 266 sidebar: &Sidebar,
262 267 directory: &crate::data::Directory,
263 268 today: NaiveDate,
@@ -267,12 +272,16 @@ impl ActivityPanel {
267 272 let activity = self.activity.clone();
268 273 let id = entry.id.clone();
269 274 let actor = entry.latest_actor();
270 let avatar = person_avatar(
271 directory,
272 actor.and_then(|actor| actor.user_id.as_deref()),
273 actor.map_or("", |actor| actor.display_name(&self.resolved_names)),
274 AVATAR_SIZE,
275 );
275 let avatar = if is_recap(entry) {
276 recap_tile().into_any_element()
277 } else {
278 person_avatar(
279 directory,
280 actor.and_then(|actor| actor.user_id.as_deref()),
281 actor.map_or("", |actor| actor.display_name(&self.resolved_names)),
282 AVATAR_SIZE,
283 )
284 };
276 285 let group = SharedString::from(format!("activity-row-group-{id}"));
277 286 row_frame(RowParts {
278 287 element_id: format!("activity-row-{id}"),
@@ -280,10 +289,9 @@ impl ActivityPanel {
280 289 marker: kind_marker(entry, group.clone()),
281 290 group,
282 291 headline: headline(entry, sidebar, &self.resolved_names),
292 headline_wraps: text.headline_wraps,
283 293 detail: detail(entry),
284 event_line: entry
285 .event_range
286 .map(|(start, end)| event_line(start, end, &Local)),
294 lines: text.lines.clone(),
287 295 unread: !entry.read,
288 296 time: format::list_time_label(entry.updated_at, today, offset),
289 297 mark_read: Rc::new({
@@ -313,8 +321,9 @@ impl ActivityPanel {
313 321 marker: proposal_marker(pending, group.clone()),
314 322 group,
315 323 headline: pending.headline(label.as_deref()),
324 headline_wraps: false,
316 325 detail: pending.detail(),
317 event_line: None,
326 lines: Vec::new(),
318 327 unread: !pending.seen,
319 328 time: format::list_time_label(pending.created_at, today, offset),
320 329 mark_read: Rc::new(move |cx: &mut App| agent_api::mark_proposal_seen(&proposal_id, cx)),
@@ -339,8 +348,9 @@ struct RowParts {
339 348 avatar: AnyElement,
340 349 marker: Div,
341 350 headline: String,
351 headline_wraps: bool,
342 352 detail: String,
343 event_line: Option<String>,
353 lines: Vec<String>,
344 354 unread: bool,
345 355 time: String,
346 356 mark_read: MarkRead,
@@ -355,13 +365,14 @@ fn row_frame(parts: RowParts) -> Stateful<Div> {
355 365 avatar,
356 366 marker,
357 367 headline,
368 headline_wraps,
358 369 detail,
359 event_line,
370 lines,
360 371 unread,
361 372 time,
362 373 mark_read,
363 374 } = parts;
364 let height = ROW_HEIGHT + event_line.as_ref().map_or(0., |_| EVENT_LINE_HEIGHT);
375 let height = row_height(headline_wraps, lines.len());
365 376 let selector = element_id.clone();
366 377 h_flex()
367 378 .id(ElementId::Name(element_id.clone().into()))
@@ -392,8 +403,10 @@ fn row_frame(parts: RowParts) -> Stateful<Div> {
392 403 .gap(px(2.))
393 404 .child(
394 405 div()
395 .truncate()
406 .when(headline_wraps, |headline| headline.line_clamp(2))
407 .when(!headline_wraps, |headline| headline.truncate())
396 408 .text_size(px(13.))
409 .line_height(px(HEADLINE_LINE_HEIGHT))
397 410 .font_weight(if unread {
398 411 FontWeight::SEMIBOLD
399 412 } else {
@@ -417,7 +430,7 @@ fn row_frame(parts: RowParts) -> Stateful<Div> {
417 430 })
418 431 .child(detail),
419 432 )
420 .children(event_line.map(|line| {
433 .children(lines.into_iter().map(|line| {
421 434 div()
422 435 .truncate()
423 436 .text_size(px(12.))
@@ -591,10 +604,7 @@ fn headline(entry: &Entry, sidebar: &Sidebar, resolved_names: &HashMap<String, S
591 604 },
592 605 (Kind::Other, _) => actor,
593 606 };
594 match conversation_label(sidebar, &entry.conversation_id) {
595 Some(label) => format!("{verb} in {label}"),
596 None => verb,
597 }
607 verb
598 608 }
599 609
600 610 fn event_line<Zone: TimeZone>(start: DateTime<Utc>, end: DateTime<Utc>, zone: &Zone) -> String
@@ -646,7 +656,11 @@ fn detail(entry: &Entry) -> String {
646 656
647 657 fn conversation_label(sidebar: &Sidebar, conversation_id: &str) -> Option<String> {
648 658 if let Some(chat) = sidebar.chats.iter().find(|chat| chat.id == conversation_id) {
649 return (!is_one_on_one(chat)).then(|| chat_title(chat));
659 return match (is_one_on_one(chat), chat.title.trim().is_empty()) {
660 (true, _) => None,
661 (false, true) => Some(format!("Chat with {}", chat_title(chat))),
662 (false, false) => Some(chat_title(chat)),
663 };
650 664 }
651 665 sidebar.teams.iter().find_map(|team| {
652 666 team.channels
@@ -670,10 +684,79 @@ fn group_header(label: &'static str) -> Div {
670 684 .child(label)
671 685 }
672 686
687 struct RowText {
688 headline_wraps: bool,
689 lines: Vec<String>,
690 }
691
692 impl RowText {
693 fn new(entry: &Entry, sidebar: &Sidebar, headline_wraps: bool) -> Self {
694 let lines = entry
695 .event_range
696 .map(|(start, end)| event_line(start, end, &Local))
697 .into_iter()
698 .chain(location_line(entry, sidebar))
699 .collect();
700 Self {
701 headline_wraps,
702 lines,
703 }
704 }
705
706 fn height(&self) -> f32 {
707 row_height(self.headline_wraps, self.lines.len())
708 }
709 }
710
711 fn row_height(headline_wraps: bool, extra_lines: usize) -> f32 {
712 let headline_extra = if headline_wraps { HEADLINE_LINE_HEIGHT } else { 0. };
713 ROW_HEIGHT + headline_extra + extra_lines as f32 * EVENT_LINE_HEIGHT
714 }
715
716 fn is_recap(entry: &Entry) -> bool {
717 entry.kind == Kind::App && entry.subtype.starts_with("recapIsReady")
718 }
719
720 fn recap_tile() -> Div {
721 div()
722 .size(px(AVATAR_SIZE))
723 .flex_none()
724 .rounded(px(RECAP_TILE_RADIUS))
725 .bg(theme::accent())
726 .flex()
727 .items_center()
728 .justify_center()
729 .child(symbol("recap", RECAP_GLYPH_SIZE, theme::white()))
730 }
731
732 fn headline_wraps(entry: &Entry, text_width: f32, window: &mut Window) -> bool {
733 let Some(title) = entry.title.as_deref().filter(|_| entry.kind == Kind::App) else {
734 return false;
735 };
736 if text_width <= 0. {
737 return false;
738 }
739 let run = window.text_style().to_run(title.len());
740 let width = window
741 .text_system()
742 .shape_line(title.to_owned().into(), px(13.), &[run], None)
743 .width;
744 f32::from(width) > text_width
745 }
746
747 fn location_line(entry: &Entry, sidebar: &Sidebar) -> Option<String> {
748 match entry.kind {
749 Kind::Mention | Kind::Reply | Kind::Reaction | Kind::Posted => {
750 conversation_label(sidebar, &entry.conversation_id)
751 }
752 _ => None,
753 }
754 }
755
673 756 enum Slot<'a> {
674 757 Proposals(Vec<PendingProposal>),
675 758 Header(&'static str),
676 Row(&'a Entry),
759 Row(&'a Entry, RowText),
677 760 Empty,
678 761 }
679 762
@@ -682,8 +765,7 @@ impl Slot<'_> {
682 765 match self {
683 766 Slot::Proposals(proposals) => HEADER_HEIGHT + proposals.len() as f32 * ROW_HEIGHT,
684 767 Slot::Header(_) => HEADER_HEIGHT,
685 Slot::Row(entry) if entry.event_range.is_some() => ROW_HEIGHT + EVENT_LINE_HEIGHT,
686 Slot::Row(_) => ROW_HEIGHT,
768 Slot::Row(_, text) => text.height(),
687 769 Slot::Empty => EMPTY_HEIGHT,
688 770 }
689 771 }
@@ -737,6 +819,7 @@ impl Render for ActivityPanel {
737 819 .read(cx)
738 820 .feed()
739 821 .sections(self.filter, today, offset);
822 let text_width = f32::from(self.scroll.bounds().size.width) - ROW_CHROME_WIDTH;
740 823 let mut slots: Vec<Slot> = Vec::new();
741 824 let proposals: Vec<PendingProposal> = agent_api::pending_proposals(cx)
742 825 .into_iter()
@@ -747,7 +830,10 @@ impl Render for ActivityPanel {
747 830 }
748 831 for section in &sections {
749 832 slots.push(Slot::Header(section.bucket.label()));
750 slots.extend(section.entries.iter().map(|entry| Slot::Row(entry)));
833 slots.extend(section.entries.iter().map(|entry| {
834 let wraps = headline_wraps(entry, text_width, window);
835 Slot::Row(entry, RowText::new(entry, &state.sidebar, wraps))
836 }));
751 837 }
752 838 if slots.is_empty() {
753 839 slots.push(Slot::Empty);
@@ -765,7 +851,7 @@ impl Render for ActivityPanel {
765 851 let unresolved: Vec<String> = visible_slots
766 852 .iter()
767 853 .filter_map(|slot| match slot {
768 Slot::Row(entry) => Some(entry.unresolved_user_ids()),
854 Slot::Row(entry, _) => Some(entry.unresolved_user_ids()),
769 855 _ => None,
770 856 })
771 857 .flatten()
@@ -791,8 +877,9 @@ impl Render for ActivityPanel {
791 877 }))
792 878 .into_any_element(),
793 879 Slot::Header(label) => group_header(label).into_any_element(),
794 Slot::Row(entry) => self.row(
880 Slot::Row(entry, text) => self.row(
795 881 entry,
882 text,
796 883 &state.sidebar,
797 884 &state.directory,
798 885 today,
@@ -840,7 +927,8 @@ mod tests {
840 927 use store::{ChatRecord, Sidebar, Store};
841 928
842 929 use super::{
843 ActivityPanel, ROW_HEIGHT, VIEWPORT_MARGIN, VisibleSlots, detail, headline, visible_slots,
930 ActivityPanel, ROW_HEIGHT, VIEWPORT_MARGIN, VisibleSlots, detail, headline, location_line,
931 visible_slots,
844 932 };
845 933 use crate::activity::{ActivityCenter, Actor, Entry, Filter, Kind};
846 934 use crate::app_state::{AppState, Mode};
@@ -967,11 +1055,15 @@ mod tests {
967 1055 };
968 1056 assert_eq!(
969 1057 headline(&with(Kind::Mention, "mention", "channel", 1), &sidebar, &HashMap::new()),
970 "Anna mentioned Releases in Platform > Releases"
1058 "Anna mentioned Releases"
1059 );
1060 assert_eq!(
1061 location_line(&with(Kind::Mention, "mention", "channel", 1), &sidebar).as_deref(),
1062 Some("Platform > Releases")
971 1063 );
972 1064 assert_eq!(
973 1065 headline(&with(Kind::Mention, "mention", "team", 1), &sidebar, &HashMap::new()),
974 "Anna mentioned Platform in Platform > Releases"
1066 "Anna mentioned Platform"
975 1067 );
976 1068 assert_eq!(
977 1069 headline(
@@ -13,7 +13,7 @@ use store::Sidebar;
13use super::avatar::person_avatar;
13use super::avatar::person_avatar;
14use super::scroll_edge::{scroll_offset, with_top_edge};
14use super::scroll_edge::{scroll_offset, with_top_edge};
15use super::sidebar::SIDEBAR_SCROLL_DIVIDER;
15use super::sidebar::SIDEBAR_SCROLL_DIVIDER;
16use super::widgets::{Corner, corner_badge, dot, icon};
16use super::widgets::{Corner, corner_badge, dot, icon, symbol};
17use crate::activity::{ActivityCenter, Entry, Filter, Kind};
17use crate::activity::{ActivityCenter, Entry, Filter, Kind};
18use crate::agent_api::{
18use crate::agent_api::{
19 self,
19 self,
@@ -32,6 +32,10 @@ const BUTTON_SIZE: f32 = 32.;
32const MARK_READ_SIZE: f32 = 20.;
32const MARK_READ_SIZE: f32 = 20.;
33const ROW_HEIGHT: f32 = 58.;
33const ROW_HEIGHT: f32 = 58.;
34const EVENT_LINE_HEIGHT: f32 = 16.;
34const EVENT_LINE_HEIGHT: f32 = 16.;
35const HEADLINE_LINE_HEIGHT: f32 = 18.;
36const ROW_CHROME_WIDTH: f32 = 12. + 20. + AVATAR_SIZE + 2. * 12. + 56.;
37const RECAP_TILE_RADIUS: f32 = 6.;
38const RECAP_GLYPH_SIZE: f32 = 20.;
35const HEADER_HEIGHT: f32 = 30.;
39const HEADER_HEIGHT: f32 = 30.;
36const EMPTY_HEIGHT: f32 = 84.;
40const EMPTY_HEIGHT: f32 = 84.;
37const FALLBACK_VIEWPORT: f32 = 900.;
41const FALLBACK_VIEWPORT: f32 = 900.;
@@ -258,6 +262,7 @@ impl ActivityPanel {
258 fn row(
262 fn row(
259 &self,
263 &self,
260 entry: &Entry,
264 entry: &Entry,
265 text: &RowText,
261 sidebar: &Sidebar,
266 sidebar: &Sidebar,
262 directory: &crate::data::Directory,
267 directory: &crate::data::Directory,
263 today: NaiveDate,
268 today: NaiveDate,
@@ -267,12 +272,16 @@ impl ActivityPanel {
267 let activity = self.activity.clone();
272 let activity = self.activity.clone();
268 let id = entry.id.clone();
273 let id = entry.id.clone();
269 let actor = entry.latest_actor();
274 let actor = entry.latest_actor();
270 let avatar = person_avatar(
275 let avatar = if is_recap(entry) {
271 directory,
276 recap_tile().into_any_element()
272 actor.and_then(|actor| actor.user_id.as_deref()),
277 } else {
273 actor.map_or("", |actor| actor.display_name(&self.resolved_names)),
278 person_avatar(
274 AVATAR_SIZE,
279 directory,
275 );
280 actor.and_then(|actor| actor.user_id.as_deref()),
281 actor.map_or("", |actor| actor.display_name(&self.resolved_names)),
282 AVATAR_SIZE,
283 )
284 };
276 let group = SharedString::from(format!("activity-row-group-{id}"));
285 let group = SharedString::from(format!("activity-row-group-{id}"));
277 row_frame(RowParts {
286 row_frame(RowParts {
278 element_id: format!("activity-row-{id}"),
287 element_id: format!("activity-row-{id}"),
@@ -280,10 +289,9 @@ impl ActivityPanel {
280 marker: kind_marker(entry, group.clone()),
289 marker: kind_marker(entry, group.clone()),
281 group,
290 group,
282 headline: headline(entry, sidebar, &self.resolved_names),
291 headline: headline(entry, sidebar, &self.resolved_names),
292 headline_wraps: text.headline_wraps,
283 detail: detail(entry),
293 detail: detail(entry),
284 event_line: entry
294 lines: text.lines.clone(),
285 .event_range
286 .map(|(start, end)| event_line(start, end, &Local)),
287 unread: !entry.read,
295 unread: !entry.read,
288 time: format::list_time_label(entry.updated_at, today, offset),
296 time: format::list_time_label(entry.updated_at, today, offset),
289 mark_read: Rc::new({
297 mark_read: Rc::new({
@@ -313,8 +321,9 @@ impl ActivityPanel {
313 marker: proposal_marker(pending, group.clone()),
321 marker: proposal_marker(pending, group.clone()),
314 group,
322 group,
315 headline: pending.headline(label.as_deref()),
323 headline: pending.headline(label.as_deref()),
324 headline_wraps: false,
316 detail: pending.detail(),
325 detail: pending.detail(),
317 event_line: None,
326 lines: Vec::new(),
318 unread: !pending.seen,
327 unread: !pending.seen,
319 time: format::list_time_label(pending.created_at, today, offset),
328 time: format::list_time_label(pending.created_at, today, offset),
320 mark_read: Rc::new(move |cx: &mut App| agent_api::mark_proposal_seen(&proposal_id, cx)),
329 mark_read: Rc::new(move |cx: &mut App| agent_api::mark_proposal_seen(&proposal_id, cx)),
@@ -339,8 +348,9 @@ struct RowParts {
339 avatar: AnyElement,
348 avatar: AnyElement,
340 marker: Div,
349 marker: Div,
341 headline: String,
350 headline: String,
351 headline_wraps: bool,
342 detail: String,
352 detail: String,
343 event_line: Option<String>,
353 lines: Vec<String>,
344 unread: bool,
354 unread: bool,
345 time: String,
355 time: String,
346 mark_read: MarkRead,
356 mark_read: MarkRead,
@@ -355,13 +365,14 @@ fn row_frame(parts: RowParts) -> Stateful<Div> {
355 avatar,
365 avatar,
356 marker,
366 marker,
357 headline,
367 headline,
368 headline_wraps,
358 detail,
369 detail,
359 event_line,
370 lines,
360 unread,
371 unread,
361 time,
372 time,
362 mark_read,
373 mark_read,
363 } = parts;
374 } = parts;
364 let height = ROW_HEIGHT + event_line.as_ref().map_or(0., |_| EVENT_LINE_HEIGHT);
375 let height = row_height(headline_wraps, lines.len());
365 let selector = element_id.clone();
376 let selector = element_id.clone();
366 h_flex()
377 h_flex()
367 .id(ElementId::Name(element_id.clone().into()))
378 .id(ElementId::Name(element_id.clone().into()))
@@ -392,8 +403,10 @@ fn row_frame(parts: RowParts) -> Stateful<Div> {
392 .gap(px(2.))
403 .gap(px(2.))
393 .child(
404 .child(
394 div()
405 div()
395 .truncate()
406 .when(headline_wraps, |headline| headline.line_clamp(2))
407 .when(!headline_wraps, |headline| headline.truncate())
396 .text_size(px(13.))
408 .text_size(px(13.))
409 .line_height(px(HEADLINE_LINE_HEIGHT))
397 .font_weight(if unread {
410 .font_weight(if unread {
398 FontWeight::SEMIBOLD
411 FontWeight::SEMIBOLD
399 } else {
412 } else {
@@ -417,7 +430,7 @@ fn row_frame(parts: RowParts) -> Stateful<Div> {
417 })
430 })
418 .child(detail),
431 .child(detail),
419 )
432 )
420 .children(event_line.map(|line| {
433 .children(lines.into_iter().map(|line| {
421 div()
434 div()
422 .truncate()
435 .truncate()
423 .text_size(px(12.))
436 .text_size(px(12.))
@@ -591,10 +604,7 @@ fn headline(entry: &Entry, sidebar: &Sidebar, resolved_names: &HashMap<String, S
591 },
604 },
592 (Kind::Other, _) => actor,
605 (Kind::Other, _) => actor,
593 };
606 };
594 match conversation_label(sidebar, &entry.conversation_id) {
607 verb
595 Some(label) => format!("{verb} in {label}"),
596 None => verb,
597 }
598}
608}
599
609
600fn event_line<Zone: TimeZone>(start: DateTime<Utc>, end: DateTime<Utc>, zone: &Zone) -> String
610fn event_line<Zone: TimeZone>(start: DateTime<Utc>, end: DateTime<Utc>, zone: &Zone) -> String
@@ -646,7 +656,11 @@ fn detail(entry: &Entry) -> String {
646
656
647fn conversation_label(sidebar: &Sidebar, conversation_id: &str) -> Option<String> {
657fn conversation_label(sidebar: &Sidebar, conversation_id: &str) -> Option<String> {
648 if let Some(chat) = sidebar.chats.iter().find(|chat| chat.id == conversation_id) {
658 if let Some(chat) = sidebar.chats.iter().find(|chat| chat.id == conversation_id) {
649 return (!is_one_on_one(chat)).then(|| chat_title(chat));
659 return match (is_one_on_one(chat), chat.title.trim().is_empty()) {
660 (true, _) => None,
661 (false, true) => Some(format!("Chat with {}", chat_title(chat))),
662 (false, false) => Some(chat_title(chat)),
663 };
650 }
664 }
651 sidebar.teams.iter().find_map(|team| {
665 sidebar.teams.iter().find_map(|team| {
652 team.channels
666 team.channels
@@ -670,10 +684,79 @@ fn group_header(label: &'static str) -> Div {
670 .child(label)
684 .child(label)
671}
685}
672
686
687struct RowText {
688 headline_wraps: bool,
689 lines: Vec<String>,
690}
691
692impl RowText {
693 fn new(entry: &Entry, sidebar: &Sidebar, headline_wraps: bool) -> Self {
694 let lines = entry
695 .event_range
696 .map(|(start, end)| event_line(start, end, &Local))
697 .into_iter()
698 .chain(location_line(entry, sidebar))
699 .collect();
700 Self {
701 headline_wraps,
702 lines,
703 }
704 }
705
706 fn height(&self) -> f32 {
707 row_height(self.headline_wraps, self.lines.len())
708 }
709}
710
711fn row_height(headline_wraps: bool, extra_lines: usize) -> f32 {
712 let headline_extra = if headline_wraps { HEADLINE_LINE_HEIGHT } else { 0. };
713 ROW_HEIGHT + headline_extra + extra_lines as f32 * EVENT_LINE_HEIGHT
714}
715
716fn is_recap(entry: &Entry) -> bool {
717 entry.kind == Kind::App && entry.subtype.starts_with("recapIsReady")
718}
719
720fn recap_tile() -> Div {
721 div()
722 .size(px(AVATAR_SIZE))
723 .flex_none()
724 .rounded(px(RECAP_TILE_RADIUS))
725 .bg(theme::accent())
726 .flex()
727 .items_center()
728 .justify_center()
729 .child(symbol("recap", RECAP_GLYPH_SIZE, theme::white()))
730}
731
732fn headline_wraps(entry: &Entry, text_width: f32, window: &mut Window) -> bool {
733 let Some(title) = entry.title.as_deref().filter(|_| entry.kind == Kind::App) else {
734 return false;
735 };
736 if text_width <= 0. {
737 return false;
738 }
739 let run = window.text_style().to_run(title.len());
740 let width = window
741 .text_system()
742 .shape_line(title.to_owned().into(), px(13.), &[run], None)
743 .width;
744 f32::from(width) > text_width
745}
746
747fn location_line(entry: &Entry, sidebar: &Sidebar) -> Option<String> {
748 match entry.kind {
749 Kind::Mention | Kind::Reply | Kind::Reaction | Kind::Posted => {
750 conversation_label(sidebar, &entry.conversation_id)
751 }
752 _ => None,
753 }
754}
755
673enum Slot<'a> {
756enum Slot<'a> {
674 Proposals(Vec<PendingProposal>),
757 Proposals(Vec<PendingProposal>),
675 Header(&'static str),
758 Header(&'static str),
676 Row(&'a Entry),
759 Row(&'a Entry, RowText),
677 Empty,
760 Empty,
678}
761}
679
762
@@ -682,8 +765,7 @@ impl Slot<'_> {
682 match self {
765 match self {
683 Slot::Proposals(proposals) => HEADER_HEIGHT + proposals.len() as f32 * ROW_HEIGHT,
766 Slot::Proposals(proposals) => HEADER_HEIGHT + proposals.len() as f32 * ROW_HEIGHT,
684 Slot::Header(_) => HEADER_HEIGHT,
767 Slot::Header(_) => HEADER_HEIGHT,
685 Slot::Row(entry) if entry.event_range.is_some() => ROW_HEIGHT + EVENT_LINE_HEIGHT,
768 Slot::Row(_, text) => text.height(),
686 Slot::Row(_) => ROW_HEIGHT,
687 Slot::Empty => EMPTY_HEIGHT,
769 Slot::Empty => EMPTY_HEIGHT,
688 }
770 }
689 }
771 }
@@ -737,6 +819,7 @@ impl Render for ActivityPanel {
737 .read(cx)
819 .read(cx)
738 .feed()
820 .feed()
739 .sections(self.filter, today, offset);
821 .sections(self.filter, today, offset);
822 let text_width = f32::from(self.scroll.bounds().size.width) - ROW_CHROME_WIDTH;
740 let mut slots: Vec<Slot> = Vec::new();
823 let mut slots: Vec<Slot> = Vec::new();
741 let proposals: Vec<PendingProposal> = agent_api::pending_proposals(cx)
824 let proposals: Vec<PendingProposal> = agent_api::pending_proposals(cx)
742 .into_iter()
825 .into_iter()
@@ -747,7 +830,10 @@ impl Render for ActivityPanel {
747 }
830 }
748 for section in &sections {
831 for section in &sections {
749 slots.push(Slot::Header(section.bucket.label()));
832 slots.push(Slot::Header(section.bucket.label()));
750 slots.extend(section.entries.iter().map(|entry| Slot::Row(entry)));
833 slots.extend(section.entries.iter().map(|entry| {
834 let wraps = headline_wraps(entry, text_width, window);
835 Slot::Row(entry, RowText::new(entry, &state.sidebar, wraps))
836 }));
751 }
837 }
752 if slots.is_empty() {
838 if slots.is_empty() {
753 slots.push(Slot::Empty);
839 slots.push(Slot::Empty);
@@ -765,7 +851,7 @@ impl Render for ActivityPanel {
765 let unresolved: Vec<String> = visible_slots
851 let unresolved: Vec<String> = visible_slots
766 .iter()
852 .iter()
767 .filter_map(|slot| match slot {
853 .filter_map(|slot| match slot {
768 Slot::Row(entry) => Some(entry.unresolved_user_ids()),
854 Slot::Row(entry, _) => Some(entry.unresolved_user_ids()),
769 _ => None,
855 _ => None,
770 })
856 })
771 .flatten()
857 .flatten()
@@ -791,8 +877,9 @@ impl Render for ActivityPanel {
791 }))
877 }))
792 .into_any_element(),
878 .into_any_element(),
793 Slot::Header(label) => group_header(label).into_any_element(),
879 Slot::Header(label) => group_header(label).into_any_element(),
794 Slot::Row(entry) => self.row(
880 Slot::Row(entry, text) => self.row(
795 entry,
881 entry,
882 text,
796 &state.sidebar,
883 &state.sidebar,
797 &state.directory,
884 &state.directory,
798 today,
885 today,
@@ -840,7 +927,8 @@ mod tests {
840 use store::{ChatRecord, Sidebar, Store};
927 use store::{ChatRecord, Sidebar, Store};
841
928
842 use super::{
929 use super::{
843 ActivityPanel, ROW_HEIGHT, VIEWPORT_MARGIN, VisibleSlots, detail, headline, visible_slots,
930 ActivityPanel, ROW_HEIGHT, VIEWPORT_MARGIN, VisibleSlots, detail, headline, location_line,
931 visible_slots,
844 };
932 };
845 use crate::activity::{ActivityCenter, Actor, Entry, Filter, Kind};
933 use crate::activity::{ActivityCenter, Actor, Entry, Filter, Kind};
846 use crate::app_state::{AppState, Mode};
934 use crate::app_state::{AppState, Mode};
@@ -967,11 +1055,15 @@ mod tests {
967 };
1055 };
968 assert_eq!(
1056 assert_eq!(
969 headline(&with(Kind::Mention, "mention", "channel", 1), &sidebar, &HashMap::new()),
1057 headline(&with(Kind::Mention, "mention", "channel", 1), &sidebar, &HashMap::new()),
970 "Anna mentioned Releases in Platform > Releases"
1058 "Anna mentioned Releases"
1059 );
1060 assert_eq!(
1061 location_line(&with(Kind::Mention, "mention", "channel", 1), &sidebar).as_deref(),
1062 Some("Platform > Releases")
971 );
1063 );
972 assert_eq!(
1064 assert_eq!(
973 headline(&with(Kind::Mention, "mention", "team", 1), &sidebar, &HashMap::new()),
1065 headline(&with(Kind::Mention, "mention", "team", 1), &sidebar, &HashMap::new()),
974 "Anna mentioned Platform in Platform > Releases"
1066 "Anna mentioned Platform"
975 );
1067 );
976 assert_eq!(
1068 assert_eq!(
977 headline(
1069 headline(