BlueGit

ict rusty-teams

feat(activity): Replies, Reactions and Missed calls filters

- more filters behind the chevron, like the chat list pills
- proposals hidden under kind filters

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

metis Daniel Däschle · pushed by metis

Authored 2026-11-04 · 3 weeks ago

Hash
f402acd35f3d4efe32b1acbe03c01bf03b3528d1
Parent
4db62ce2
2 files changed +133 −30
crates/app-state/src/activity/feed.rs +46 −1
@@ -25,16 +25,31 @@ pub enum Filter {
25 25 All,
26 26 Mentions,
27 27 Unread,
28 Replies,
29 Reactions,
30 MissedCalls,
28 31 }
29 32
30 33 impl Filter {
31 pub const ALL: [Filter; 3] = [Filter::All, Filter::Mentions, Filter::Unread];
34 pub const PRIMARY: [Filter; 3] = [Filter::All, Filter::Mentions, Filter::Unread];
35 pub const OVERFLOW: [Filter; 3] = [Filter::Replies, Filter::Reactions, Filter::MissedCalls];
36 pub const ALL: [Filter; 6] = [
37 Filter::All,
38 Filter::Mentions,
39 Filter::Unread,
40 Filter::Replies,
41 Filter::Reactions,
42 Filter::MissedCalls,
43 ];
32 44
33 45 pub fn key(self) -> &'static str {
34 46 match self {
35 47 Filter::All => "all",
36 48 Filter::Mentions => "mentions",
37 49 Filter::Unread => "unread",
50 Filter::Replies => "replies",
51 Filter::Reactions => "reactions",
52 Filter::MissedCalls => "missed_calls",
38 53 }
39 54 }
40 55
@@ -47,6 +62,9 @@ impl Filter {
47 62 Filter::All => "All",
48 63 Filter::Mentions => "@Mentions",
49 64 Filter::Unread => "Unread",
65 Filter::Replies => "Replies",
66 Filter::Reactions => "Reactions",
67 Filter::MissedCalls => "Missed calls",
50 68 }
51 69 }
52 70
@@ -55,6 +73,9 @@ impl Filter {
55 73 Filter::All => "No activity yet",
56 74 Filter::Mentions => "No mentions",
57 75 Filter::Unread => "Nothing unread",
76 Filter::Replies => "No replies",
77 Filter::Reactions => "No reactions",
78 Filter::MissedCalls => "No missed calls",
58 79 }
59 80 }
60 81
@@ -63,6 +84,9 @@ impl Filter {
63 84 Filter::All => true,
64 85 Filter::Mentions => entry.kind == Kind::Mention,
65 86 Filter::Unread => !entry.read,
87 Filter::Replies => entry.kind == Kind::Reply,
88 Filter::Reactions => entry.kind == Kind::Reaction,
89 Filter::MissedCalls => entry.kind == Kind::MissedCall,
66 90 }
67 91 }
68 92 }
@@ -285,4 +309,25 @@ mod tests {
285 309 assert_eq!(feed.unread_count(), 2);
286 310 assert_eq!(feed.bell_count(), 2);
287 311 }
312
313 #[test]
314 fn kind_filters_keep_only_their_kind() {
315 let feed = Feed::new(vec![
316 entry("reply", Kind::Reply, at(8, 9), true),
317 entry("reaction", Kind::Reaction, at(8, 9), false),
318 entry("missed", Kind::MissedCall, at(8, 9), false),
319 entry("call", Kind::Call, at(8, 9), false),
320 ]);
321 let today = at(8, 12).date_naive();
322 let offset = FixedOffset::east_opt(0).unwrap();
323 let ids = |filter| -> Vec<String> {
324 feed.sections(filter, today, offset)
325 .iter()
326 .flat_map(|section| section.entries.iter().map(|entry| entry.id.clone()))
327 .collect()
328 };
329 assert_eq!(ids(Filter::Replies), ["reply"]);
330 assert_eq!(ids(Filter::Reactions), ["reaction"]);
331 assert_eq!(ids(Filter::MissedCalls), ["missed"]);
332 }
288 333 }
@@ -25,16 +25,31 @@ pub enum Filter {
25 All,
25 All,
26 Mentions,
26 Mentions,
27 Unread,
27 Unread,
28 Replies,
29 Reactions,
30 MissedCalls,
28}
31}
29
32
30impl Filter {
33impl Filter {
31 pub const ALL: [Filter; 3] = [Filter::All, Filter::Mentions, Filter::Unread];
34 pub const PRIMARY: [Filter; 3] = [Filter::All, Filter::Mentions, Filter::Unread];
35 pub const OVERFLOW: [Filter; 3] = [Filter::Replies, Filter::Reactions, Filter::MissedCalls];
36 pub const ALL: [Filter; 6] = [
37 Filter::All,
38 Filter::Mentions,
39 Filter::Unread,
40 Filter::Replies,
41 Filter::Reactions,
42 Filter::MissedCalls,
43 ];
32
44
33 pub fn key(self) -> &'static str {
45 pub fn key(self) -> &'static str {
34 match self {
46 match self {
35 Filter::All => "all",
47 Filter::All => "all",
36 Filter::Mentions => "mentions",
48 Filter::Mentions => "mentions",
37 Filter::Unread => "unread",
49 Filter::Unread => "unread",
50 Filter::Replies => "replies",
51 Filter::Reactions => "reactions",
52 Filter::MissedCalls => "missed_calls",
38 }
53 }
39 }
54 }
40
55
@@ -47,6 +62,9 @@ impl Filter {
47 Filter::All => "All",
62 Filter::All => "All",
48 Filter::Mentions => "@Mentions",
63 Filter::Mentions => "@Mentions",
49 Filter::Unread => "Unread",
64 Filter::Unread => "Unread",
65 Filter::Replies => "Replies",
66 Filter::Reactions => "Reactions",
67 Filter::MissedCalls => "Missed calls",
50 }
68 }
51 }
69 }
52
70
@@ -55,6 +73,9 @@ impl Filter {
55 Filter::All => "No activity yet",
73 Filter::All => "No activity yet",
56 Filter::Mentions => "No mentions",
74 Filter::Mentions => "No mentions",
57 Filter::Unread => "Nothing unread",
75 Filter::Unread => "Nothing unread",
76 Filter::Replies => "No replies",
77 Filter::Reactions => "No reactions",
78 Filter::MissedCalls => "No missed calls",
58 }
79 }
59 }
80 }
60
81
@@ -63,6 +84,9 @@ impl Filter {
63 Filter::All => true,
84 Filter::All => true,
64 Filter::Mentions => entry.kind == Kind::Mention,
85 Filter::Mentions => entry.kind == Kind::Mention,
65 Filter::Unread => !entry.read,
86 Filter::Unread => !entry.read,
87 Filter::Replies => entry.kind == Kind::Reply,
88 Filter::Reactions => entry.kind == Kind::Reaction,
89 Filter::MissedCalls => entry.kind == Kind::MissedCall,
66 }
90 }
67 }
91 }
68}
92}
@@ -285,4 +309,25 @@ mod tests {
285 assert_eq!(feed.unread_count(), 2);
309 assert_eq!(feed.unread_count(), 2);
286 assert_eq!(feed.bell_count(), 2);
310 assert_eq!(feed.bell_count(), 2);
287 }
311 }
312
313 #[test]
314 fn kind_filters_keep_only_their_kind() {
315 let feed = Feed::new(vec![
316 entry("reply", Kind::Reply, at(8, 9), true),
317 entry("reaction", Kind::Reaction, at(8, 9), false),
318 entry("missed", Kind::MissedCall, at(8, 9), false),
319 entry("call", Kind::Call, at(8, 9), false),
320 ]);
321 let today = at(8, 12).date_naive();
322 let offset = FixedOffset::east_opt(0).unwrap();
323 let ids = |filter| -> Vec<String> {
324 feed.sections(filter, today, offset)
325 .iter()
326 .flat_map(|section| section.entries.iter().map(|entry| entry.id.clone()))
327 .collect()
328 };
329 assert_eq!(ids(Filter::Replies), ["reply"]);
330 assert_eq!(ids(Filter::Reactions), ["reaction"]);
331 assert_eq!(ids(Filter::MissedCalls), ["missed"]);
332 }
288}
333}
crates/app/src/views/activity_panel.rs +87 −29
@@ -19,6 +19,7 @@ use crate::agent_api::{
19 19 pending::{PendingKind, PendingProposal, conversation_label as proposal_conversation_label},
20 20 };
21 21 use crate::app_state::{AppState, chat_title};
22 use crate::chat_filter::{FEWER_FILTERS, MORE_FILTERS};
22 23 use crate::data::is_one_on_one;
23 24 use crate::format;
24 25 use crate::people::resolve_names;
@@ -49,6 +50,7 @@ pub struct ActivityPanel {
49 50 app: Entity<AppState>,
50 51 activity: Entity<ActivityCenter>,
51 52 filter: Filter,
53 more_filters_open: bool,
52 54 scroll: ScrollHandle,
53 55 resolved_names: HashMap<String, String>,
54 56 looked_up: HashSet<String>,
@@ -83,6 +85,7 @@ impl ActivityPanel {
83 85 app,
84 86 activity,
85 87 filter,
88 more_filters_open: false,
86 89 scroll: ScrollHandle::new(),
87 90 resolved_names: HashMap::new(),
88 91 looked_up: HashSet::new(),
@@ -103,35 +106,82 @@ impl ActivityPanel {
103 106 cx.emit(event);
104 107 }
105 108
109 fn filter_pill(&self, filter: Filter, cx: &mut Context<Self>) -> impl IntoElement {
110 let selected = filter == self.filter;
111 div()
112 .id(ElementId::Name(
113 format!("activity-filter-{}", filter.label()).into(),
114 ))
115 .h(px(24.))
116 .px(px(12.))
117 .flex()
118 .flex_none()
119 .items_center()
120 .rounded_full()
121 .cursor_pointer()
122 .text_size(px(12.))
123 .when(selected, |pill| {
124 pill.bg(theme::accent()).text_color(theme::on_accent())
125 })
126 .when(!selected, |pill| {
127 pill.bg(theme::surface_raised())
128 .text_color(theme::text_soft())
129 .hover(|pill| pill.bg(theme::border_strong()))
130 })
131 .child(filter.label())
132 .on_click(cx.listener(move |this, _, _, cx| {
133 this.filter = filter;
134 let _ = this.app.read(cx).store.set_meta(FILTER_KEY, filter.key());
135 cx.notify();
136 }))
137 }
138
139 fn more_filters_button(&self, cx: &mut Context<Self>) -> impl IntoElement {
140 let open = self.more_filters_open;
141 let label = if open { FEWER_FILTERS } else { MORE_FILTERS };
142 div()
143 .id("activity-filter-more")
144 .size(px(24.))
145 .flex()
146 .flex_none()
147 .items_center()
148 .justify_center()
149 .rounded_full()
150 .cursor_pointer()
151 .bg(theme::surface_raised())
152 .hover(|pill| pill.bg(theme::border_strong()))
153 .tooltip(move |window, cx| Tooltip::new(label).build(window, cx))
154 .child(icon(
155 if open {
156 IconName::ChevronUp
157 } else {
158 IconName::ChevronDown
159 },
160 14.,
161 theme::text_soft(),
162 ))
163 .on_click(cx.listener(|this, _, _, cx| {
164 this.more_filters_open = !this.more_filters_open;
165 cx.notify();
166 }))
167 }
168
106 169 fn header(&self, cx: &mut Context<Self>) -> Div {
107 let pills = Filter::ALL.into_iter().map(|filter| {
108 let selected = filter == self.filter;
109 div()
110 .id(ElementId::Name(
111 format!("activity-filter-{}", filter.label()).into(),
112 ))
113 .h(px(24.))
114 .px(px(12.))
115 .flex()
116 .items_center()
117 .rounded_full()
118 .cursor_pointer()
119 .text_size(px(12.))
120 .when(selected, |pill| {
121 pill.bg(theme::accent()).text_color(theme::on_accent())
122 })
123 .when(!selected, |pill| {
124 pill.bg(theme::surface_raised())
125 .text_color(theme::text_soft())
126 .hover(|pill| pill.bg(theme::border_strong()))
127 })
128 .child(filter.label())
129 .on_click(cx.listener(move |this, _, _, cx| {
130 this.filter = filter;
131 let _ = this.app.read(cx).store.set_meta(FILTER_KEY, filter.key());
132 cx.notify();
133 }))
134 });
170 let overflow_active = Filter::OVERFLOW.contains(&self.filter);
171 let mut pills: Vec<AnyElement> = Filter::PRIMARY
172 .into_iter()
173 .map(|filter| self.filter_pill(filter, cx).into_any_element())
174 .collect();
175 if self.more_filters_open || overflow_active {
176 pills.extend(
177 Filter::OVERFLOW
178 .into_iter()
179 .map(|filter| self.filter_pill(filter, cx).into_any_element()),
180 );
181 }
182 if !overflow_active {
183 pills.push(self.more_filters_button(cx).into_any_element());
184 }
135 185 v_flex()
136 186 .flex_none()
137 187 .child(
@@ -184,7 +234,14 @@ impl ActivityPanel {
184 234 })),
185 235 ),
186 236 )
187 .child(h_flex().px(px(16.)).pb(px(12.)).gap(px(6.)).children(pills))
237 .child(
238 h_flex()
239 .px(px(16.))
240 .pb(px(12.))
241 .flex_wrap()
242 .gap(px(6.))
243 .children(pills),
244 )
188 245 }
189 246
190 247 fn row(
@@ -372,6 +429,7 @@ fn admits_proposal(filter: Filter, pending: &PendingProposal) -> bool {
372 429 Filter::All => true,
373 430 Filter::Mentions => false,
374 431 Filter::Unread => !pending.seen,
432 Filter::Replies | Filter::Reactions | Filter::MissedCalls => false,
375 433 }
376 434 }
377 435
@@ -19,6 +19,7 @@ use crate::agent_api::{
19 pending::{PendingKind, PendingProposal, conversation_label as proposal_conversation_label},
19 pending::{PendingKind, PendingProposal, conversation_label as proposal_conversation_label},
20};
20};
21use crate::app_state::{AppState, chat_title};
21use crate::app_state::{AppState, chat_title};
22use crate::chat_filter::{FEWER_FILTERS, MORE_FILTERS};
22use crate::data::is_one_on_one;
23use crate::data::is_one_on_one;
23use crate::format;
24use crate::format;
24use crate::people::resolve_names;
25use crate::people::resolve_names;
@@ -49,6 +50,7 @@ pub struct ActivityPanel {
49 app: Entity<AppState>,
50 app: Entity<AppState>,
50 activity: Entity<ActivityCenter>,
51 activity: Entity<ActivityCenter>,
51 filter: Filter,
52 filter: Filter,
53 more_filters_open: bool,
52 scroll: ScrollHandle,
54 scroll: ScrollHandle,
53 resolved_names: HashMap<String, String>,
55 resolved_names: HashMap<String, String>,
54 looked_up: HashSet<String>,
56 looked_up: HashSet<String>,
@@ -83,6 +85,7 @@ impl ActivityPanel {
83 app,
85 app,
84 activity,
86 activity,
85 filter,
87 filter,
88 more_filters_open: false,
86 scroll: ScrollHandle::new(),
89 scroll: ScrollHandle::new(),
87 resolved_names: HashMap::new(),
90 resolved_names: HashMap::new(),
88 looked_up: HashSet::new(),
91 looked_up: HashSet::new(),
@@ -103,35 +106,82 @@ impl ActivityPanel {
103 cx.emit(event);
106 cx.emit(event);
104 }
107 }
105
108
109 fn filter_pill(&self, filter: Filter, cx: &mut Context<Self>) -> impl IntoElement {
110 let selected = filter == self.filter;
111 div()
112 .id(ElementId::Name(
113 format!("activity-filter-{}", filter.label()).into(),
114 ))
115 .h(px(24.))
116 .px(px(12.))
117 .flex()
118 .flex_none()
119 .items_center()
120 .rounded_full()
121 .cursor_pointer()
122 .text_size(px(12.))
123 .when(selected, |pill| {
124 pill.bg(theme::accent()).text_color(theme::on_accent())
125 })
126 .when(!selected, |pill| {
127 pill.bg(theme::surface_raised())
128 .text_color(theme::text_soft())
129 .hover(|pill| pill.bg(theme::border_strong()))
130 })
131 .child(filter.label())
132 .on_click(cx.listener(move |this, _, _, cx| {
133 this.filter = filter;
134 let _ = this.app.read(cx).store.set_meta(FILTER_KEY, filter.key());
135 cx.notify();
136 }))
137 }
138
139 fn more_filters_button(&self, cx: &mut Context<Self>) -> impl IntoElement {
140 let open = self.more_filters_open;
141 let label = if open { FEWER_FILTERS } else { MORE_FILTERS };
142 div()
143 .id("activity-filter-more")
144 .size(px(24.))
145 .flex()
146 .flex_none()
147 .items_center()
148 .justify_center()
149 .rounded_full()
150 .cursor_pointer()
151 .bg(theme::surface_raised())
152 .hover(|pill| pill.bg(theme::border_strong()))
153 .tooltip(move |window, cx| Tooltip::new(label).build(window, cx))
154 .child(icon(
155 if open {
156 IconName::ChevronUp
157 } else {
158 IconName::ChevronDown
159 },
160 14.,
161 theme::text_soft(),
162 ))
163 .on_click(cx.listener(|this, _, _, cx| {
164 this.more_filters_open = !this.more_filters_open;
165 cx.notify();
166 }))
167 }
168
106 fn header(&self, cx: &mut Context<Self>) -> Div {
169 fn header(&self, cx: &mut Context<Self>) -> Div {
107 let pills = Filter::ALL.into_iter().map(|filter| {
170 let overflow_active = Filter::OVERFLOW.contains(&self.filter);
108 let selected = filter == self.filter;
171 let mut pills: Vec<AnyElement> = Filter::PRIMARY
109 div()
172 .into_iter()
110 .id(ElementId::Name(
173 .map(|filter| self.filter_pill(filter, cx).into_any_element())
111 format!("activity-filter-{}", filter.label()).into(),
174 .collect();
112 ))
175 if self.more_filters_open || overflow_active {
113 .h(px(24.))
176 pills.extend(
114 .px(px(12.))
177 Filter::OVERFLOW
115 .flex()
178 .into_iter()
116 .items_center()
179 .map(|filter| self.filter_pill(filter, cx).into_any_element()),
117 .rounded_full()
180 );
118 .cursor_pointer()
181 }
119 .text_size(px(12.))
182 if !overflow_active {
120 .when(selected, |pill| {
183 pills.push(self.more_filters_button(cx).into_any_element());
121 pill.bg(theme::accent()).text_color(theme::on_accent())
184 }
122 })
123 .when(!selected, |pill| {
124 pill.bg(theme::surface_raised())
125 .text_color(theme::text_soft())
126 .hover(|pill| pill.bg(theme::border_strong()))
127 })
128 .child(filter.label())
129 .on_click(cx.listener(move |this, _, _, cx| {
130 this.filter = filter;
131 let _ = this.app.read(cx).store.set_meta(FILTER_KEY, filter.key());
132 cx.notify();
133 }))
134 });
135 v_flex()
185 v_flex()
136 .flex_none()
186 .flex_none()
137 .child(
187 .child(
@@ -184,7 +234,14 @@ impl ActivityPanel {
184 })),
234 })),
185 ),
235 ),
186 )
236 )
187 .child(h_flex().px(px(16.)).pb(px(12.)).gap(px(6.)).children(pills))
237 .child(
238 h_flex()
239 .px(px(16.))
240 .pb(px(12.))
241 .flex_wrap()
242 .gap(px(6.))
243 .children(pills),
244 )
188 }
245 }
189
246
190 fn row(
247 fn row(
@@ -372,6 +429,7 @@ fn admits_proposal(filter: Filter, pending: &PendingProposal) -> bool {
372 Filter::All => true,
429 Filter::All => true,
373 Filter::Mentions => false,
430 Filter::Mentions => false,
374 Filter::Unread => !pending.seen,
431 Filter::Unread => !pending.seen,
432 Filter::Replies | Filter::Reactions | Filter::MissedCalls => false,
375 }
433 }
376}
434}
377
435