BlueGit

ict rusty-teams

feat(parity): Quick views (Mentions, Drafts, Saved) in the chat list like Teams

- "Quick views" section at the top of the chat list; each opens its list in the main pane
- Saved leaves the rail; Ctrl+4 opens the Saved quick view
- Mentions from the activity feed, Drafts from unsent local drafts
- choosing a chat or Find in chat closes the quick view; opening one moves focus to the shell so shortcuts keep working

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

metis Daniel Däschle · pushed by metis

Authored 2026-11-08 · 3 weeks ago

Hash
29318242e48c55b22b96b7f86b97b84c83556614
Parent
3b37290b
11 files changed +624 −290
crates/app-base/src/assets.rs +4 −1
@@ -8,7 +8,7 @@ macro_rules! symbols {
8 8 };
9 9 }
10 10
11 const SYMBOLS: [(&str, &[u8]); 82] = symbols![
11 const SYMBOLS: [(&str, &[u8]); 85] = symbols![
12 12 "campaign",
13 13 "lock",
14 14 "bot",
@@ -64,6 +64,9 @@ const SYMBOLS: [(&str, &[u8]); 82] = symbols![
64 64 "call_missed",
65 65 "videocam",
66 66 "fluent_video",
67 "fluent_mention",
68 "fluent_drafts",
69 "fluent_bookmark",
67 70 "fluent_record",
68 71 "fluent_record_stop",
69 72 "fluent_cloud_arrow_up",
@@ -8,7 +8,7 @@ macro_rules! symbols {
8 };
8 };
9}
9}
10
10
11const SYMBOLS: [(&str, &[u8]); 82] = symbols![
11const SYMBOLS: [(&str, &[u8]); 85] = symbols![
12 "campaign",
12 "campaign",
13 "lock",
13 "lock",
14 "bot",
14 "bot",
@@ -64,6 +64,9 @@ const SYMBOLS: [(&str, &[u8]); 82] = symbols![
64 "call_missed",
64 "call_missed",
65 "videocam",
65 "videocam",
66 "fluent_video",
66 "fluent_video",
67 "fluent_mention",
68 "fluent_drafts",
69 "fluent_bookmark",
67 "fluent_record",
70 "fluent_record",
68 "fluent_record_stop",
71 "fluent_record_stop",
69 "fluent_cloud_arrow_up",
72 "fluent_cloud_arrow_up",
crates/app-state/src/app_state.rs +52 −0
@@ -29,6 +29,31 @@ use calling::meeting::LiveMeeting;
29 29 const COLLAPSED_META_KEY: &str = "ui.collapsed_sections";
30 30 const RECENT_MESSAGES_FOR_TYPING: usize = 5;
31 31
32 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
33 pub enum QuickView {
34 Mentions,
35 Drafts,
36 Saved,
37 }
38
39 impl QuickView {
40 pub fn title(self) -> &'static str {
41 match self {
42 QuickView::Mentions => "Mentions",
43 QuickView::Drafts => "Drafts",
44 QuickView::Saved => "Saved",
45 }
46 }
47
48 pub fn empty_text(self) -> &'static str {
49 match self {
50 QuickView::Mentions => "No mentions yet. When someone @mentions you, it shows up here.",
51 QuickView::Drafts => "No drafts. Messages you start and do not send show up here.",
52 QuickView::Saved => "No saved messages. Use Save message in the ... menu of a message.",
53 }
54 }
55 }
56
32 57 #[derive(Debug, Clone, PartialEq, Eq)]
33 58 pub enum Selection {
34 59 Chat(String),
@@ -124,6 +149,7 @@ pub struct AppState {
124 149 pub typing: TypingState,
125 150 typing_timer_running: bool,
126 151 pub local_previews: HashMap<String, LocalPreview>,
152 pub quick_view: Option<QuickView>,
127 153 pub scheduled: Vec<ScheduledDraft>,
128 154 pub scheduled_polling: bool,
129 155 pub saved: SavedSet,
@@ -279,6 +305,7 @@ impl AppState {
279 305 typing: TypingState::default(),
280 306 typing_timer_running: false,
281 307 local_previews: HashMap::new(),
308 quick_view: None,
282 309 scheduled: Vec::new(),
283 310 scheduled_polling: false,
284 311 saved: SavedSet::default(),
@@ -912,7 +939,27 @@ impl AppState {
912 939 );
913 940 }
914 941
942 pub fn open_quick_view(&mut self, view: QuickView, cx: &mut Context<Self>) {
943 self.show_call(false, cx);
944 self.cancel_prejoin(cx);
945 self.new_chat = false;
946 self.quick_view = Some(view);
947 if view == QuickView::Saved {
948 self.refresh_saved(cx);
949 }
950 cx.emit(AppEvent::Sidebar);
951 cx.notify();
952 }
953
954 pub fn close_quick_view(&mut self, cx: &mut Context<Self>) {
955 if self.quick_view.take().is_some() {
956 cx.emit(AppEvent::Sidebar);
957 cx.notify();
958 }
959 }
960
915 961 pub fn start_new_chat(&mut self, cx: &mut Context<Self>) {
962 self.quick_view = None;
916 963 self.new_chat = true;
917 964 self.show_call(false, cx);
918 965 cx.emit(AppEvent::Selection);
@@ -933,7 +980,12 @@ impl AppState {
933 980 self.cancel_prejoin(cx);
934 981 self.call_end = None;
935 982 let was_drafting = std::mem::take(&mut self.new_chat);
983 let left_quick_view = self.quick_view.take().is_some();
936 984 if !was_drafting && self.selection.as_ref() == Some(&selection) {
985 if left_quick_view {
986 cx.emit(AppEvent::Sidebar);
987 cx.notify();
988 }
937 989 return;
938 990 }
939 991 let conversation_id = selection.conversation_id().to_owned();
@@ -29,6 +29,31 @@ use calling::meeting::LiveMeeting;
29const COLLAPSED_META_KEY: &str = "ui.collapsed_sections";
29const COLLAPSED_META_KEY: &str = "ui.collapsed_sections";
30const RECENT_MESSAGES_FOR_TYPING: usize = 5;
30const RECENT_MESSAGES_FOR_TYPING: usize = 5;
31
31
32#[derive(Debug, Clone, Copy, PartialEq, Eq)]
33pub enum QuickView {
34 Mentions,
35 Drafts,
36 Saved,
37}
38
39impl QuickView {
40 pub fn title(self) -> &'static str {
41 match self {
42 QuickView::Mentions => "Mentions",
43 QuickView::Drafts => "Drafts",
44 QuickView::Saved => "Saved",
45 }
46 }
47
48 pub fn empty_text(self) -> &'static str {
49 match self {
50 QuickView::Mentions => "No mentions yet. When someone @mentions you, it shows up here.",
51 QuickView::Drafts => "No drafts. Messages you start and do not send show up here.",
52 QuickView::Saved => "No saved messages. Use Save message in the ... menu of a message.",
53 }
54 }
55}
56
32#[derive(Debug, Clone, PartialEq, Eq)]
57#[derive(Debug, Clone, PartialEq, Eq)]
33pub enum Selection {
58pub enum Selection {
34 Chat(String),
59 Chat(String),
@@ -124,6 +149,7 @@ pub struct AppState {
124 pub typing: TypingState,
149 pub typing: TypingState,
125 typing_timer_running: bool,
150 typing_timer_running: bool,
126 pub local_previews: HashMap<String, LocalPreview>,
151 pub local_previews: HashMap<String, LocalPreview>,
152 pub quick_view: Option<QuickView>,
127 pub scheduled: Vec<ScheduledDraft>,
153 pub scheduled: Vec<ScheduledDraft>,
128 pub scheduled_polling: bool,
154 pub scheduled_polling: bool,
129 pub saved: SavedSet,
155 pub saved: SavedSet,
@@ -279,6 +305,7 @@ impl AppState {
279 typing: TypingState::default(),
305 typing: TypingState::default(),
280 typing_timer_running: false,
306 typing_timer_running: false,
281 local_previews: HashMap::new(),
307 local_previews: HashMap::new(),
308 quick_view: None,
282 scheduled: Vec::new(),
309 scheduled: Vec::new(),
283 scheduled_polling: false,
310 scheduled_polling: false,
284 saved: SavedSet::default(),
311 saved: SavedSet::default(),
@@ -912,7 +939,27 @@ impl AppState {
912 );
939 );
913 }
940 }
914
941
942 pub fn open_quick_view(&mut self, view: QuickView, cx: &mut Context<Self>) {
943 self.show_call(false, cx);
944 self.cancel_prejoin(cx);
945 self.new_chat = false;
946 self.quick_view = Some(view);
947 if view == QuickView::Saved {
948 self.refresh_saved(cx);
949 }
950 cx.emit(AppEvent::Sidebar);
951 cx.notify();
952 }
953
954 pub fn close_quick_view(&mut self, cx: &mut Context<Self>) {
955 if self.quick_view.take().is_some() {
956 cx.emit(AppEvent::Sidebar);
957 cx.notify();
958 }
959 }
960
915 pub fn start_new_chat(&mut self, cx: &mut Context<Self>) {
961 pub fn start_new_chat(&mut self, cx: &mut Context<Self>) {
962 self.quick_view = None;
916 self.new_chat = true;
963 self.new_chat = true;
917 self.show_call(false, cx);
964 self.show_call(false, cx);
918 cx.emit(AppEvent::Selection);
965 cx.emit(AppEvent::Selection);
@@ -933,7 +980,12 @@ impl AppState {
933 self.cancel_prejoin(cx);
980 self.cancel_prejoin(cx);
934 self.call_end = None;
981 self.call_end = None;
935 let was_drafting = std::mem::take(&mut self.new_chat);
982 let was_drafting = std::mem::take(&mut self.new_chat);
983 let left_quick_view = self.quick_view.take().is_some();
936 if !was_drafting && self.selection.as_ref() == Some(&selection) {
984 if !was_drafting && self.selection.as_ref() == Some(&selection) {
985 if left_quick_view {
986 cx.emit(AppEvent::Sidebar);
987 cx.notify();
988 }
937 return;
989 return;
938 }
990 }
939 let conversation_id = selection.conversation_id().to_owned();
991 let conversation_id = selection.conversation_id().to_owned();
crates/app/assets/symbols/fluent_bookmark.svg added +1 −0
@@ -0,0 +1 @@
1 <svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M4 4.5A2.5 2.5 0 0 1 6.5 2h7A2.5 2.5 0 0 1 16 4.5v13a.5.5 0 0 1-.8.4L10 14.12 4.8 17.9a.5.5 0 0 1-.8-.4v-13ZM6.5 3C5.67 3 5 3.67 5 4.5v12.02l4.7-3.42a.5.5 0 0 1 .6 0l4.7 3.42V4.5c0-.83-.67-1.5-1.5-1.5h-7Z"/></svg>
@@ -0,0 +1 @@
1<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M4 4.5A2.5 2.5 0 0 1 6.5 2h7A2.5 2.5 0 0 1 16 4.5v13a.5.5 0 0 1-.8.4L10 14.12 4.8 17.9a.5.5 0 0 1-.8-.4v-13ZM6.5 3C5.67 3 5 3.67 5 4.5v12.02l4.7-3.42a.5.5 0 0 1 .6 0l4.7 3.42V4.5c0-.83-.67-1.5-1.5-1.5h-7Z"/></svg>
crates/app/assets/symbols/fluent_drafts.svg added +1 −0
@@ -0,0 +1 @@
1 <svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m13.25 2.82-9.61 9.6-.12.13a2 2 0 0 0-.4.76l-1.1 4.06-.02.08a.5.5 0 0 0 .63.53l4.06-1.1.16-.06a2 2 0 0 0 .73-.46l9.6-9.6.13-.15a2.78 2.78 0 0 0-4.06-3.8Zm-8.9 10.31 8.04-8.04 2.52 2.52-8.04 8.04-.1.09-.1.07a1 1 0 0 1-.25.1l-3.2.87.87-3.2.04-.13a1 1 0 0 1 .22-.32Zm12.12-9.6.11.11c.59.7.55 1.75-.1 2.4l-.87.87-2.52-2.53.86-.86.12-.1c.7-.59 1.75-.55 2.4.1ZM11.65 3H2.5a.5.5 0 0 0 0 1h8.15l1-1Zm-3 3H2.5a.5.5 0 0 0 0 1h5.15l1-1Zm-4 4 1-1H2.5a.5.5 0 0 0 0 1h2.15Z"/></svg>
@@ -0,0 +1 @@
1<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m13.25 2.82-9.61 9.6-.12.13a2 2 0 0 0-.4.76l-1.1 4.06-.02.08a.5.5 0 0 0 .63.53l4.06-1.1.16-.06a2 2 0 0 0 .73-.46l9.6-9.6.13-.15a2.78 2.78 0 0 0-4.06-3.8Zm-8.9 10.31 8.04-8.04 2.52 2.52-8.04 8.04-.1.09-.1.07a1 1 0 0 1-.25.1l-3.2.87.87-3.2.04-.13a1 1 0 0 1 .22-.32Zm12.12-9.6.11.11c.59.7.55 1.75-.1 2.4l-.87.87-2.52-2.53.86-.86.12-.1c.7-.59 1.75-.55 2.4.1ZM11.65 3H2.5a.5.5 0 0 0 0 1h8.15l1-1Zm-3 3H2.5a.5.5 0 0 0 0 1h5.15l1-1Zm-4 4 1-1H2.5a.5.5 0 0 0 0 1h2.15Z"/></svg>
crates/app/assets/symbols/fluent_mention.svg added +1 −0
@@ -0,0 +1 @@
1 <svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10 2a8 8 0 0 1 8 8c0 2.7-1.14 4.5-3 4.5-1.23 0-2.14-.78-2.62-2.09-.6.98-1.6 1.59-2.88 1.59C7.36 14 6 12.3 6 10c0-2.34 1.31-4 3.5-4 1.05 0 1.9.38 2.5 1.04V6.5a.5.5 0 0 1 1-.09V10c0 2.22.81 3.5 2 3.5s2-1.28 2-3.5a7 7 0 1 0-4.62 6.58.5.5 0 0 1 .34.94A7.99 7.99 0 0 1 2 10a8 8 0 0 1 8-8Zm-.5 5C7.92 7 7 8.17 7 10c0 1.8.97 3 2.5 3s2.5-1.2 2.5-3c0-1.83-.92-3-2.5-3Z"/></svg>
@@ -0,0 +1 @@
1<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10 2a8 8 0 0 1 8 8c0 2.7-1.14 4.5-3 4.5-1.23 0-2.14-.78-2.62-2.09-.6.98-1.6 1.59-2.88 1.59C7.36 14 6 12.3 6 10c0-2.34 1.31-4 3.5-4 1.05 0 1.9.38 2.5 1.04V6.5a.5.5 0 0 1 1-.09V10c0 2.22.81 3.5 2 3.5s2-1.28 2-3.5a7 7 0 1 0-4.62 6.58.5.5 0 0 1 .34.94A7.99 7.99 0 0 1 2 10a8 8 0 0 1 8-8Zm-.5 5C7.92 7 7 8.17 7 10c0 1.8.97 3 2.5 3s2.5-1.2 2.5-3c0-1.83-.92-3-2.5-3Z"/></svg>
crates/app/src/views/mod.rs +1 −1
@@ -72,7 +72,7 @@ pub mod rail;
72 72 pub mod reaction_picker;
73 73 pub mod reaction_pills;
74 74 pub mod recap_tab;
75 pub mod saved_panel;
75 pub mod quick_view_pane;
76 76 pub mod scheduled_toolbar;
77 77 pub mod section_dialog;
78 78 pub mod share_bar;
@@ -72,7 +72,7 @@ pub mod rail;
72pub mod reaction_picker;
72pub mod reaction_picker;
73pub mod reaction_pills;
73pub mod reaction_pills;
74pub mod recap_tab;
74pub mod recap_tab;
75pub mod saved_panel;
75pub mod quick_view_pane;
76pub mod scheduled_toolbar;
76pub mod scheduled_toolbar;
77pub mod section_dialog;
77pub mod section_dialog;
78pub mod share_bar;
78pub mod share_bar;
crates/app/src/views/quick_view_pane.rs added +410 −0
@@ -0,0 +1,410 @@
1 use std::collections::HashMap;
2
3 use chrono::{DateTime, FixedOffset, Local, NaiveDate, Offset, Utc};
4 use gpui_kit::assets::IconName;
5 use gpui_kit::component::scroll::ScrollableElement as _;
6 use gpui_kit::component::{h_flex, tooltip::Tooltip, v_flex};
7 use gpui_kit::prelude::FluentBuilder as _;
8 use gpui_kit::*;
9 use teams_core::SavedMessage;
10
11 use super::avatar::person_avatar;
12 use super::scroll_edge::with_top_edge;
13 use super::widgets::icon;
14 use crate::activity::{ActivityCenter, Entry, Kind};
15 use store::Sidebar;
16
17 use crate::app_state::{AppState, QuickView, selection_for, selection_title};
18 use crate::format;
19 use crate::local_previews::LocalPreview;
20 use crate::theme;
21
22 const QUICK_VIEW_SCROLL_DIVIDER: &str = "shell/islands/main/quick-view-divider-scroll";
23 const HEADER_HEIGHT: f32 = 60.;
24 const HEADER_PADDING: f32 = 20.;
25 const AVATAR_SIZE: f32 = 32.;
26 const BUTTON_SIZE: f32 = 24.;
27 const PREVIEW_LINES: usize = 2;
28 const LIST_MAX_WIDTH: f32 = 860.;
29 const UNKNOWN_AUTHOR: &str = "Unknown";
30
31 #[derive(Debug, Clone, PartialEq, Eq)]
32 pub struct QuickRow {
33 pub conversation_id: String,
34 pub message_id: Option<String>,
35 pub author_id: Option<String>,
36 pub author: String,
37 pub place: String,
38 pub time: String,
39 pub preview: String,
40 pub saved: Option<SavedMessage>,
41 }
42
43 fn place_of(sidebar: &Sidebar, conversation_id: &str) -> Option<String> {
44 selection_for(sidebar, conversation_id).map(|selection| selection_title(sidebar, &selection))
45 }
46
47 fn time_label(time: DateTime<Utc>, today: NaiveDate, offset: FixedOffset) -> String {
48 format::list_time_label(time, today, offset)
49 }
50
51 pub fn mention_rows(
52 entries: &[Entry],
53 sidebar: &Sidebar,
54 today: NaiveDate,
55 offset: FixedOffset,
56 ) -> Vec<QuickRow> {
57 let mut mentions: Vec<&Entry> = entries
58 .iter()
59 .filter(|entry| entry.kind == Kind::Mention)
60 .collect();
61 mentions.sort_by(|left, right| right.updated_at.cmp(&left.updated_at));
62 mentions
63 .into_iter()
64 .map(|entry| {
65 let actor = entry.actors.first();
66 QuickRow {
67 conversation_id: entry.conversation_id.clone(),
68 message_id: Some(entry.message_id.clone()).filter(|id| !id.is_empty()),
69 author_id: actor.and_then(|actor| actor.user_id.clone()),
70 author: actor
71 .map(|actor| actor.name.clone())
72 .unwrap_or_else(|| UNKNOWN_AUTHOR.to_owned()),
73 place: place_of(sidebar, &entry.conversation_id)
74 .or_else(|| entry.source_label.clone())
75 .unwrap_or_default(),
76 time: time_label(entry.updated_at, today, offset),
77 preview: entry.preview.clone(),
78 saved: None,
79 }
80 })
81 .collect()
82 }
83
84 pub fn draft_rows(previews: &HashMap<String, LocalPreview>, sidebar: &Sidebar) -> Vec<QuickRow> {
85 let mut rows: Vec<QuickRow> = previews
86 .iter()
87 .filter_map(|(conversation_id, preview)| {
88 let LocalPreview::Draft(text) = preview else {
89 return None;
90 };
91 let place = place_of(sidebar, conversation_id)?;
92 Some(QuickRow {
93 conversation_id: conversation_id.clone(),
94 message_id: None,
95 author_id: None,
96 author: place.clone(),
97 place: String::new(),
98 time: String::new(),
99 preview: text.clone(),
100 saved: None,
101 })
102 })
103 .collect();
104 rows.sort_by(|left, right| left.author.to_lowercase().cmp(&right.author.to_lowercase()));
105 rows
106 }
107
108 pub fn saved_rows(
109 items: &[SavedMessage],
110 sidebar: &Sidebar,
111 today: NaiveDate,
112 offset: FixedOffset,
113 ) -> Vec<QuickRow> {
114 items
115 .iter()
116 .map(|item| QuickRow {
117 conversation_id: item.conversation_id.clone(),
118 message_id: Some(item.message_id.clone()),
119 author_id: item.author_id.clone(),
120 author: item
121 .author_name
122 .clone()
123 .unwrap_or_else(|| UNKNOWN_AUTHOR.to_owned()),
124 place: place_of(sidebar, &item.conversation_id)
125 .or_else(|| item.topic.clone())
126 .unwrap_or_default(),
127 time: time_label(item.saved_at, today, offset),
128 preview: item.preview.clone(),
129 saved: Some(item.clone()),
130 })
131 .collect()
132 }
133
134 pub enum QuickViewEvent {
135 Open {
136 conversation_id: String,
137 message_id: Option<String>,
138 },
139 }
140
141 pub struct QuickViewPane {
142 app: Entity<AppState>,
143 activity: Entity<ActivityCenter>,
144 scroll: ScrollHandle,
145 _observations: [Subscription; 2],
146 }
147
148 impl EventEmitter<QuickViewEvent> for QuickViewPane {}
149
150 impl QuickViewPane {
151 pub fn new(
152 app: Entity<AppState>,
153 activity: Entity<ActivityCenter>,
154 cx: &mut Context<Self>,
155 ) -> Self {
156 let observations = [
157 cx.observe(&app, |_, _, cx| cx.notify()),
158 cx.observe(&activity, |_, _, cx| cx.notify()),
159 ];
160 QuickViewPane {
161 app,
162 activity,
163 scroll: ScrollHandle::new(),
164 _observations: observations,
165 }
166 }
167
168 fn rows(&self, view: QuickView, cx: &App) -> Vec<QuickRow> {
169 let state = self.app.read(cx);
170 let offset = Local::now().offset().fix();
171 let today = Utc::now().with_timezone(&offset).date_naive();
172 match view {
173 QuickView::Mentions => mention_rows(
174 self.activity.read(cx).feed().entries(),
175 &state.sidebar,
176 today,
177 offset,
178 ),
179 QuickView::Drafts => draft_rows(&state.local_previews, &state.sidebar),
180 QuickView::Saved => saved_rows(state.saved.items(), &state.sidebar, today, offset),
181 }
182 }
183
184 fn header(&self, view: QuickView, count: usize) -> Div {
185 h_flex()
186 .h(px(HEADER_HEIGHT))
187 .flex_none()
188 .px(px(HEADER_PADDING))
189 .gap(px(8.))
190 .items_center()
191 .child(
192 div()
193 .text_size(px(16.))
194 .font_weight(FontWeight::BOLD)
195 .text_color(theme::text())
196 .child(view.title()),
197 )
198 .when(count > 0, |header| {
199 header.child(
200 div()
201 .text_size(px(12.))
202 .text_color(theme::text_muted())
203 .child(count.to_string()),
204 )
205 })
206 }
207
208 fn row(&self, row: &QuickRow, index: usize, cx: &Context<Self>) -> AnyElement {
209 let app = self.app.clone();
210 let group = SharedString::from(format!("quick-row-group-{index}"));
211 let (conversation_id, message_id) = (row.conversation_id.clone(), row.message_id.clone());
212 let unsave = row.saved.clone().map(|item| {
213 div()
214 .id(ElementId::Name(format!("quick-unsave-{index}").into()))
215 .absolute()
216 .right(px(8.))
217 .top(px(8.))
218 .size(px(BUTTON_SIZE))
219 .flex()
220 .items_center()
221 .justify_center()
222 .rounded(px(6.))
223 .cursor_pointer()
224 .invisible()
225 .group_hover(group.clone(), |button| button.visible())
226 .hover(|button| button.bg(theme::popup_hover()))
227 .child(icon(IconName::BookmarkOff, 14., theme::text_muted()))
228 .tooltip(|window, cx| Tooltip::new("Unsave").build(window, cx))
229 .on_click(move |_, _, cx| {
230 cx.stop_propagation();
231 let entry = item.clone();
232 app.update(cx, |state, cx| state.set_saved(entry, false, cx));
233 })
234 });
235 let directory = &self.app.read(cx).directory;
236 h_flex()
237 .id(ElementId::Name(format!("quick-row-{index}").into()))
238 .group(group.clone())
239 .relative()
240 .w_full()
241 .p(px(12.))
242 .gap(px(12.))
243 .items_start()
244 .rounded(px(8.))
245 .cursor_pointer()
246 .hover(|row| row.bg(theme::row_hover()))
247 .child(div().flex_none().size(px(AVATAR_SIZE)).child(person_avatar(
248 directory,
249 row.author_id.as_deref(),
250 &row.author,
251 AVATAR_SIZE,
252 )))
253 .child(
254 v_flex()
255 .flex_1()
256 .min_w_0()
257 .gap(px(2.))
258 .child(
259 h_flex()
260 .gap(px(8.))
261 .items_baseline()
262 .child(
263 div()
264 .flex_none()
265 .text_size(px(14.))
266 .font_weight(FontWeight::SEMIBOLD)
267 .text_color(theme::text())
268 .child(row.author.clone()),
269 )
270 .child(
271 div()
272 .flex_1()
273 .min_w_0()
274 .truncate()
275 .text_size(px(12.))
276 .text_color(theme::text_muted())
277 .child(row.place.clone()),
278 )
279 .child(
280 div()
281 .flex_none()
282 .pr(px(BUTTON_SIZE + 8.))
283 .text_size(px(12.))
284 .text_color(theme::text_muted())
285 .child(row.time.clone()),
286 ),
287 )
288 .child(
289 div()
290 .line_clamp(PREVIEW_LINES)
291 .text_ellipsis()
292 .text_size(px(14.))
293 .line_height(relative(1.4))
294 .text_color(theme::text_soft())
295 .child(row.preview.clone()),
296 ),
297 )
298 .children(unsave)
299 .on_click(cx.listener(move |_, _, _, cx| {
300 cx.emit(QuickViewEvent::Open {
301 conversation_id: conversation_id.clone(),
302 message_id: message_id.clone(),
303 });
304 }))
305 .into_any_element()
306 }
307 }
308
309 impl Render for QuickViewPane {
310 fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
311 let view = self.app.read(cx).quick_view.unwrap_or(QuickView::Saved);
312 let rows = self.rows(view, cx);
313 let mut list: Vec<AnyElement> = rows
314 .iter()
315 .enumerate()
316 .map(|(index, row)| self.row(row, index, cx))
317 .collect();
318 if list.is_empty() {
319 list.push(
320 div()
321 .py(px(32.))
322 .px(px(24.))
323 .flex()
324 .justify_center()
325 .text_center()
326 .text_size(px(13.))
327 .text_color(theme::text_muted())
328 .child(view.empty_text())
329 .into_any_element(),
330 );
331 }
332 v_flex()
333 .debug_selector(|| "shell/islands/main".into())
334 .flex_1()
335 .w_full()
336 .min_w_0()
337 .h_full()
338 .rounded(px(10.))
339 .bg(theme::surface())
340 .overflow_hidden()
341 .child(self.header(view, rows.len()))
342 .child(div().w_full().h(px(1.)).flex_none().bg(theme::border()))
343 .child(with_top_edge(
344 v_flex()
345 .id("quick-view-list")
346 .flex_1()
347 .min_h_0()
348 .px(px(HEADER_PADDING - 12.))
349 .py(px(8.))
350 .overflow_y_scrollbar()
351 .track_scroll(&self.scroll)
352 .child(v_flex().w_full().max_w(px(LIST_MAX_WIDTH)).children(list)),
353 &self.scroll,
354 QUICK_VIEW_SCROLL_DIVIDER,
355 ))
356 }
357 }
358
359 #[cfg(test)]
360 mod tests {
361 use std::collections::HashMap;
362
363 use chrono::{FixedOffset, NaiveDate, TimeZone, Utc};
364 use store::Sidebar;
365
366 use super::{draft_rows, mention_rows};
367 use crate::activity::{Actor, Entry, Kind};
368 use crate::local_previews::LocalPreview;
369
370 fn entry(id: &str, kind: Kind, minute: u32) -> Entry {
371 Entry {
372 id: id.to_owned(),
373 conversation_id: "19:chat".to_owned(),
374 kind,
375 message_id: format!("m-{id}"),
376 actors: vec![Actor {
377 user_id: Some("ada".to_owned()),
378 name: "Ada".to_owned(),
379 }],
380 preview: "@Dana look".to_owned(),
381 updated_at: Utc.with_ymd_and_hms(2026, 11, 8, 9, minute, 0).unwrap(),
382 ..Entry::default()
383 }
384 }
385
386
387 #[test]
388 fn mentions_list_only_mentions_newest_first() {
389 let entries = [
390 entry("a", Kind::Mention, 1),
391 entry("b", Kind::Reaction, 2),
392 entry("c", Kind::Mention, 3),
393 ];
394 let offset = FixedOffset::east_opt(0).unwrap();
395 let today = NaiveDate::from_ymd_opt(2026, 11, 8).unwrap();
396 let rows = mention_rows(&entries, &Sidebar::default(), today, offset);
397 let ids: Vec<_> = rows.iter().map(|row| row.message_id.clone().unwrap()).collect();
398 assert_eq!(ids, ["m-c", "m-a"]);
399 assert_eq!(rows[0].author, "Ada");
400 }
401
402 #[test]
403 fn drafts_skip_unsent_and_unknown_conversations() {
404 let previews = HashMap::from([
405 ("19:gone".to_owned(), LocalPreview::Draft("lost".to_owned())),
406 ("19:chat".to_owned(), LocalPreview::NotSent),
407 ]);
408 assert!(draft_rows(&previews, &Sidebar::default()).is_empty());
409 }
410 }
@@ -0,0 +1,410 @@
1use std::collections::HashMap;
2
3use chrono::{DateTime, FixedOffset, Local, NaiveDate, Offset, Utc};
4use gpui_kit::assets::IconName;
5use gpui_kit::component::scroll::ScrollableElement as _;
6use gpui_kit::component::{h_flex, tooltip::Tooltip, v_flex};
7use gpui_kit::prelude::FluentBuilder as _;
8use gpui_kit::*;
9use teams_core::SavedMessage;
10
11use super::avatar::person_avatar;
12use super::scroll_edge::with_top_edge;
13use super::widgets::icon;
14use crate::activity::{ActivityCenter, Entry, Kind};
15use store::Sidebar;
16
17use crate::app_state::{AppState, QuickView, selection_for, selection_title};
18use crate::format;
19use crate::local_previews::LocalPreview;
20use crate::theme;
21
22const QUICK_VIEW_SCROLL_DIVIDER: &str = "shell/islands/main/quick-view-divider-scroll";
23const HEADER_HEIGHT: f32 = 60.;
24const HEADER_PADDING: f32 = 20.;
25const AVATAR_SIZE: f32 = 32.;
26const BUTTON_SIZE: f32 = 24.;
27const PREVIEW_LINES: usize = 2;
28const LIST_MAX_WIDTH: f32 = 860.;
29const UNKNOWN_AUTHOR: &str = "Unknown";
30
31#[derive(Debug, Clone, PartialEq, Eq)]
32pub struct QuickRow {
33 pub conversation_id: String,
34 pub message_id: Option<String>,
35 pub author_id: Option<String>,
36 pub author: String,
37 pub place: String,
38 pub time: String,
39 pub preview: String,
40 pub saved: Option<SavedMessage>,
41}
42
43fn place_of(sidebar: &Sidebar, conversation_id: &str) -> Option<String> {
44 selection_for(sidebar, conversation_id).map(|selection| selection_title(sidebar, &selection))
45}
46
47fn time_label(time: DateTime<Utc>, today: NaiveDate, offset: FixedOffset) -> String {
48 format::list_time_label(time, today, offset)
49}
50
51pub fn mention_rows(
52 entries: &[Entry],
53 sidebar: &Sidebar,
54 today: NaiveDate,
55 offset: FixedOffset,
56) -> Vec<QuickRow> {
57 let mut mentions: Vec<&Entry> = entries
58 .iter()
59 .filter(|entry| entry.kind == Kind::Mention)
60 .collect();
61 mentions.sort_by(|left, right| right.updated_at.cmp(&left.updated_at));
62 mentions
63 .into_iter()
64 .map(|entry| {
65 let actor = entry.actors.first();
66 QuickRow {
67 conversation_id: entry.conversation_id.clone(),
68 message_id: Some(entry.message_id.clone()).filter(|id| !id.is_empty()),
69 author_id: actor.and_then(|actor| actor.user_id.clone()),
70 author: actor
71 .map(|actor| actor.name.clone())
72 .unwrap_or_else(|| UNKNOWN_AUTHOR.to_owned()),
73 place: place_of(sidebar, &entry.conversation_id)
74 .or_else(|| entry.source_label.clone())
75 .unwrap_or_default(),
76 time: time_label(entry.updated_at, today, offset),
77 preview: entry.preview.clone(),
78 saved: None,
79 }
80 })
81 .collect()
82}
83
84pub fn draft_rows(previews: &HashMap<String, LocalPreview>, sidebar: &Sidebar) -> Vec<QuickRow> {
85 let mut rows: Vec<QuickRow> = previews
86 .iter()
87 .filter_map(|(conversation_id, preview)| {
88 let LocalPreview::Draft(text) = preview else {
89 return None;
90 };
91 let place = place_of(sidebar, conversation_id)?;
92 Some(QuickRow {
93 conversation_id: conversation_id.clone(),
94 message_id: None,
95 author_id: None,
96 author: place.clone(),
97 place: String::new(),
98 time: String::new(),
99 preview: text.clone(),
100 saved: None,
101 })
102 })
103 .collect();
104 rows.sort_by(|left, right| left.author.to_lowercase().cmp(&right.author.to_lowercase()));
105 rows
106}
107
108pub fn saved_rows(
109 items: &[SavedMessage],
110 sidebar: &Sidebar,
111 today: NaiveDate,
112 offset: FixedOffset,
113) -> Vec<QuickRow> {
114 items
115 .iter()
116 .map(|item| QuickRow {
117 conversation_id: item.conversation_id.clone(),
118 message_id: Some(item.message_id.clone()),
119 author_id: item.author_id.clone(),
120 author: item
121 .author_name
122 .clone()
123 .unwrap_or_else(|| UNKNOWN_AUTHOR.to_owned()),
124 place: place_of(sidebar, &item.conversation_id)
125 .or_else(|| item.topic.clone())
126 .unwrap_or_default(),
127 time: time_label(item.saved_at, today, offset),
128 preview: item.preview.clone(),
129 saved: Some(item.clone()),
130 })
131 .collect()
132}
133
134pub enum QuickViewEvent {
135 Open {
136 conversation_id: String,
137 message_id: Option<String>,
138 },
139}
140
141pub struct QuickViewPane {
142 app: Entity<AppState>,
143 activity: Entity<ActivityCenter>,
144 scroll: ScrollHandle,
145 _observations: [Subscription; 2],
146}
147
148impl EventEmitter<QuickViewEvent> for QuickViewPane {}
149
150impl QuickViewPane {
151 pub fn new(
152 app: Entity<AppState>,
153 activity: Entity<ActivityCenter>,
154 cx: &mut Context<Self>,
155 ) -> Self {
156 let observations = [
157 cx.observe(&app, |_, _, cx| cx.notify()),
158 cx.observe(&activity, |_, _, cx| cx.notify()),
159 ];
160 QuickViewPane {
161 app,
162 activity,
163 scroll: ScrollHandle::new(),
164 _observations: observations,
165 }
166 }
167
168 fn rows(&self, view: QuickView, cx: &App) -> Vec<QuickRow> {
169 let state = self.app.read(cx);
170 let offset = Local::now().offset().fix();
171 let today = Utc::now().with_timezone(&offset).date_naive();
172 match view {
173 QuickView::Mentions => mention_rows(
174 self.activity.read(cx).feed().entries(),
175 &state.sidebar,
176 today,
177 offset,
178 ),
179 QuickView::Drafts => draft_rows(&state.local_previews, &state.sidebar),
180 QuickView::Saved => saved_rows(state.saved.items(), &state.sidebar, today, offset),
181 }
182 }
183
184 fn header(&self, view: QuickView, count: usize) -> Div {
185 h_flex()
186 .h(px(HEADER_HEIGHT))
187 .flex_none()
188 .px(px(HEADER_PADDING))
189 .gap(px(8.))
190 .items_center()
191 .child(
192 div()
193 .text_size(px(16.))
194 .font_weight(FontWeight::BOLD)
195 .text_color(theme::text())
196 .child(view.title()),
197 )
198 .when(count > 0, |header| {
199 header.child(
200 div()
201 .text_size(px(12.))
202 .text_color(theme::text_muted())
203 .child(count.to_string()),
204 )
205 })
206 }
207
208 fn row(&self, row: &QuickRow, index: usize, cx: &Context<Self>) -> AnyElement {
209 let app = self.app.clone();
210 let group = SharedString::from(format!("quick-row-group-{index}"));
211 let (conversation_id, message_id) = (row.conversation_id.clone(), row.message_id.clone());
212 let unsave = row.saved.clone().map(|item| {
213 div()
214 .id(ElementId::Name(format!("quick-unsave-{index}").into()))
215 .absolute()
216 .right(px(8.))
217 .top(px(8.))
218 .size(px(BUTTON_SIZE))
219 .flex()
220 .items_center()
221 .justify_center()
222 .rounded(px(6.))
223 .cursor_pointer()
224 .invisible()
225 .group_hover(group.clone(), |button| button.visible())
226 .hover(|button| button.bg(theme::popup_hover()))
227 .child(icon(IconName::BookmarkOff, 14., theme::text_muted()))
228 .tooltip(|window, cx| Tooltip::new("Unsave").build(window, cx))
229 .on_click(move |_, _, cx| {
230 cx.stop_propagation();
231 let entry = item.clone();
232 app.update(cx, |state, cx| state.set_saved(entry, false, cx));
233 })
234 });
235 let directory = &self.app.read(cx).directory;
236 h_flex()
237 .id(ElementId::Name(format!("quick-row-{index}").into()))
238 .group(group.clone())
239 .relative()
240 .w_full()
241 .p(px(12.))
242 .gap(px(12.))
243 .items_start()
244 .rounded(px(8.))
245 .cursor_pointer()
246 .hover(|row| row.bg(theme::row_hover()))
247 .child(div().flex_none().size(px(AVATAR_SIZE)).child(person_avatar(
248 directory,
249 row.author_id.as_deref(),
250 &row.author,
251 AVATAR_SIZE,
252 )))
253 .child(
254 v_flex()
255 .flex_1()
256 .min_w_0()
257 .gap(px(2.))
258 .child(
259 h_flex()
260 .gap(px(8.))
261 .items_baseline()
262 .child(
263 div()
264 .flex_none()
265 .text_size(px(14.))
266 .font_weight(FontWeight::SEMIBOLD)
267 .text_color(theme::text())
268 .child(row.author.clone()),
269 )
270 .child(
271 div()
272 .flex_1()
273 .min_w_0()
274 .truncate()
275 .text_size(px(12.))
276 .text_color(theme::text_muted())
277 .child(row.place.clone()),
278 )
279 .child(
280 div()
281 .flex_none()
282 .pr(px(BUTTON_SIZE + 8.))
283 .text_size(px(12.))
284 .text_color(theme::text_muted())
285 .child(row.time.clone()),
286 ),
287 )
288 .child(
289 div()
290 .line_clamp(PREVIEW_LINES)
291 .text_ellipsis()
292 .text_size(px(14.))
293 .line_height(relative(1.4))
294 .text_color(theme::text_soft())
295 .child(row.preview.clone()),
296 ),
297 )
298 .children(unsave)
299 .on_click(cx.listener(move |_, _, _, cx| {
300 cx.emit(QuickViewEvent::Open {
301 conversation_id: conversation_id.clone(),
302 message_id: message_id.clone(),
303 });
304 }))
305 .into_any_element()
306 }
307}
308
309impl Render for QuickViewPane {
310 fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
311 let view = self.app.read(cx).quick_view.unwrap_or(QuickView::Saved);
312 let rows = self.rows(view, cx);
313 let mut list: Vec<AnyElement> = rows
314 .iter()
315 .enumerate()
316 .map(|(index, row)| self.row(row, index, cx))
317 .collect();
318 if list.is_empty() {
319 list.push(
320 div()
321 .py(px(32.))
322 .px(px(24.))
323 .flex()
324 .justify_center()
325 .text_center()
326 .text_size(px(13.))
327 .text_color(theme::text_muted())
328 .child(view.empty_text())
329 .into_any_element(),
330 );
331 }
332 v_flex()
333 .debug_selector(|| "shell/islands/main".into())
334 .flex_1()
335 .w_full()
336 .min_w_0()
337 .h_full()
338 .rounded(px(10.))
339 .bg(theme::surface())
340 .overflow_hidden()
341 .child(self.header(view, rows.len()))
342 .child(div().w_full().h(px(1.)).flex_none().bg(theme::border()))
343 .child(with_top_edge(
344 v_flex()
345 .id("quick-view-list")
346 .flex_1()
347 .min_h_0()
348 .px(px(HEADER_PADDING - 12.))
349 .py(px(8.))
350 .overflow_y_scrollbar()
351 .track_scroll(&self.scroll)
352 .child(v_flex().w_full().max_w(px(LIST_MAX_WIDTH)).children(list)),
353 &self.scroll,
354 QUICK_VIEW_SCROLL_DIVIDER,
355 ))
356 }
357}
358
359#[cfg(test)]
360mod tests {
361 use std::collections::HashMap;
362
363 use chrono::{FixedOffset, NaiveDate, TimeZone, Utc};
364 use store::Sidebar;
365
366 use super::{draft_rows, mention_rows};
367 use crate::activity::{Actor, Entry, Kind};
368 use crate::local_previews::LocalPreview;
369
370 fn entry(id: &str, kind: Kind, minute: u32) -> Entry {
371 Entry {
372 id: id.to_owned(),
373 conversation_id: "19:chat".to_owned(),
374 kind,
375 message_id: format!("m-{id}"),
376 actors: vec![Actor {
377 user_id: Some("ada".to_owned()),
378 name: "Ada".to_owned(),
379 }],
380 preview: "@Dana look".to_owned(),
381 updated_at: Utc.with_ymd_and_hms(2026, 11, 8, 9, minute, 0).unwrap(),
382 ..Entry::default()
383 }
384 }
385
386
387 #[test]
388 fn mentions_list_only_mentions_newest_first() {
389 let entries = [
390 entry("a", Kind::Mention, 1),
391 entry("b", Kind::Reaction, 2),
392 entry("c", Kind::Mention, 3),
393 ];
394 let offset = FixedOffset::east_opt(0).unwrap();
395 let today = NaiveDate::from_ymd_opt(2026, 11, 8).unwrap();
396 let rows = mention_rows(&entries, &Sidebar::default(), today, offset);
397 let ids: Vec<_> = rows.iter().map(|row| row.message_id.clone().unwrap()).collect();
398 assert_eq!(ids, ["m-c", "m-a"]);
399 assert_eq!(rows[0].author, "Ada");
400 }
401
402 #[test]
403 fn drafts_skip_unsent_and_unknown_conversations() {
404 let previews = HashMap::from([
405 ("19:gone".to_owned(), LocalPreview::Draft("lost".to_owned())),
406 ("19:chat".to_owned(), LocalPreview::NotSent),
407 ]);
408 assert!(draft_rows(&previews, &Sidebar::default()).is_empty());
409 }
410}
crates/app/src/views/rail.rs +7 −16
@@ -87,13 +87,6 @@ fn rail_items(
87 87 icon: IconName::Phone,
88 88 badge: RailBadge::None,
89 89 },
90 RailItem {
91 tab: SidebarTab::Saved,
92 label: "Saved",
93 shortcut_label: "Open Saved",
94 icon: IconName::Bookmark,
95 badge: RailBadge::None,
96 },
97 90 ];
98 91 if let Some(running) = agents_running {
99 92 items.push(RailItem {
@@ -275,21 +268,20 @@ mod tests {
275 268 SidebarTab::Chats,
276 269 SidebarTab::Channels,
277 270 SidebarTab::Calendar,
278 SidebarTab::Calls,
279 SidebarTab::Saved
271 SidebarTab::Calls
280 272 ]
281 273 );
282 274 }
283 275
284 276 #[test]
285 277 fn agents_comes_last_and_only_when_actions_exist() {
286 assert_eq!(rail_items(0, 0, false, None).len(), 6);
278 assert_eq!(rail_items(0, 0, false, None).len(), 5);
287 279 let with_agents = rail_items(0, 0, false, Some(2));
288 assert_eq!(with_agents.len(), 7);
289 assert_eq!(with_agents[6].tab, SidebarTab::Agents);
290 assert_eq!(with_agents[6].label, "Agents");
291 assert_eq!(with_agents[6].badge, RailBadge::Count(2));
292 assert_eq!(rail_items(0, 0, false, Some(0))[6].badge, RailBadge::None);
280 assert_eq!(with_agents.len(), 6);
281 assert_eq!(with_agents[5].tab, SidebarTab::Agents);
282 assert_eq!(with_agents[5].label, "Agents");
283 assert_eq!(with_agents[5].badge, RailBadge::Count(2));
284 assert_eq!(rail_items(0, 0, false, Some(0))[5].badge, RailBadge::None);
293 285 }
294 286
295 287 #[test]
@@ -300,7 +292,6 @@ mod tests {
300 292 assert_eq!(items[2].badge, RailBadge::Dot);
301 293 assert_eq!(items[3].badge, RailBadge::None);
302 294 assert_eq!(items[4].badge, RailBadge::None);
303 assert_eq!(items[5].badge, RailBadge::None);
304 295 let quiet = rail_items(0, 0, false, None);
305 296 assert!(quiet.iter().all(|item| item.badge == RailBadge::None));
306 297 assert_eq!(count_badge_for(usize::MAX), RailBadge::Count(u32::MAX));
@@ -87,13 +87,6 @@ fn rail_items(
87 icon: IconName::Phone,
87 icon: IconName::Phone,
88 badge: RailBadge::None,
88 badge: RailBadge::None,
89 },
89 },
90 RailItem {
91 tab: SidebarTab::Saved,
92 label: "Saved",
93 shortcut_label: "Open Saved",
94 icon: IconName::Bookmark,
95 badge: RailBadge::None,
96 },
97 ];
90 ];
98 if let Some(running) = agents_running {
91 if let Some(running) = agents_running {
99 items.push(RailItem {
92 items.push(RailItem {
@@ -275,21 +268,20 @@ mod tests {
275 SidebarTab::Chats,
268 SidebarTab::Chats,
276 SidebarTab::Channels,
269 SidebarTab::Channels,
277 SidebarTab::Calendar,
270 SidebarTab::Calendar,
278 SidebarTab::Calls,
271 SidebarTab::Calls
279 SidebarTab::Saved
280 ]
272 ]
281 );
273 );
282 }
274 }
283
275
284 #[test]
276 #[test]
285 fn agents_comes_last_and_only_when_actions_exist() {
277 fn agents_comes_last_and_only_when_actions_exist() {
286 assert_eq!(rail_items(0, 0, false, None).len(), 6);
278 assert_eq!(rail_items(0, 0, false, None).len(), 5);
287 let with_agents = rail_items(0, 0, false, Some(2));
279 let with_agents = rail_items(0, 0, false, Some(2));
288 assert_eq!(with_agents.len(), 7);
280 assert_eq!(with_agents.len(), 6);
289 assert_eq!(with_agents[6].tab, SidebarTab::Agents);
281 assert_eq!(with_agents[5].tab, SidebarTab::Agents);
290 assert_eq!(with_agents[6].label, "Agents");
282 assert_eq!(with_agents[5].label, "Agents");
291 assert_eq!(with_agents[6].badge, RailBadge::Count(2));
283 assert_eq!(with_agents[5].badge, RailBadge::Count(2));
292 assert_eq!(rail_items(0, 0, false, Some(0))[6].badge, RailBadge::None);
284 assert_eq!(rail_items(0, 0, false, Some(0))[5].badge, RailBadge::None);
293 }
285 }
294
286
295 #[test]
287 #[test]
@@ -300,7 +292,6 @@ mod tests {
300 assert_eq!(items[2].badge, RailBadge::Dot);
292 assert_eq!(items[2].badge, RailBadge::Dot);
301 assert_eq!(items[3].badge, RailBadge::None);
293 assert_eq!(items[3].badge, RailBadge::None);
302 assert_eq!(items[4].badge, RailBadge::None);
294 assert_eq!(items[4].badge, RailBadge::None);
303 assert_eq!(items[5].badge, RailBadge::None);
304 let quiet = rail_items(0, 0, false, None);
295 let quiet = rail_items(0, 0, false, None);
305 assert!(quiet.iter().all(|item| item.badge == RailBadge::None));
296 assert!(quiet.iter().all(|item| item.badge == RailBadge::None));
306 assert_eq!(count_badge_for(usize::MAX), RailBadge::Count(u32::MAX));
297 assert_eq!(count_badge_for(usize::MAX), RailBadge::Count(u32::MAX));
crates/app/src/views/saved_panel.rs deleted +0 −249
@@ -1,249 +0,0 @@
1 use chrono::{DateTime, Local, Offset};
2 use gpui_kit::component::scroll::ScrollableElement as _;
3 use gpui_kit::assets::IconName;
4 use gpui_kit::component::{h_flex, tooltip::Tooltip, v_flex};
5 use gpui_kit::*;
6 use teams_core::SavedMessage;
7
8 use super::avatar::person_avatar;
9 use super::scroll_edge::with_top_edge;
10 use super::sidebar::SIDEBAR_SCROLL_DIVIDER;
11 use super::widgets::icon;
12 use crate::app_state::{AppState, selection_for, selection_title};
13 use crate::format;
14 use crate::theme;
15
16 const AVATAR_SIZE: f32 = 32.;
17 const BUTTON_SIZE: f32 = 24.;
18 const PREVIEW_LINES: usize = 2;
19 const EMPTY_TEXT: &str = "No saved messages. Use Save message in the ... menu of a message.";
20 const UNKNOWN_AUTHOR: &str = "Unknown";
21
22 pub enum SavedPanelEvent {
23 Open {
24 conversation_id: String,
25 message_id: String,
26 },
27 }
28
29 pub struct SavedPanel {
30 app: Entity<AppState>,
31 scroll: ScrollHandle,
32 _observation: Subscription,
33 }
34
35 impl EventEmitter<SavedPanelEvent> for SavedPanel {}
36
37 pub fn count_label(count: usize) -> String {
38 match count {
39 0 => String::new(),
40 count => count.to_string(),
41 }
42 }
43
44 impl SavedPanel {
45 pub fn new(app: Entity<AppState>, cx: &mut Context<Self>) -> Self {
46 let observation = cx.observe(&app, |_, _, cx| cx.notify());
47 SavedPanel {
48 app,
49 scroll: ScrollHandle::new(),
50 _observation: observation,
51 }
52 }
53
54 fn header(&self, count: usize) -> Div {
55 h_flex()
56 .h(px(52.))
57 .flex_none()
58 .pl(px(16.))
59 .pr(px(12.))
60 .gap(px(8.))
61 .items_center()
62 .child(
63 div()
64 .text_size(px(16.))
65 .font_weight(FontWeight::BOLD)
66 .text_color(theme::text())
67 .child("Saved"),
68 )
69 .child(
70 div()
71 .text_size(px(12.))
72 .text_color(theme::text_muted())
73 .child(count_label(count)),
74 )
75 }
76
77 fn row(
78 &self,
79 item: &SavedMessage,
80 index: usize,
81 title: String,
82 panel: Entity<SavedPanel>,
83 cx: &App,
84 ) -> AnyElement {
85 let app = self.app.clone();
86 let state = self.app.read(cx);
87 let now = Local::now();
88 let author = item.author_name.as_deref().unwrap_or(UNKNOWN_AUTHOR);
89 let group = SharedString::from(format!("saved-row-group-{index}"));
90 let (conversation_id, message_id) = (item.conversation_id.clone(), item.message_id.clone());
91 let unsave_item = item.clone();
92 h_flex()
93 .id(ElementId::Name(format!("saved-row-{index}").into()))
94 .group(group.clone())
95 .relative()
96 .mx(px(6.))
97 .p(px(10.))
98 .gap(px(12.))
99 .items_start()
100 .rounded(px(8.))
101 .cursor_pointer()
102 .hover(|row| row.bg(theme::row_hover()))
103 .child(div().flex_none().size(px(AVATAR_SIZE)).child(person_avatar(
104 &state.directory,
105 item.author_id.as_deref(),
106 author,
107 AVATAR_SIZE,
108 )))
109 .child(
110 v_flex()
111 .flex_1()
112 .min_w_0()
113 .gap(px(4.))
114 .child(
115 h_flex()
116 .gap(px(6.))
117 .items_baseline()
118 .child(
119 div()
120 .flex_none()
121 .text_size(px(13.))
122 .font_weight(FontWeight::SEMIBOLD)
123 .text_color(theme::text())
124 .child(author.to_owned()),
125 )
126 .child(
127 div()
128 .flex_1()
129 .min_w_0()
130 .truncate()
131 .text_size(px(12.))
132 .text_color(theme::text_muted())
133 .child(title),
134 )
135 .child(
136 div()
137 .flex_none()
138 .text_size(px(11.))
139 .text_color(theme::text_muted())
140 .child(saved_time(item.saved_at, now)),
141 ),
142 )
143 .child(
144 div()
145 .line_clamp(PREVIEW_LINES).text_ellipsis()
146 .text_size(px(13.))
147 .line_height(relative(1.4))
148 .text_color(theme::text_soft())
149 .child(item.preview.clone()),
150 ),
151 )
152 .child(
153 div()
154 .id(ElementId::Name(format!("saved-unsave-{index}").into()))
155 .absolute()
156 .right(px(6.))
157 .bottom(px(6.))
158 .size(px(BUTTON_SIZE))
159 .flex()
160 .items_center()
161 .justify_center()
162 .rounded(px(6.))
163 .bg(theme::surface_raised())
164 .cursor_pointer()
165 .opacity(0.)
166 .group_hover(group, |button| button.opacity(1.))
167 .hover(|button| button.bg(theme::border_strong()))
168 .child(icon(IconName::BookmarkOff, 14., theme::text_muted()))
169 .tooltip(|window, cx| Tooltip::new("Unsave").build(window, cx))
170 .on_click(move |_, _, cx| {
171 cx.stop_propagation();
172 let entry = unsave_item.clone();
173 app.update(cx, |state, cx| state.set_saved(entry, false, cx));
174 }),
175 )
176 .on_click(move |_, _, cx| {
177 let event = SavedPanelEvent::Open {
178 conversation_id: conversation_id.clone(),
179 message_id: message_id.clone(),
180 };
181 panel.update(cx, |_, cx| cx.emit(event));
182 })
183 .into_any_element()
184 }
185 }
186
187 fn saved_time(saved_at: DateTime<chrono::Utc>, now: DateTime<Local>) -> String {
188 format::list_time_label(saved_at, now.date_naive(), now.offset().fix())
189 }
190
191 impl Render for SavedPanel {
192 fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
193 let panel = cx.entity();
194 let state = self.app.read(cx);
195 let items = state.saved.items().to_vec();
196 let mut rows: Vec<AnyElement> = items
197 .iter()
198 .enumerate()
199 .map(|(index, item)| {
200 let title = selection_for(&state.sidebar, &item.conversation_id)
201 .map(|selection| selection_title(&state.sidebar, &selection))
202 .or_else(|| item.topic.clone())
203 .unwrap_or_default();
204 self.row(item, index, title, panel.clone(), cx)
205 })
206 .collect();
207 if rows.is_empty() {
208 rows.push(
209 div()
210 .py(px(32.))
211 .px(px(24.))
212 .flex()
213 .justify_center()
214 .text_center()
215 .text_size(px(13.))
216 .text_color(theme::text_muted())
217 .child(EMPTY_TEXT)
218 .into_any_element(),
219 );
220 }
221 v_flex()
222 .flex_1()
223 .min_h_0()
224 .child(self.header(items.len()))
225 .child(with_top_edge(
226 v_flex()
227 .id("saved-list")
228 .flex_1()
229 .min_h_0()
230 .pb(px(12.))
231 .overflow_y_scrollbar()
232 .track_scroll(&self.scroll)
233 .children(rows),
234 &self.scroll,
235 SIDEBAR_SCROLL_DIVIDER,
236 ))
237 }
238 }
239
240 #[cfg(test)]
241 mod tests {
242 use super::count_label;
243
244 #[test]
245 fn the_header_count_is_hidden_when_nothing_is_saved() {
246 assert_eq!(count_label(0), "");
247 assert_eq!(count_label(2), "2");
248 }
249 }
@@ -1,249 +0,0 @@
1use chrono::{DateTime, Local, Offset};
2use gpui_kit::component::scroll::ScrollableElement as _;
3use gpui_kit::assets::IconName;
4use gpui_kit::component::{h_flex, tooltip::Tooltip, v_flex};
5use gpui_kit::*;
6use teams_core::SavedMessage;
7
8use super::avatar::person_avatar;
9use super::scroll_edge::with_top_edge;
10use super::sidebar::SIDEBAR_SCROLL_DIVIDER;
11use super::widgets::icon;
12use crate::app_state::{AppState, selection_for, selection_title};
13use crate::format;
14use crate::theme;
15
16const AVATAR_SIZE: f32 = 32.;
17const BUTTON_SIZE: f32 = 24.;
18const PREVIEW_LINES: usize = 2;
19const EMPTY_TEXT: &str = "No saved messages. Use Save message in the ... menu of a message.";
20const UNKNOWN_AUTHOR: &str = "Unknown";
21
22pub enum SavedPanelEvent {
23 Open {
24 conversation_id: String,
25 message_id: String,
26 },
27}
28
29pub struct SavedPanel {
30 app: Entity<AppState>,
31 scroll: ScrollHandle,
32 _observation: Subscription,
33}
34
35impl EventEmitter<SavedPanelEvent> for SavedPanel {}
36
37pub fn count_label(count: usize) -> String {
38 match count {
39 0 => String::new(),
40 count => count.to_string(),
41 }
42}
43
44impl SavedPanel {
45 pub fn new(app: Entity<AppState>, cx: &mut Context<Self>) -> Self {
46 let observation = cx.observe(&app, |_, _, cx| cx.notify());
47 SavedPanel {
48 app,
49 scroll: ScrollHandle::new(),
50 _observation: observation,
51 }
52 }
53
54 fn header(&self, count: usize) -> Div {
55 h_flex()
56 .h(px(52.))
57 .flex_none()
58 .pl(px(16.))
59 .pr(px(12.))
60 .gap(px(8.))
61 .items_center()
62 .child(
63 div()
64 .text_size(px(16.))
65 .font_weight(FontWeight::BOLD)
66 .text_color(theme::text())
67 .child("Saved"),
68 )
69 .child(
70 div()
71 .text_size(px(12.))
72 .text_color(theme::text_muted())
73 .child(count_label(count)),
74 )
75 }
76
77 fn row(
78 &self,
79 item: &SavedMessage,
80 index: usize,
81 title: String,
82 panel: Entity<SavedPanel>,
83 cx: &App,
84 ) -> AnyElement {
85 let app = self.app.clone();
86 let state = self.app.read(cx);
87 let now = Local::now();
88 let author = item.author_name.as_deref().unwrap_or(UNKNOWN_AUTHOR);
89 let group = SharedString::from(format!("saved-row-group-{index}"));
90 let (conversation_id, message_id) = (item.conversation_id.clone(), item.message_id.clone());
91 let unsave_item = item.clone();
92 h_flex()
93 .id(ElementId::Name(format!("saved-row-{index}").into()))
94 .group(group.clone())
95 .relative()
96 .mx(px(6.))
97 .p(px(10.))
98 .gap(px(12.))
99 .items_start()
100 .rounded(px(8.))
101 .cursor_pointer()
102 .hover(|row| row.bg(theme::row_hover()))
103 .child(div().flex_none().size(px(AVATAR_SIZE)).child(person_avatar(
104 &state.directory,
105 item.author_id.as_deref(),
106 author,
107 AVATAR_SIZE,
108 )))
109 .child(
110 v_flex()
111 .flex_1()
112 .min_w_0()
113 .gap(px(4.))
114 .child(
115 h_flex()
116 .gap(px(6.))
117 .items_baseline()
118 .child(
119 div()
120 .flex_none()
121 .text_size(px(13.))
122 .font_weight(FontWeight::SEMIBOLD)
123 .text_color(theme::text())
124 .child(author.to_owned()),
125 )
126 .child(
127 div()
128 .flex_1()
129 .min_w_0()
130 .truncate()
131 .text_size(px(12.))
132 .text_color(theme::text_muted())
133 .child(title),
134 )
135 .child(
136 div()
137 .flex_none()
138 .text_size(px(11.))
139 .text_color(theme::text_muted())
140 .child(saved_time(item.saved_at, now)),
141 ),
142 )
143 .child(
144 div()
145 .line_clamp(PREVIEW_LINES).text_ellipsis()
146 .text_size(px(13.))
147 .line_height(relative(1.4))
148 .text_color(theme::text_soft())
149 .child(item.preview.clone()),
150 ),
151 )
152 .child(
153 div()
154 .id(ElementId::Name(format!("saved-unsave-{index}").into()))
155 .absolute()
156 .right(px(6.))
157 .bottom(px(6.))
158 .size(px(BUTTON_SIZE))
159 .flex()
160 .items_center()
161 .justify_center()
162 .rounded(px(6.))
163 .bg(theme::surface_raised())
164 .cursor_pointer()
165 .opacity(0.)
166 .group_hover(group, |button| button.opacity(1.))
167 .hover(|button| button.bg(theme::border_strong()))
168 .child(icon(IconName::BookmarkOff, 14., theme::text_muted()))
169 .tooltip(|window, cx| Tooltip::new("Unsave").build(window, cx))
170 .on_click(move |_, _, cx| {
171 cx.stop_propagation();
172 let entry = unsave_item.clone();
173 app.update(cx, |state, cx| state.set_saved(entry, false, cx));
174 }),
175 )
176 .on_click(move |_, _, cx| {
177 let event = SavedPanelEvent::Open {
178 conversation_id: conversation_id.clone(),
179 message_id: message_id.clone(),
180 };
181 panel.update(cx, |_, cx| cx.emit(event));
182 })
183 .into_any_element()
184 }
185}
186
187fn saved_time(saved_at: DateTime<chrono::Utc>, now: DateTime<Local>) -> String {
188 format::list_time_label(saved_at, now.date_naive(), now.offset().fix())
189}
190
191impl Render for SavedPanel {
192 fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
193 let panel = cx.entity();
194 let state = self.app.read(cx);
195 let items = state.saved.items().to_vec();
196 let mut rows: Vec<AnyElement> = items
197 .iter()
198 .enumerate()
199 .map(|(index, item)| {
200 let title = selection_for(&state.sidebar, &item.conversation_id)
201 .map(|selection| selection_title(&state.sidebar, &selection))
202 .or_else(|| item.topic.clone())
203 .unwrap_or_default();
204 self.row(item, index, title, panel.clone(), cx)
205 })
206 .collect();
207 if rows.is_empty() {
208 rows.push(
209 div()
210 .py(px(32.))
211 .px(px(24.))
212 .flex()
213 .justify_center()
214 .text_center()
215 .text_size(px(13.))
216 .text_color(theme::text_muted())
217 .child(EMPTY_TEXT)
218 .into_any_element(),
219 );
220 }
221 v_flex()
222 .flex_1()
223 .min_h_0()
224 .child(self.header(items.len()))
225 .child(with_top_edge(
226 v_flex()
227 .id("saved-list")
228 .flex_1()
229 .min_h_0()
230 .pb(px(12.))
231 .overflow_y_scrollbar()
232 .track_scroll(&self.scroll)
233 .children(rows),
234 &self.scroll,
235 SIDEBAR_SCROLL_DIVIDER,
236 ))
237 }
238}
239
240#[cfg(test)]
241mod tests {
242 use super::count_label;
243
244 #[test]
245 fn the_header_count_is_hidden_when_nothing_is_saved() {
246 assert_eq!(count_label(0), "");
247 assert_eq!(count_label(2), "2");
248 }
249}
crates/app/src/views/shell.rs +37 −9
@@ -21,7 +21,7 @@ use super::profile_card::{ProfileCard, ProfileCardEvent};
21 21 use gpui_kit::prelude::FluentBuilder as _;
22 22 use super::rail::RailView;
23 23 use crate::chat_filter::ChatFilterPill;
24 use super::saved_panel::{SavedPanel, SavedPanelEvent};
24 use super::quick_view_pane::{QuickViewEvent, QuickViewPane};
25 25 use super::shortcuts::{
26 26 ClearChatFilters, DeclineCall, FilterMeetingChats, FilterMutedChats,
27 27 FilterNonMeetingChats, FilterUnreadChats, FindInChat, HangUpCall, JoinMeetingFromToast, JumpToLastReadOrNewest, NextConversation, OpenActivity,
@@ -45,7 +45,7 @@ use super::switcher::{Switcher, SwitcherEvent, candidates_from};
45 45 use super::title_bar::{mode_label, render_title_bar, update_button};
46 46 use crate::activity::ActivityCenter;
47 47 use crate::agents::{AgentRunsEvent, StartDialog, StartDialogEvent, StartRequest};
48 use crate::app_state::{AppEvent, AppState, Selection, selection_for};
48 use crate::app_state::{AppEvent, AppState, QuickView, Selection, selection_for};
49 49 use crate::call::{CallMedia, CallWindows, ZoomStep};
50 50 use crate::notice::NoticeAction;
51 51 use crate::notify::NotificationCenter;
@@ -154,6 +154,8 @@ pub struct AppShell {
154 154 rail: Entity<RailView>,
155 155 sidebar: Entity<SidebarView>,
156 156 calendar: Entity<CalendarView>,
157 quick_pane: Entity<QuickViewPane>,
158 shown_quick_view: Option<QuickView>,
157 159 conversation: Entity<ConversationView>,
158 160 call_chat: Option<(String, Entity<ConversationView>)>,
159 161 prejoin: Option<Entity<PrejoinView>>,
@@ -211,6 +213,15 @@ impl AppShell {
211 213 }
212 214 }
213 215
216 fn focus_opened_quick_view(&mut self, window: &mut Window, cx: &mut Context<Self>) {
217 let quick_view = self.state.read(cx).quick_view;
218 if std::mem::replace(&mut self.shown_quick_view, quick_view) != quick_view
219 && quick_view.is_some()
220 {
221 self.restore_focus(window, cx);
222 }
223 }
224
214 225 fn leave_calendar_on_selection(&mut self, cx: &mut Context<Self>) {
215 226 if self.sidebar.read(cx).tab() != SidebarTab::Calendar {
216 227 return;
@@ -255,7 +266,7 @@ impl AppShell {
255 266 });
256 267 let activity = cx.new(|cx| ActivityCenter::new(state.clone(), window, cx));
257 268 let activity_panel = cx.new(|cx| ActivityPanel::new(state.clone(), activity.clone(), cx));
258 let saved_panel = cx.new(|cx| SavedPanel::new(state.clone(), cx));
269 let quick_pane = cx.new(|cx| QuickViewPane::new(state.clone(), activity.clone(), cx));
259 270 let agents_panel = crate::agents::runs_handle(cx)
260 271 .map(|runs| cx.new(|cx| crate::agents::AgentsPanel::new(runs, cx)));
261 272 let agents_subscription = agents_panel.as_ref().map(|panel| {
@@ -290,12 +301,14 @@ impl AppShell {
290 301 }
291 302 },
292 303 ),
293 cx.subscribe(&saved_panel, |this, _, event: &SavedPanelEvent, cx| {
294 let SavedPanelEvent::Open {
304 cx.subscribe(&quick_pane, |this, _, event: &QuickViewEvent, cx| {
305 let QuickViewEvent::Open {
295 306 conversation_id,
296 307 message_id,
297 308 } = event;
298 this.open_message(conversation_id, message_id, cx);
309 this.state
310 .update(cx, |state, cx| state.close_quick_view(cx));
311 this.open_message(conversation_id, message_id.as_deref().unwrap_or_default(), cx);
299 312 }),
300 313 ];
301 314 let agent_subscription = crate::agents::runs_handle(cx).map(|runs| {
@@ -313,7 +326,7 @@ impl AppShell {
313 326 },
314 327 )
315 328 });
316 let sidebar = cx.new(|cx| SidebarView::new(state.clone(), activity_panel, saved_panel, agents_panel, cx));
329 let sidebar = cx.new(|cx| SidebarView::new(state.clone(), activity_panel, agents_panel, cx));
317 330 let sidebar_subscription = cx.subscribe_in(&sidebar, window, |this, _, event: &SidebarEvent, window, cx| {
318 331 match event {
319 332 SidebarEvent::RestoreFocus => this.restore_focus(window, cx),
@@ -335,6 +348,9 @@ impl AppShell {
335 348 if matches!(event, AppEvent::Sidebar | AppEvent::Status) {
336 349 this.apply_open_target(cx);
337 350 }
351 if matches!(event, AppEvent::Sidebar) {
352 this.focus_opened_quick_view(window, cx);
353 }
338 354 if matches!(event, AppEvent::Selection) {
339 355 this.leave_calendar_on_selection(cx);
340 356 }
@@ -387,6 +403,8 @@ impl AppShell {
387 403 rail,
388 404 sidebar,
389 405 calendar,
406 quick_pane,
407 shown_quick_view: None,
390 408 conversation,
391 409 call_chat: None,
392 410 prejoin: None,
@@ -882,6 +900,7 @@ impl AppShell {
882 900 call_view: Option<AnyElement>,
883 901 show_sidebar: bool,
884 902 calendar_open: bool,
903 quick_view_open: bool,
885 904 ) -> impl IntoElement {
886 905 h_flex()
887 906 .debug_selector(|| "shell/islands".into())
@@ -912,6 +931,11 @@ impl AppShell {
912 931 (None, Some(prejoin)) => prejoin
913 932 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
914 933 .into_any_element(),
934 (None, None) if quick_view_open => self
935 .quick_pane
936 .clone()
937 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
938 .into_any_element(),
915 939 (None, None) if calendar_open => self
916 940 .calendar
917 941 .clone()
@@ -984,6 +1008,7 @@ impl Render for AppShell {
984 1008 self.toasts.update_failed(update_failure.as_deref(), window, cx);
985 1009 let chat_panel = self.call_chat.as_ref().map(|(_, view)| view.clone().into());
986 1010 let calendar_tab = self.sidebar.read(cx).tab() == SidebarTab::Calendar;
1011 let chats_tab = self.sidebar.read(cx).tab() == SidebarTab::Chats;
987 1012 let state = self.state.read(cx);
988 1013 let call_fullscreen = state.call_fullscreen();
989 1014 let window_width = f32::from(window.viewport_size().width);
@@ -992,6 +1017,7 @@ impl Render for AppShell {
992 1017 .as_ref()
993 1018 .is_some_and(|call| call.chat_open || call.people_open || call.transcript_open);
994 1019 let calendar_open = calendar_tab && !state.viewing_call();
1020 let quick_view_open = chats_tab && state.quick_view.is_some();
995 1021 let show_sidebar = !calendar_open
996 1022 && !(state.viewing_call()
997 1023 && !call_fullscreen
@@ -1082,7 +1108,7 @@ impl Render for AppShell {
1082 1108 .on_action(cx.listener(|this, _: &OpenSaved, window, cx| {
1083 1109 this.close_image_viewer(window, cx);
1084 1110 this.sidebar
1085 .update(cx, |sidebar, cx| sidebar.show_saved(cx));
1111 .update(cx, |sidebar, cx| sidebar.open_quick_view(QuickView::Saved, cx));
1086 1112 }))
1087 1113 .on_action(cx.listener(|this, _: &OpenCalendar, window, cx| {
1088 1114 this.close_image_viewer(window, cx);
@@ -1101,6 +1127,8 @@ impl Render for AppShell {
1101 1127 }))
1102 1128 .on_action(cx.listener(|this, _: &FindInChat, window, cx| {
1103 1129 this.close_image_viewer(window, cx);
1130 this.state
1131 .update(cx, |state, cx| state.close_quick_view(cx));
1104 1132 this.conversation
1105 1133 .update(cx, |conversation, cx| conversation.open_find(window, cx));
1106 1134 }))
@@ -1231,7 +1259,7 @@ impl Render for AppShell {
1231 1259 .size_full()
1232 1260 .child(title_bar)
1233 1261 .children(banner)
1234 .child(self.islands(call_view, show_sidebar, calendar_open)),
1262 .child(self.islands(call_view, show_sidebar, calendar_open, quick_view_open)),
1235 1263 )
1236 1264 .children(call_mini)
1237 1265 .children(call_overlay)
@@ -21,7 +21,7 @@ use super::profile_card::{ProfileCard, ProfileCardEvent};
21use gpui_kit::prelude::FluentBuilder as _;
21use gpui_kit::prelude::FluentBuilder as _;
22use super::rail::RailView;
22use super::rail::RailView;
23use crate::chat_filter::ChatFilterPill;
23use crate::chat_filter::ChatFilterPill;
24use super::saved_panel::{SavedPanel, SavedPanelEvent};
24use super::quick_view_pane::{QuickViewEvent, QuickViewPane};
25use super::shortcuts::{
25use super::shortcuts::{
26 ClearChatFilters, DeclineCall, FilterMeetingChats, FilterMutedChats,
26 ClearChatFilters, DeclineCall, FilterMeetingChats, FilterMutedChats,
27 FilterNonMeetingChats, FilterUnreadChats, FindInChat, HangUpCall, JoinMeetingFromToast, JumpToLastReadOrNewest, NextConversation, OpenActivity,
27 FilterNonMeetingChats, FilterUnreadChats, FindInChat, HangUpCall, JoinMeetingFromToast, JumpToLastReadOrNewest, NextConversation, OpenActivity,
@@ -45,7 +45,7 @@ use super::switcher::{Switcher, SwitcherEvent, candidates_from};
45use super::title_bar::{mode_label, render_title_bar, update_button};
45use super::title_bar::{mode_label, render_title_bar, update_button};
46use crate::activity::ActivityCenter;
46use crate::activity::ActivityCenter;
47use crate::agents::{AgentRunsEvent, StartDialog, StartDialogEvent, StartRequest};
47use crate::agents::{AgentRunsEvent, StartDialog, StartDialogEvent, StartRequest};
48use crate::app_state::{AppEvent, AppState, Selection, selection_for};
48use crate::app_state::{AppEvent, AppState, QuickView, Selection, selection_for};
49use crate::call::{CallMedia, CallWindows, ZoomStep};
49use crate::call::{CallMedia, CallWindows, ZoomStep};
50use crate::notice::NoticeAction;
50use crate::notice::NoticeAction;
51use crate::notify::NotificationCenter;
51use crate::notify::NotificationCenter;
@@ -154,6 +154,8 @@ pub struct AppShell {
154 rail: Entity<RailView>,
154 rail: Entity<RailView>,
155 sidebar: Entity<SidebarView>,
155 sidebar: Entity<SidebarView>,
156 calendar: Entity<CalendarView>,
156 calendar: Entity<CalendarView>,
157 quick_pane: Entity<QuickViewPane>,
158 shown_quick_view: Option<QuickView>,
157 conversation: Entity<ConversationView>,
159 conversation: Entity<ConversationView>,
158 call_chat: Option<(String, Entity<ConversationView>)>,
160 call_chat: Option<(String, Entity<ConversationView>)>,
159 prejoin: Option<Entity<PrejoinView>>,
161 prejoin: Option<Entity<PrejoinView>>,
@@ -211,6 +213,15 @@ impl AppShell {
211 }
213 }
212 }
214 }
213
215
216 fn focus_opened_quick_view(&mut self, window: &mut Window, cx: &mut Context<Self>) {
217 let quick_view = self.state.read(cx).quick_view;
218 if std::mem::replace(&mut self.shown_quick_view, quick_view) != quick_view
219 && quick_view.is_some()
220 {
221 self.restore_focus(window, cx);
222 }
223 }
224
214 fn leave_calendar_on_selection(&mut self, cx: &mut Context<Self>) {
225 fn leave_calendar_on_selection(&mut self, cx: &mut Context<Self>) {
215 if self.sidebar.read(cx).tab() != SidebarTab::Calendar {
226 if self.sidebar.read(cx).tab() != SidebarTab::Calendar {
216 return;
227 return;
@@ -255,7 +266,7 @@ impl AppShell {
255 });
266 });
256 let activity = cx.new(|cx| ActivityCenter::new(state.clone(), window, cx));
267 let activity = cx.new(|cx| ActivityCenter::new(state.clone(), window, cx));
257 let activity_panel = cx.new(|cx| ActivityPanel::new(state.clone(), activity.clone(), cx));
268 let activity_panel = cx.new(|cx| ActivityPanel::new(state.clone(), activity.clone(), cx));
258 let saved_panel = cx.new(|cx| SavedPanel::new(state.clone(), cx));
269 let quick_pane = cx.new(|cx| QuickViewPane::new(state.clone(), activity.clone(), cx));
259 let agents_panel = crate::agents::runs_handle(cx)
270 let agents_panel = crate::agents::runs_handle(cx)
260 .map(|runs| cx.new(|cx| crate::agents::AgentsPanel::new(runs, cx)));
271 .map(|runs| cx.new(|cx| crate::agents::AgentsPanel::new(runs, cx)));
261 let agents_subscription = agents_panel.as_ref().map(|panel| {
272 let agents_subscription = agents_panel.as_ref().map(|panel| {
@@ -290,12 +301,14 @@ impl AppShell {
290 }
301 }
291 },
302 },
292 ),
303 ),
293 cx.subscribe(&saved_panel, |this, _, event: &SavedPanelEvent, cx| {
304 cx.subscribe(&quick_pane, |this, _, event: &QuickViewEvent, cx| {
294 let SavedPanelEvent::Open {
305 let QuickViewEvent::Open {
295 conversation_id,
306 conversation_id,
296 message_id,
307 message_id,
297 } = event;
308 } = event;
298 this.open_message(conversation_id, message_id, cx);
309 this.state
310 .update(cx, |state, cx| state.close_quick_view(cx));
311 this.open_message(conversation_id, message_id.as_deref().unwrap_or_default(), cx);
299 }),
312 }),
300 ];
313 ];
301 let agent_subscription = crate::agents::runs_handle(cx).map(|runs| {
314 let agent_subscription = crate::agents::runs_handle(cx).map(|runs| {
@@ -313,7 +326,7 @@ impl AppShell {
313 },
326 },
314 )
327 )
315 });
328 });
316 let sidebar = cx.new(|cx| SidebarView::new(state.clone(), activity_panel, saved_panel, agents_panel, cx));
329 let sidebar = cx.new(|cx| SidebarView::new(state.clone(), activity_panel, agents_panel, cx));
317 let sidebar_subscription = cx.subscribe_in(&sidebar, window, |this, _, event: &SidebarEvent, window, cx| {
330 let sidebar_subscription = cx.subscribe_in(&sidebar, window, |this, _, event: &SidebarEvent, window, cx| {
318 match event {
331 match event {
319 SidebarEvent::RestoreFocus => this.restore_focus(window, cx),
332 SidebarEvent::RestoreFocus => this.restore_focus(window, cx),
@@ -335,6 +348,9 @@ impl AppShell {
335 if matches!(event, AppEvent::Sidebar | AppEvent::Status) {
348 if matches!(event, AppEvent::Sidebar | AppEvent::Status) {
336 this.apply_open_target(cx);
349 this.apply_open_target(cx);
337 }
350 }
351 if matches!(event, AppEvent::Sidebar) {
352 this.focus_opened_quick_view(window, cx);
353 }
338 if matches!(event, AppEvent::Selection) {
354 if matches!(event, AppEvent::Selection) {
339 this.leave_calendar_on_selection(cx);
355 this.leave_calendar_on_selection(cx);
340 }
356 }
@@ -387,6 +403,8 @@ impl AppShell {
387 rail,
403 rail,
388 sidebar,
404 sidebar,
389 calendar,
405 calendar,
406 quick_pane,
407 shown_quick_view: None,
390 conversation,
408 conversation,
391 call_chat: None,
409 call_chat: None,
392 prejoin: None,
410 prejoin: None,
@@ -882,6 +900,7 @@ impl AppShell {
882 call_view: Option<AnyElement>,
900 call_view: Option<AnyElement>,
883 show_sidebar: bool,
901 show_sidebar: bool,
884 calendar_open: bool,
902 calendar_open: bool,
903 quick_view_open: bool,
885 ) -> impl IntoElement {
904 ) -> impl IntoElement {
886 h_flex()
905 h_flex()
887 .debug_selector(|| "shell/islands".into())
906 .debug_selector(|| "shell/islands".into())
@@ -912,6 +931,11 @@ impl AppShell {
912 (None, Some(prejoin)) => prejoin
931 (None, Some(prejoin)) => prejoin
913 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
932 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
914 .into_any_element(),
933 .into_any_element(),
934 (None, None) if quick_view_open => self
935 .quick_pane
936 .clone()
937 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
938 .into_any_element(),
915 (None, None) if calendar_open => self
939 (None, None) if calendar_open => self
916 .calendar
940 .calendar
917 .clone()
941 .clone()
@@ -984,6 +1008,7 @@ impl Render for AppShell {
984 self.toasts.update_failed(update_failure.as_deref(), window, cx);
1008 self.toasts.update_failed(update_failure.as_deref(), window, cx);
985 let chat_panel = self.call_chat.as_ref().map(|(_, view)| view.clone().into());
1009 let chat_panel = self.call_chat.as_ref().map(|(_, view)| view.clone().into());
986 let calendar_tab = self.sidebar.read(cx).tab() == SidebarTab::Calendar;
1010 let calendar_tab = self.sidebar.read(cx).tab() == SidebarTab::Calendar;
1011 let chats_tab = self.sidebar.read(cx).tab() == SidebarTab::Chats;
987 let state = self.state.read(cx);
1012 let state = self.state.read(cx);
988 let call_fullscreen = state.call_fullscreen();
1013 let call_fullscreen = state.call_fullscreen();
989 let window_width = f32::from(window.viewport_size().width);
1014 let window_width = f32::from(window.viewport_size().width);
@@ -992,6 +1017,7 @@ impl Render for AppShell {
992 .as_ref()
1017 .as_ref()
993 .is_some_and(|call| call.chat_open || call.people_open || call.transcript_open);
1018 .is_some_and(|call| call.chat_open || call.people_open || call.transcript_open);
994 let calendar_open = calendar_tab && !state.viewing_call();
1019 let calendar_open = calendar_tab && !state.viewing_call();
1020 let quick_view_open = chats_tab && state.quick_view.is_some();
995 let show_sidebar = !calendar_open
1021 let show_sidebar = !calendar_open
996 && !(state.viewing_call()
1022 && !(state.viewing_call()
997 && !call_fullscreen
1023 && !call_fullscreen
@@ -1082,7 +1108,7 @@ impl Render for AppShell {
1082 .on_action(cx.listener(|this, _: &OpenSaved, window, cx| {
1108 .on_action(cx.listener(|this, _: &OpenSaved, window, cx| {
1083 this.close_image_viewer(window, cx);
1109 this.close_image_viewer(window, cx);
1084 this.sidebar
1110 this.sidebar
1085 .update(cx, |sidebar, cx| sidebar.show_saved(cx));
1111 .update(cx, |sidebar, cx| sidebar.open_quick_view(QuickView::Saved, cx));
1086 }))
1112 }))
1087 .on_action(cx.listener(|this, _: &OpenCalendar, window, cx| {
1113 .on_action(cx.listener(|this, _: &OpenCalendar, window, cx| {
1088 this.close_image_viewer(window, cx);
1114 this.close_image_viewer(window, cx);
@@ -1101,6 +1127,8 @@ impl Render for AppShell {
1101 }))
1127 }))
1102 .on_action(cx.listener(|this, _: &FindInChat, window, cx| {
1128 .on_action(cx.listener(|this, _: &FindInChat, window, cx| {
1103 this.close_image_viewer(window, cx);
1129 this.close_image_viewer(window, cx);
1130 this.state
1131 .update(cx, |state, cx| state.close_quick_view(cx));
1104 this.conversation
1132 this.conversation
1105 .update(cx, |conversation, cx| conversation.open_find(window, cx));
1133 .update(cx, |conversation, cx| conversation.open_find(window, cx));
1106 }))
1134 }))
@@ -1231,7 +1259,7 @@ impl Render for AppShell {
1231 .size_full()
1259 .size_full()
1232 .child(title_bar)
1260 .child(title_bar)
1233 .children(banner)
1261 .children(banner)
1234 .child(self.islands(call_view, show_sidebar, calendar_open)),
1262 .child(self.islands(call_view, show_sidebar, calendar_open, quick_view_open)),
1235 )
1263 )
1236 .children(call_mini)
1264 .children(call_mini)
1237 .children(call_overlay)
1265 .children(call_overlay)
crates/app/src/views/sidebar.rs +110 −14
@@ -21,7 +21,6 @@ use super::activity_panel::ActivityPanel;
21 21 use super::avatar::{spec_avatar, team_avatar, with_presence};
22 22 use super::calls_tab::calls_body;
23 23 use super::chat_menu::{ChatMenuTarget, MenuContext, chat_menu};
24 use super::saved_panel::SavedPanel;
25 24 use super::scroll_edge::{scroll_offset, with_top_edge};
26 25 use super::channel_admin_dialogs::{confirm_delete_channel, open_edit_channel_dialog};
27 26 use super::create_channel_dialog::open_create_channel_dialog;
@@ -29,7 +28,7 @@ use super::section_dialog::{SectionNameTarget, open_section_name_dialog};
29 28 use super::widgets::{count_badge, icon, menu_icon, page_header, symbol, unread_marker};
30 29 use crate::agents::AgentsPanel;
31 30 use super::last_views::LastViews;
32 use crate::app_state::{AppEvent, AppState, Selection};
31 use crate::app_state::{AppEvent, AppState, QuickView, Selection};
33 32 use crate::channel_menu::{
34 33 ChannelMenuItem, MenuEntry, TeamMenuItem, TeamMenuState, channel_menu_entries,
35 34 team_menu_entries,
@@ -62,6 +61,15 @@ const PROPOSAL_DOT_SIZE: f32 = 8.;
62 61 const PINNED_CHANNEL_HEIGHT: f32 = 48.;
63 62 const SECTION_HEIGHT: f32 = 30.;
64 63 const SECTION_GAP: f32 = 4.;
64 const QUICK_VIEWS_SECTION_ID: &str = "quick-views";
65 const QUICK_VIEWS_TITLE: &str = "Quick views";
66 const QUICK_ROW_HEIGHT: f32 = 32.;
67 const QUICK_ICON_SIZE: f32 = 18.;
68 const QUICK_VIEWS: [(QuickView, &str); 3] = [
69 (QuickView::Mentions, "fluent_mention"),
70 (QuickView::Drafts, "fluent_drafts"),
71 (QuickView::Saved, "fluent_bookmark"),
72 ];
65 73 const HINT_HEIGHT: f32 = 26.;
66 74 const SEE_MORE_HEIGHT: f32 = 28.;
67 75 const LOADING_OLDER_LABEL: &str = "Loading older chats";
@@ -97,7 +105,6 @@ pub enum SidebarTab {
97 105 Channels,
98 106 Calendar,
99 107 Calls,
100 Saved,
101 108 Agents,
102 109 }
103 110
@@ -109,7 +116,6 @@ impl SidebarTab {
109 116 SidebarTab::Channels => "Teams",
110 117 SidebarTab::Calendar => "Calendar",
111 118 SidebarTab::Calls => "Calls",
112 SidebarTab::Saved => "Saved",
113 119 SidebarTab::Agents => "Agents",
114 120 }
115 121 }
@@ -338,7 +344,6 @@ pub struct SidebarView {
338 344 state: Entity<AppState>,
339 345 tab: SidebarTab,
340 346 activity_panel: Entity<ActivityPanel>,
341 saved_panel: Entity<SavedPanel>,
342 347 agents_panel: Option<Entity<AgentsPanel>>,
343 348 collapsed_teams: HashSet<String>,
344 349 revealed_channel_teams: HashSet<String>,
@@ -407,7 +412,6 @@ impl SidebarView {
407 412 pub fn new(
408 413 state: Entity<AppState>,
409 414 activity_panel: Entity<ActivityPanel>,
410 saved_panel: Entity<SavedPanel>,
411 415 agents_panel: Option<Entity<AgentsPanel>>,
412 416 cx: &mut Context<Self>,
413 417 ) -> Self {
@@ -476,7 +480,6 @@ impl SidebarView {
476 480 state,
477 481 tab,
478 482 activity_panel,
479 saved_panel,
480 483 agents_panel,
481 484 collapsed_teams,
482 485 revealed_channel_teams: HashSet::new(),
@@ -525,8 +528,10 @@ impl SidebarView {
525 528 self.open_tab(SidebarTab::Calendar, cx);
526 529 }
527 530
528 pub fn show_saved(&mut self, cx: &mut Context<Self>) {
529 self.open_tab(SidebarTab::Saved, cx);
531 pub fn open_quick_view(&mut self, view: QuickView, cx: &mut Context<Self>) {
532 self.open_tab(SidebarTab::Chats, cx);
533 self.state
534 .update(cx, |state, cx| state.open_quick_view(view, cx));
530 535 }
531 536
532 537 pub fn show_agents(&mut self, cx: &mut Context<Self>) {
@@ -548,7 +553,6 @@ impl SidebarView {
548 553 state.refresh_call_history(cx);
549 554 state.refresh_calendar(cx);
550 555 }),
551 SidebarTab::Saved => self.state.update(cx, |state, cx| state.refresh_saved(cx)),
552 556 SidebarTab::Calendar => self.state.update(cx, |state, cx| state.open_calendar(cx)),
553 557 SidebarTab::Activity => {
554 558 let activity = self.activity_panel.read(cx).activity();
@@ -591,7 +595,6 @@ impl SidebarView {
591 595 SidebarTab::Activity
592 596 | SidebarTab::Calendar
593 597 | SidebarTab::Calls
594 | SidebarTab::Saved
595 598 | SidebarTab::Agents => None,
596 599 };
597 600 if let Some(selection) = selection {
@@ -846,6 +849,92 @@ impl SidebarView {
846 849 .context_menu(move |popup, _, _| section_menu(popup, &menu_state, &menu))
847 850 }
848 851
852 fn quick_views_section(&self, cx: &mut Context<Self>) -> (Div, f32) {
853 let (collapsed, open_view) = {
854 let state = self.state.read(cx);
855 (
856 state.collapsed.contains(QUICK_VIEWS_SECTION_ID),
857 state.quick_view,
858 )
859 };
860 let header = h_flex()
861 .id(QUICK_VIEWS_SECTION_ID)
862 .h(px(SECTION_HEIGHT))
863 .flex_none()
864 .mt(px(SECTION_GAP))
865 .mx(px(6.))
866 .px(px(10.))
867 .gap(px(6.))
868 .items_center()
869 .rounded(px(6.))
870 .cursor_pointer()
871 .hover(|header| header.bg(theme::row_hover()))
872 .child(icon(
873 if collapsed {
874 IconName::ChevronRight
875 } else {
876 IconName::ChevronDown
877 },
878 12.,
879 theme::text_muted(),
880 ))
881 .child(
882 div()
883 .flex_1()
884 .text_size(px(12.))
885 .font_weight(FontWeight::SEMIBOLD)
886 .text_color(theme::text_soft())
887 .child(QUICK_VIEWS_TITLE),
888 )
889 .on_click(cx.listener(|this, _, _, cx| {
890 this.state.update(cx, |state, cx| {
891 state.toggle_collapsed(QUICK_VIEWS_SECTION_ID, cx)
892 });
893 }));
894 let mut section = v_flex().w_full().child(header);
895 let mut height = SECTION_GAP + SECTION_HEIGHT;
896 if !collapsed {
897 for (view, glyph) in QUICK_VIEWS {
898 section = section.child(self.quick_view_row(view, glyph, open_view == Some(view), cx));
899 height += QUICK_ROW_HEIGHT;
900 }
901 }
902 (section, height)
903 }
904
905 fn quick_view_row(
906 &self,
907 view: QuickView,
908 glyph: &'static str,
909 selected: bool,
910 cx: &mut Context<Self>,
911 ) -> Stateful<Div> {
912 h_flex()
913 .id(SharedString::from(format!("quick-view-{}", view.title())))
914 .debug_selector(move || format!("quick-view/{}", view.title()))
915 .h(px(QUICK_ROW_HEIGHT))
916 .flex_none()
917 .mx(px(6.))
918 .px(px(10.))
919 .gap(px(10.))
920 .items_center()
921 .rounded(px(8.))
922 .cursor_pointer()
923 .when(selected, |row| row.bg(theme::surface_raised()))
924 .when(!selected, |row| row.hover(|row| row.bg(theme::row_hover())))
925 .child(symbol(glyph, QUICK_ICON_SIZE, theme::text_soft()))
926 .child(
927 div()
928 .text_size(px(13.))
929 .text_color(theme::text())
930 .child(view.title()),
931 )
932 .on_click(cx.listener(move |this, _, _, cx| {
933 this.state
934 .update(cx, |state, cx| state.open_quick_view(view, cx));
935 }))
936 }
937
849 938 fn see_more_row(&self, section: &Section, cx: &mut Context<Self>) -> impl IntoElement {
850 939 let toggle_id = section.id.clone();
851 940 let label = if section.hidden_count > 0 {
@@ -1111,7 +1200,10 @@ impl SidebarView {
1111 1200 let (selected, drafting) = {
1112 1201 let state = self.state.read(cx);
1113 1202 (
1114 state.selection.clone().filter(|_| !state.new_chat),
1203 state
1204 .selection
1205 .clone()
1206 .filter(|_| !state.new_chat && state.quick_view.is_none()),
1115 1207 state.new_chat,
1116 1208 )
1117 1209 };
@@ -1126,6 +1218,11 @@ impl SidebarView {
1126 1218 list = list.child(self.draft_row());
1127 1219 y += ROW_HEIGHT;
1128 1220 }
1221 if !self.chat_filter.is_active() {
1222 let (quick_views, quick_height) = self.quick_views_section(cx);
1223 list = list.child(quick_views);
1224 y += quick_height;
1225 }
1129 1226 for (section, section_menu) in sections.iter().zip(section_menus) {
1130 1227 list = with_spacer(list, &mut skipped_height);
1131 1228 list = list.child(self.section_header(section, section_menu, cx));
@@ -2002,7 +2099,6 @@ impl Render for SidebarView {
2002 2099 SidebarTab::Chats => self.chats_body(window_height, cx),
2003 2100 SidebarTab::Channels => self.channels_body(cx),
2004 2101 SidebarTab::Calls => calls_body(&self.state, &self.calls_scroll, window_height, cx),
2005 SidebarTab::Saved => self.saved_panel.clone().into_any_element(),
2006 2102 SidebarTab::Agents => match &self.agents_panel {
2007 2103 Some(panel) => panel.clone().into_any_element(),
2008 2104 None => div().into_any_element(),
@@ -2025,7 +2121,7 @@ impl Render for SidebarView {
2025 2121 Some(page_header(self.tab.title()).child(self.channel_list_menu_button(cx)))
2026 2122 }
2027 2123 SidebarTab::Calls | SidebarTab::Agents => Some(page_header(self.tab.title())),
2028 SidebarTab::Activity | SidebarTab::Saved | SidebarTab::Calendar => None,
2124 SidebarTab::Activity | SidebarTab::Calendar => None,
2029 2125 };
2030 2126 v_flex()
2031 2127 .debug_selector(|| "shell/islands/sidebar".into())
@@ -21,7 +21,6 @@ use super::activity_panel::ActivityPanel;
21use super::avatar::{spec_avatar, team_avatar, with_presence};
21use super::avatar::{spec_avatar, team_avatar, with_presence};
22use super::calls_tab::calls_body;
22use super::calls_tab::calls_body;
23use super::chat_menu::{ChatMenuTarget, MenuContext, chat_menu};
23use super::chat_menu::{ChatMenuTarget, MenuContext, chat_menu};
24use super::saved_panel::SavedPanel;
25use super::scroll_edge::{scroll_offset, with_top_edge};
24use super::scroll_edge::{scroll_offset, with_top_edge};
26use super::channel_admin_dialogs::{confirm_delete_channel, open_edit_channel_dialog};
25use super::channel_admin_dialogs::{confirm_delete_channel, open_edit_channel_dialog};
27use super::create_channel_dialog::open_create_channel_dialog;
26use super::create_channel_dialog::open_create_channel_dialog;
@@ -29,7 +28,7 @@ use super::section_dialog::{SectionNameTarget, open_section_name_dialog};
29use super::widgets::{count_badge, icon, menu_icon, page_header, symbol, unread_marker};
28use super::widgets::{count_badge, icon, menu_icon, page_header, symbol, unread_marker};
30use crate::agents::AgentsPanel;
29use crate::agents::AgentsPanel;
31use super::last_views::LastViews;
30use super::last_views::LastViews;
32use crate::app_state::{AppEvent, AppState, Selection};
31use crate::app_state::{AppEvent, AppState, QuickView, Selection};
33use crate::channel_menu::{
32use crate::channel_menu::{
34 ChannelMenuItem, MenuEntry, TeamMenuItem, TeamMenuState, channel_menu_entries,
33 ChannelMenuItem, MenuEntry, TeamMenuItem, TeamMenuState, channel_menu_entries,
35 team_menu_entries,
34 team_menu_entries,
@@ -62,6 +61,15 @@ const PROPOSAL_DOT_SIZE: f32 = 8.;
62const PINNED_CHANNEL_HEIGHT: f32 = 48.;
61const PINNED_CHANNEL_HEIGHT: f32 = 48.;
63const SECTION_HEIGHT: f32 = 30.;
62const SECTION_HEIGHT: f32 = 30.;
64const SECTION_GAP: f32 = 4.;
63const SECTION_GAP: f32 = 4.;
64const QUICK_VIEWS_SECTION_ID: &str = "quick-views";
65const QUICK_VIEWS_TITLE: &str = "Quick views";
66const QUICK_ROW_HEIGHT: f32 = 32.;
67const QUICK_ICON_SIZE: f32 = 18.;
68const QUICK_VIEWS: [(QuickView, &str); 3] = [
69 (QuickView::Mentions, "fluent_mention"),
70 (QuickView::Drafts, "fluent_drafts"),
71 (QuickView::Saved, "fluent_bookmark"),
72];
65const HINT_HEIGHT: f32 = 26.;
73const HINT_HEIGHT: f32 = 26.;
66const SEE_MORE_HEIGHT: f32 = 28.;
74const SEE_MORE_HEIGHT: f32 = 28.;
67const LOADING_OLDER_LABEL: &str = "Loading older chats";
75const LOADING_OLDER_LABEL: &str = "Loading older chats";
@@ -97,7 +105,6 @@ pub enum SidebarTab {
97 Channels,
105 Channels,
98 Calendar,
106 Calendar,
99 Calls,
107 Calls,
100 Saved,
101 Agents,
108 Agents,
102}
109}
103
110
@@ -109,7 +116,6 @@ impl SidebarTab {
109 SidebarTab::Channels => "Teams",
116 SidebarTab::Channels => "Teams",
110 SidebarTab::Calendar => "Calendar",
117 SidebarTab::Calendar => "Calendar",
111 SidebarTab::Calls => "Calls",
118 SidebarTab::Calls => "Calls",
112 SidebarTab::Saved => "Saved",
113 SidebarTab::Agents => "Agents",
119 SidebarTab::Agents => "Agents",
114 }
120 }
115 }
121 }
@@ -338,7 +344,6 @@ pub struct SidebarView {
338 state: Entity<AppState>,
344 state: Entity<AppState>,
339 tab: SidebarTab,
345 tab: SidebarTab,
340 activity_panel: Entity<ActivityPanel>,
346 activity_panel: Entity<ActivityPanel>,
341 saved_panel: Entity<SavedPanel>,
342 agents_panel: Option<Entity<AgentsPanel>>,
347 agents_panel: Option<Entity<AgentsPanel>>,
343 collapsed_teams: HashSet<String>,
348 collapsed_teams: HashSet<String>,
344 revealed_channel_teams: HashSet<String>,
349 revealed_channel_teams: HashSet<String>,
@@ -407,7 +412,6 @@ impl SidebarView {
407 pub fn new(
412 pub fn new(
408 state: Entity<AppState>,
413 state: Entity<AppState>,
409 activity_panel: Entity<ActivityPanel>,
414 activity_panel: Entity<ActivityPanel>,
410 saved_panel: Entity<SavedPanel>,
411 agents_panel: Option<Entity<AgentsPanel>>,
415 agents_panel: Option<Entity<AgentsPanel>>,
412 cx: &mut Context<Self>,
416 cx: &mut Context<Self>,
413 ) -> Self {
417 ) -> Self {
@@ -476,7 +480,6 @@ impl SidebarView {
476 state,
480 state,
477 tab,
481 tab,
478 activity_panel,
482 activity_panel,
479 saved_panel,
480 agents_panel,
483 agents_panel,
481 collapsed_teams,
484 collapsed_teams,
482 revealed_channel_teams: HashSet::new(),
485 revealed_channel_teams: HashSet::new(),
@@ -525,8 +528,10 @@ impl SidebarView {
525 self.open_tab(SidebarTab::Calendar, cx);
528 self.open_tab(SidebarTab::Calendar, cx);
526 }
529 }
527
530
528 pub fn show_saved(&mut self, cx: &mut Context<Self>) {
531 pub fn open_quick_view(&mut self, view: QuickView, cx: &mut Context<Self>) {
529 self.open_tab(SidebarTab::Saved, cx);
532 self.open_tab(SidebarTab::Chats, cx);
533 self.state
534 .update(cx, |state, cx| state.open_quick_view(view, cx));
530 }
535 }
531
536
532 pub fn show_agents(&mut self, cx: &mut Context<Self>) {
537 pub fn show_agents(&mut self, cx: &mut Context<Self>) {
@@ -548,7 +553,6 @@ impl SidebarView {
548 state.refresh_call_history(cx);
553 state.refresh_call_history(cx);
549 state.refresh_calendar(cx);
554 state.refresh_calendar(cx);
550 }),
555 }),
551 SidebarTab::Saved => self.state.update(cx, |state, cx| state.refresh_saved(cx)),
552 SidebarTab::Calendar => self.state.update(cx, |state, cx| state.open_calendar(cx)),
556 SidebarTab::Calendar => self.state.update(cx, |state, cx| state.open_calendar(cx)),
553 SidebarTab::Activity => {
557 SidebarTab::Activity => {
554 let activity = self.activity_panel.read(cx).activity();
558 let activity = self.activity_panel.read(cx).activity();
@@ -591,7 +595,6 @@ impl SidebarView {
591 SidebarTab::Activity
595 SidebarTab::Activity
592 | SidebarTab::Calendar
596 | SidebarTab::Calendar
593 | SidebarTab::Calls
597 | SidebarTab::Calls
594 | SidebarTab::Saved
595 | SidebarTab::Agents => None,
598 | SidebarTab::Agents => None,
596 };
599 };
597 if let Some(selection) = selection {
600 if let Some(selection) = selection {
@@ -846,6 +849,92 @@ impl SidebarView {
846 .context_menu(move |popup, _, _| section_menu(popup, &menu_state, &menu))
849 .context_menu(move |popup, _, _| section_menu(popup, &menu_state, &menu))
847 }
850 }
848
851
852 fn quick_views_section(&self, cx: &mut Context<Self>) -> (Div, f32) {
853 let (collapsed, open_view) = {
854 let state = self.state.read(cx);
855 (
856 state.collapsed.contains(QUICK_VIEWS_SECTION_ID),
857 state.quick_view,
858 )
859 };
860 let header = h_flex()
861 .id(QUICK_VIEWS_SECTION_ID)
862 .h(px(SECTION_HEIGHT))
863 .flex_none()
864 .mt(px(SECTION_GAP))
865 .mx(px(6.))
866 .px(px(10.))
867 .gap(px(6.))
868 .items_center()
869 .rounded(px(6.))
870 .cursor_pointer()
871 .hover(|header| header.bg(theme::row_hover()))
872 .child(icon(
873 if collapsed {
874 IconName::ChevronRight
875 } else {
876 IconName::ChevronDown
877 },
878 12.,
879 theme::text_muted(),
880 ))
881 .child(
882 div()
883 .flex_1()
884 .text_size(px(12.))
885 .font_weight(FontWeight::SEMIBOLD)
886 .text_color(theme::text_soft())
887 .child(QUICK_VIEWS_TITLE),
888 )
889 .on_click(cx.listener(|this, _, _, cx| {
890 this.state.update(cx, |state, cx| {
891 state.toggle_collapsed(QUICK_VIEWS_SECTION_ID, cx)
892 });
893 }));
894 let mut section = v_flex().w_full().child(header);
895 let mut height = SECTION_GAP + SECTION_HEIGHT;
896 if !collapsed {
897 for (view, glyph) in QUICK_VIEWS {
898 section = section.child(self.quick_view_row(view, glyph, open_view == Some(view), cx));
899 height += QUICK_ROW_HEIGHT;
900 }
901 }
902 (section, height)
903 }
904
905 fn quick_view_row(
906 &self,
907 view: QuickView,
908 glyph: &'static str,
909 selected: bool,
910 cx: &mut Context<Self>,
911 ) -> Stateful<Div> {
912 h_flex()
913 .id(SharedString::from(format!("quick-view-{}", view.title())))
914 .debug_selector(move || format!("quick-view/{}", view.title()))
915 .h(px(QUICK_ROW_HEIGHT))
916 .flex_none()
917 .mx(px(6.))
918 .px(px(10.))
919 .gap(px(10.))
920 .items_center()
921 .rounded(px(8.))
922 .cursor_pointer()
923 .when(selected, |row| row.bg(theme::surface_raised()))
924 .when(!selected, |row| row.hover(|row| row.bg(theme::row_hover())))
925 .child(symbol(glyph, QUICK_ICON_SIZE, theme::text_soft()))
926 .child(
927 div()
928 .text_size(px(13.))
929 .text_color(theme::text())
930 .child(view.title()),
931 )
932 .on_click(cx.listener(move |this, _, _, cx| {
933 this.state
934 .update(cx, |state, cx| state.open_quick_view(view, cx));
935 }))
936 }
937
849 fn see_more_row(&self, section: &Section, cx: &mut Context<Self>) -> impl IntoElement {
938 fn see_more_row(&self, section: &Section, cx: &mut Context<Self>) -> impl IntoElement {
850 let toggle_id = section.id.clone();
939 let toggle_id = section.id.clone();
851 let label = if section.hidden_count > 0 {
940 let label = if section.hidden_count > 0 {
@@ -1111,7 +1200,10 @@ impl SidebarView {
1111 let (selected, drafting) = {
1200 let (selected, drafting) = {
1112 let state = self.state.read(cx);
1201 let state = self.state.read(cx);
1113 (
1202 (
1114 state.selection.clone().filter(|_| !state.new_chat),
1203 state
1204 .selection
1205 .clone()
1206 .filter(|_| !state.new_chat && state.quick_view.is_none()),
1115 state.new_chat,
1207 state.new_chat,
1116 )
1208 )
1117 };
1209 };
@@ -1126,6 +1218,11 @@ impl SidebarView {
1126 list = list.child(self.draft_row());
1218 list = list.child(self.draft_row());
1127 y += ROW_HEIGHT;
1219 y += ROW_HEIGHT;
1128 }
1220 }
1221 if !self.chat_filter.is_active() {
1222 let (quick_views, quick_height) = self.quick_views_section(cx);
1223 list = list.child(quick_views);
1224 y += quick_height;
1225 }
1129 for (section, section_menu) in sections.iter().zip(section_menus) {
1226 for (section, section_menu) in sections.iter().zip(section_menus) {
1130 list = with_spacer(list, &mut skipped_height);
1227 list = with_spacer(list, &mut skipped_height);
1131 list = list.child(self.section_header(section, section_menu, cx));
1228 list = list.child(self.section_header(section, section_menu, cx));
@@ -2002,7 +2099,6 @@ impl Render for SidebarView {
2002 SidebarTab::Chats => self.chats_body(window_height, cx),
2099 SidebarTab::Chats => self.chats_body(window_height, cx),
2003 SidebarTab::Channels => self.channels_body(cx),
2100 SidebarTab::Channels => self.channels_body(cx),
2004 SidebarTab::Calls => calls_body(&self.state, &self.calls_scroll, window_height, cx),
2101 SidebarTab::Calls => calls_body(&self.state, &self.calls_scroll, window_height, cx),
2005 SidebarTab::Saved => self.saved_panel.clone().into_any_element(),
2006 SidebarTab::Agents => match &self.agents_panel {
2102 SidebarTab::Agents => match &self.agents_panel {
2007 Some(panel) => panel.clone().into_any_element(),
2103 Some(panel) => panel.clone().into_any_element(),
2008 None => div().into_any_element(),
2104 None => div().into_any_element(),
@@ -2025,7 +2121,7 @@ impl Render for SidebarView {
2025 Some(page_header(self.tab.title()).child(self.channel_list_menu_button(cx)))
2121 Some(page_header(self.tab.title()).child(self.channel_list_menu_button(cx)))
2026 }
2122 }
2027 SidebarTab::Calls | SidebarTab::Agents => Some(page_header(self.tab.title())),
2123 SidebarTab::Calls | SidebarTab::Agents => Some(page_header(self.tab.title())),
2028 SidebarTab::Activity | SidebarTab::Saved | SidebarTab::Calendar => None,
2124 SidebarTab::Activity | SidebarTab::Calendar => None,
2029 };
2125 };
2030 v_flex()
2126 v_flex()
2031 .debug_selector(|| "shell/islands/sidebar".into())
2127 .debug_selector(|| "shell/islands/sidebar".into())