feat(chat): group chat header like Teams
- Unnamed groups show first names with presence dots and +N - People button with member count replaces the face pile - Search and pop out buttons in the chat header - Copilot pane and find panel close each other Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -22,6 +22,7 @@ use teams_core::{
22
22
};
23
23
24
24
mod channel_details;
25
mod chat_header_actions;
25
26
mod copilot;
26
27
pub use channel_details::{
27
28
CHANNEL_DETAILS_BUTTON, CHANNEL_DETAILS_PINNED_TAG, CHANNEL_DETAILS_SHARED_TAG,
@@ -3498,6 +3499,7 @@ impl ConversationView {
3498
3499
return;
3499
3500
};
3500
3501
self.channel_details_open = false;
3502
self.close_copilot();
3501
3503
if let Some(panel) = &self.find_panel {
3502
3504
panel.update(cx, |panel, cx| panel.focus(window, cx));
3503
3505
return;
@@ -3560,6 +3562,7 @@ impl ConversationView {
3560
3562
let mut subline = String::new();
3561
3563
let mut stack: Option<AnyElement> = None;
3562
3564
let mut rename: Option<AnyElement> = None;
3565
let mut names_title: Option<Div> = None;
3563
3566
match ¤t.selection {
3564
3567
Selection::Chat(chat_id) => {
3565
3568
if let Some(chat) = app.sidebar.chats.iter().find(|chat| &chat.id == chat_id) {
@@ -3604,14 +3607,15 @@ impl ConversationView {
3604
3607
{
3605
3608
rename = Some(group_name_button(&self.app, chat_id, &chat.title));
3606
3609
}
3610
if chat.title.trim().is_empty() {
3611
names_title = Some(chat_header_actions::group_title(directory, &faces));
3612
}
3607
3613
let pair = AvatarSpec::Pair(face(faces[0].clone()), face(faces[1].clone()));
3608
3614
lead = Some(spec_avatar(directory, &pair, 36., theme::surface()));
3609
subline = format!("{} participants", chat.members.len());
3610
let shown: Vec<Face> = faces.iter().cloned().map(face).collect();
3611
3615
stack = Some(members_popover(
3612
3616
&self.app,
3613
3617
chat_id,
3614
member_stack(directory, &shown, shown.len(), false)
3618
chat_header_actions::member_count(chat.members.len())
3615
3619
.debug_selector(|| MEMBERS_BUTTON.into()),
3616
3620
));
3617
3621
}
@@ -3716,7 +3720,10 @@ impl ConversationView {
3716
3720
.text_size(px(15.))
3717
3721
.font_weight(FontWeight::SEMIBOLD)
3718
3722
.text_color(theme::text())
3719
.child(current.title.clone()),
3723
.map(|title| match names_title {
3724
Some(names) => title.child(names),
3725
None => title.child(current.title.clone()),
3726
}),
3720
3727
)
3721
3728
.children(rename),
3722
3729
)
@@ -3730,11 +3737,13 @@ impl ConversationView {
3730
3737
}),
3731
3738
)
3732
3739
.children(inline_tabs)
3733
.children(stack)
3734
3740
.children(call_controls)
3741
.children(stack)
3735
3742
.children(self.copilot_button(cx))
3743
.children(self.chat_find_button(cx))
3736
3744
.children(self.channel_find_button(cx))
3737
3745
.children(self.channel_details_button(cx))
3746
.children(self.pop_out_button())
3738
3747
.children(self.pop_in_button(current))
3739
3748
}
3740
3749
@@ -22,6 +22,7 @@ use teams_core::{22
};22
};23
23
24
mod channel_details;24
mod channel_details;25
mod chat_header_actions;25
mod copilot;26
mod copilot;26
pub use channel_details::{27
pub use channel_details::{27
CHANNEL_DETAILS_BUTTON, CHANNEL_DETAILS_PINNED_TAG, CHANNEL_DETAILS_SHARED_TAG,28
CHANNEL_DETAILS_BUTTON, CHANNEL_DETAILS_PINNED_TAG, CHANNEL_DETAILS_SHARED_TAG,@@ -3498,6 +3499,7 @@ impl ConversationView {3498
return;3499
return;3499
};3500
};3500
self.channel_details_open = false;3501
self.channel_details_open = false;3502
self.close_copilot();3501
if let Some(panel) = &self.find_panel {3503
if let Some(panel) = &self.find_panel {3502
panel.update(cx, |panel, cx| panel.focus(window, cx));3504
panel.update(cx, |panel, cx| panel.focus(window, cx));3503
return;3505
return;@@ -3560,6 +3562,7 @@ impl ConversationView {3560
let mut subline = String::new();3562
let mut subline = String::new();3561
let mut stack: Option<AnyElement> = None;3563
let mut stack: Option<AnyElement> = None;3562
let mut rename: Option<AnyElement> = None;3564
let mut rename: Option<AnyElement> = None;3565
let mut names_title: Option<Div> = None;3563
match ¤t.selection {3566
match ¤t.selection {3564
Selection::Chat(chat_id) => {3567
Selection::Chat(chat_id) => {3565
if let Some(chat) = app.sidebar.chats.iter().find(|chat| &chat.id == chat_id) {3568
if let Some(chat) = app.sidebar.chats.iter().find(|chat| &chat.id == chat_id) {@@ -3604,14 +3607,15 @@ impl ConversationView {3604
{3607
{3605
rename = Some(group_name_button(&self.app, chat_id, &chat.title));3608
rename = Some(group_name_button(&self.app, chat_id, &chat.title));3606
}3609
}3610
if chat.title.trim().is_empty() {3611
names_title = Some(chat_header_actions::group_title(directory, &faces));3612
}3607
let pair = AvatarSpec::Pair(face(faces[0].clone()), face(faces[1].clone()));3613
let pair = AvatarSpec::Pair(face(faces[0].clone()), face(faces[1].clone()));3608
lead = Some(spec_avatar(directory, &pair, 36., theme::surface()));3614
lead = Some(spec_avatar(directory, &pair, 36., theme::surface()));3609
subline = format!("{} participants", chat.members.len());3610
let shown: Vec<Face> = faces.iter().cloned().map(face).collect();3611
stack = Some(members_popover(3615
stack = Some(members_popover(3612
&self.app,3616
&self.app,3613
chat_id,3617
chat_id,3614
member_stack(directory, &shown, shown.len(), false)3618
chat_header_actions::member_count(chat.members.len())3615
.debug_selector(|| MEMBERS_BUTTON.into()),3619
.debug_selector(|| MEMBERS_BUTTON.into()),3616
));3620
));3617
}3621
}@@ -3716,7 +3720,10 @@ impl ConversationView {3716
.text_size(px(15.))3720
.text_size(px(15.))3717
.font_weight(FontWeight::SEMIBOLD)3721
.font_weight(FontWeight::SEMIBOLD)3718
.text_color(theme::text())3722
.text_color(theme::text())3719
.child(current.title.clone()),3723
.map(|title| match names_title {3724
Some(names) => title.child(names),3725
None => title.child(current.title.clone()),3726
}),3720
)3727
)3721
.children(rename),3728
.children(rename),3722
)3729
)@@ -3730,11 +3737,13 @@ impl ConversationView {3730
}),3737
}),3731
)3738
)3732
.children(inline_tabs)3739
.children(inline_tabs)3733
.children(stack)3734
.children(call_controls)3740
.children(call_controls)3741
.children(stack)3735
.children(self.copilot_button(cx))3742
.children(self.copilot_button(cx))3743
.children(self.chat_find_button(cx))3736
.children(self.channel_find_button(cx))3744
.children(self.channel_find_button(cx))3737
.children(self.channel_details_button(cx))3745
.children(self.channel_details_button(cx))3746
.children(self.pop_out_button())3738
.children(self.pop_in_button(current))3747
.children(self.pop_in_button(current))3739
}3748
}3740
3749
@@ -0,0 +1,93 @@
1
use gpui_kit::assets::IconName;
2
use gpui_kit::component::button::{Button, ButtonVariants as _};
3
use gpui_kit::component::h_flex;
4
use gpui_kit::prelude::FluentBuilder as _;
5
use gpui_kit::*;
6
7
use super::ConversationView;
8
use crate::app_state::Selection;
9
use crate::data::Directory;
10
use crate::find_in_chat::FIND_IN_CHAT;
11
use crate::theme;
12
use crate::views::chat_pop_out::{self, POP_OUT_CHAT_LABEL};
13
use crate::views::avatar::status_glyph;
14
use crate::views::widgets::{icon, symbol};
15
16
const BUTTON_SIZE: f32 = 32.;
17
const COUNT_GLYPH: f32 = 16.;
18
19
impl ConversationView {
20
fn header_chat_id(&self) -> Option<&str> {
21
match &self.current.as_ref()?.selection {
22
Selection::Chat(chat_id) if !self.draft_active => Some(chat_id),
23
_ => None,
24
}
25
}
26
27
pub(super) fn chat_find_button(&self, cx: &mut Context<Self>) -> Option<AnyElement> {
28
self.header_chat_id().filter(|_| !self.pinned)?;
29
Some(
30
Button::new("chat-find")
31
.icon(IconName::Search)
32
.ghost()
33
.size(px(BUTTON_SIZE))
34
.rounded(px(8.))
35
.tooltip(FIND_IN_CHAT)
36
.on_click(cx.listener(|this, _, window, cx| this.open_find(window, cx)))
37
.into_any_element(),
38
)
39
}
40
41
pub(super) fn pop_out_button(&self) -> Option<AnyElement> {
42
let chat_id = self
43
.header_chat_id()
44
.filter(|_| !self.popped_out && !self.pinned)?
45
.to_owned();
46
let app = self.app.clone();
47
Some(
48
Button::new("chat-pop-out")
49
.icon(IconName::ExternalLink)
50
.ghost()
51
.size(px(BUTTON_SIZE))
52
.rounded(px(8.))
53
.tooltip(POP_OUT_CHAT_LABEL)
54
.on_click(move |_, _, cx| chat_pop_out::pop_out_chat(&app, &chat_id, cx))
55
.into_any_element(),
56
)
57
}
58
}
59
60
pub fn member_count(count: usize) -> Div {
61
h_flex()
62
.gap(px(4.))
63
.items_center()
64
.text_size(px(13.))
65
.text_color(theme::text_soft())
66
.child(icon(IconName::Users, COUNT_GLYPH, theme::text_soft()))
67
.child(count.to_string())
68
}
69
70
const TITLE_NAMES: usize = 3;
71
const NAME_DOT: f32 = 10.;
72
73
pub fn group_title(directory: &Directory, faces: &[(Option<String>, String)]) -> Div {
74
let hidden = faces.len().saturating_sub(TITLE_NAMES);
75
h_flex()
76
.min_w_0()
77
.gap(px(6.))
78
.items_center()
79
.children(faces.iter().take(TITLE_NAMES).map(|(user_id, name)| {
80
let first = name.split_whitespace().next().unwrap_or(name).to_owned();
81
let dot = user_id
82
.as_deref()
83
.and_then(|id| status_glyph(directory.presence_of(id).kind()))
84
.map(|(glyph, color)| symbol(glyph, NAME_DOT, color));
85
h_flex()
86
.flex_none()
87
.gap(px(3.))
88
.items_center()
89
.child(first)
90
.children(dot)
91
}))
92
.when(hidden > 0, |row| row.child(format!("+{hidden}")))
93
}
@@ -0,0 +1,93 @@1
use gpui_kit::assets::IconName;2
use gpui_kit::component::button::{Button, ButtonVariants as _};3
use gpui_kit::component::h_flex;4
use gpui_kit::prelude::FluentBuilder as _;5
use gpui_kit::*;6
7
use super::ConversationView;8
use crate::app_state::Selection;9
use crate::data::Directory;10
use crate::find_in_chat::FIND_IN_CHAT;11
use crate::theme;12
use crate::views::chat_pop_out::{self, POP_OUT_CHAT_LABEL};13
use crate::views::avatar::status_glyph;14
use crate::views::widgets::{icon, symbol};15
16
const BUTTON_SIZE: f32 = 32.;17
const COUNT_GLYPH: f32 = 16.;18
19
impl ConversationView {20
fn header_chat_id(&self) -> Option<&str> {21
match &self.current.as_ref()?.selection {22
Selection::Chat(chat_id) if !self.draft_active => Some(chat_id),23
_ => None,24
}25
}26
27
pub(super) fn chat_find_button(&self, cx: &mut Context<Self>) -> Option<AnyElement> {28
self.header_chat_id().filter(|_| !self.pinned)?;29
Some(30
Button::new("chat-find")31
.icon(IconName::Search)32
.ghost()33
.size(px(BUTTON_SIZE))34
.rounded(px(8.))35
.tooltip(FIND_IN_CHAT)36
.on_click(cx.listener(|this, _, window, cx| this.open_find(window, cx)))37
.into_any_element(),38
)39
}40
41
pub(super) fn pop_out_button(&self) -> Option<AnyElement> {42
let chat_id = self43
.header_chat_id()44
.filter(|_| !self.popped_out && !self.pinned)?45
.to_owned();46
let app = self.app.clone();47
Some(48
Button::new("chat-pop-out")49
.icon(IconName::ExternalLink)50
.ghost()51
.size(px(BUTTON_SIZE))52
.rounded(px(8.))53
.tooltip(POP_OUT_CHAT_LABEL)54
.on_click(move |_, _, cx| chat_pop_out::pop_out_chat(&app, &chat_id, cx))55
.into_any_element(),56
)57
}58
}59
60
pub fn member_count(count: usize) -> Div {61
h_flex()62
.gap(px(4.))63
.items_center()64
.text_size(px(13.))65
.text_color(theme::text_soft())66
.child(icon(IconName::Users, COUNT_GLYPH, theme::text_soft()))67
.child(count.to_string())68
}69
70
const TITLE_NAMES: usize = 3;71
const NAME_DOT: f32 = 10.;72
73
pub fn group_title(directory: &Directory, faces: &[(Option<String>, String)]) -> Div {74
let hidden = faces.len().saturating_sub(TITLE_NAMES);75
h_flex()76
.min_w_0()77
.gap(px(6.))78
.items_center()79
.children(faces.iter().take(TITLE_NAMES).map(|(user_id, name)| {80
let first = name.split_whitespace().next().unwrap_or(name).to_owned();81
let dot = user_id82
.as_deref()83
.and_then(|id| status_glyph(directory.presence_of(id).kind()))84
.map(|(glyph, color)| symbol(glyph, NAME_DOT, color));85
h_flex()86
.flex_none()87
.gap(px(3.))88
.items_center()89
.child(first)90
.children(dot)91
}))92
.when(hidden > 0, |row| row.child(format!("+{hidden}")))93
}@@ -96,6 +96,8 @@ impl ConversationView {
96
96
}
97
97
if self.copilot.open {
98
98
self.channel_details_open = false;
99
self.find_panel = None;
100
self.find_subscription = None;
99
101
if let Some(input) = &self.copilot.input {
100
102
input.update(cx, |input, cx| input.focus(window, cx));
101
103
}
@@ -103,6 +105,10 @@ impl ConversationView {
103
105
cx.notify();
104
106
}
105
107
108
pub(super) fn close_copilot(&mut self) {
109
self.copilot.open = false;
110
}
111
106
112
pub(super) fn reset_copilot(&mut self) {
107
113
let input = self.copilot.input.take();
108
114
let events = self.copilot._input_events.take();
@@ -96,6 +96,8 @@ impl ConversationView {96
}96
}97
if self.copilot.open {97
if self.copilot.open {98
self.channel_details_open = false;98
self.channel_details_open = false;99
self.find_panel = None;100
self.find_subscription = None;99
if let Some(input) = &self.copilot.input {101
if let Some(input) = &self.copilot.input {100
input.update(cx, |input, cx| input.focus(window, cx));102
input.update(cx, |input, cx| input.focus(window, cx));101
}103
}@@ -103,6 +105,10 @@ impl ConversationView {103
cx.notify();105
cx.notify();104
}106
}105
107
108
pub(super) fn close_copilot(&mut self) {109
self.copilot.open = false;110
}111
106
pub(super) fn reset_copilot(&mut self) {112
pub(super) fn reset_copilot(&mut self) {107
let input = self.copilot.input.take();113
let input = self.copilot.input.take();108
let events = self.copilot._input_events.take();114
let events = self.copilot._input_events.take();