BlueGit

ict rusty-teams

fix(chat): pending replies show their quote, composer and receipt polish

- Pending reply shows its quote before the server echo
- Unnamed group chats: composer says "Type a message"
- Composer: send button gap, single-line row centered
- Format toolbar wider than the composer ends at its right edge
- Read receipt checks sit on the text baseline
- Agent chip: Open session on stopped runs

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

metis Daniel Däschle · pushed by metis

Authored 2026-10-15 · 6 weeks ago

Hash
ef56e7b8d3ef5c744f19a45bd0b2c5987ee4ee74
Parent
94f8942c
10 files changed +155 −71
crates/app/src/agents/run_chip.rs +22 −27
@@ -173,12 +173,22 @@ fn chip_row(run: &AgentRun, fill: Hsla) -> Stateful<Div> {
173 173 })
174 174 .child(dismiss_button(run_id))
175 175 }
176 RunState::Stopped => row
177 .child(icon(IconName::Square, STATUS_ICON, theme::text_faint()))
178 .child(label(action_label, theme::text_soft()))
179 .child(step_text("Stopped".to_owned()))
180 .child(elapsed_text(run))
181 .child(dismiss_button(run_id)),
176 RunState::Stopped => {
177 row.child(icon(IconName::Square, STATUS_ICON, theme::text_faint()))
178 .child(label(action_label, theme::text_soft()))
179 .child(step_text("Stopped".to_owned()))
180 .child(elapsed_text(run))
181 .when(!session_id.is_empty(), |row| {
182 row.child(
183 chip_button(format!("agent-open-{run_id}"), "Open session", false)
184 .on_click(move |_, _, cx| {
185 cx.stop_propagation();
186 with_runs(cx, |runs, cx| runs.stop_and_open_session(run_id, cx));
187 }),
188 )
189 })
190 .child(dismiss_button(run_id))
191 }
182 192 }
183 193 }
184 194
@@ -206,27 +216,12 @@ fn step_row(elapsed: String, text: String, current: bool) -> Div {
206 216 }
207 217
208 218 fn stop_row(run_id: u64) -> Div {
209 h_flex()
210 .mt(px(2.))
211 .items_center()
212 .justify_between()
213 .child(
214 chip_button(
215 format!("agent-stop-open-{run_id}"),
216 "Stop and open session",
217 false,
218 )
219 .on_click(move |_, _, cx| {
220 cx.stop_propagation();
221 with_runs(cx, |runs, cx| runs.stop_and_open_session(run_id, cx));
222 }),
223 )
224 .child(
225 chip_button(format!("agent-stop-{run_id}"), "Stop", false).on_click(move |_, _, cx| {
226 cx.stop_propagation();
227 with_runs(cx, |runs, cx| runs.stop(run_id, cx));
228 }),
229 )
219 h_flex().mt(px(2.)).items_center().justify_end().child(
220 chip_button(format!("agent-stop-{run_id}"), "Stop", false).on_click(move |_, _, cx| {
221 cx.stop_propagation();
222 with_runs(cx, |runs, cx| runs.stop(run_id, cx));
223 }),
224 )
230 225 }
231 226
232 227 fn detail_panel(run: &AgentRun, fill: Hsla) -> Div {
@@ -173,12 +173,22 @@ fn chip_row(run: &AgentRun, fill: Hsla) -> Stateful<Div> {
173 })
173 })
174 .child(dismiss_button(run_id))
174 .child(dismiss_button(run_id))
175 }
175 }
176 RunState::Stopped => row
176 RunState::Stopped => {
177 .child(icon(IconName::Square, STATUS_ICON, theme::text_faint()))
177 row.child(icon(IconName::Square, STATUS_ICON, theme::text_faint()))
178 .child(label(action_label, theme::text_soft()))
178 .child(label(action_label, theme::text_soft()))
179 .child(step_text("Stopped".to_owned()))
179 .child(step_text("Stopped".to_owned()))
180 .child(elapsed_text(run))
180 .child(elapsed_text(run))
181 .child(dismiss_button(run_id)),
181 .when(!session_id.is_empty(), |row| {
182 row.child(
183 chip_button(format!("agent-open-{run_id}"), "Open session", false)
184 .on_click(move |_, _, cx| {
185 cx.stop_propagation();
186 with_runs(cx, |runs, cx| runs.stop_and_open_session(run_id, cx));
187 }),
188 )
189 })
190 .child(dismiss_button(run_id))
191 }
182 }
192 }
183}
193}
184
194
@@ -206,27 +216,12 @@ fn step_row(elapsed: String, text: String, current: bool) -> Div {
206}
216}
207
217
208fn stop_row(run_id: u64) -> Div {
218fn stop_row(run_id: u64) -> Div {
209 h_flex()
219 h_flex().mt(px(2.)).items_center().justify_end().child(
210 .mt(px(2.))
220 chip_button(format!("agent-stop-{run_id}"), "Stop", false).on_click(move |_, _, cx| {
211 .items_center()
221 cx.stop_propagation();
212 .justify_between()
222 with_runs(cx, |runs, cx| runs.stop(run_id, cx));
213 .child(
223 }),
214 chip_button(
224 )
215 format!("agent-stop-open-{run_id}"),
216 "Stop and open session",
217 false,
218 )
219 .on_click(move |_, _, cx| {
220 cx.stop_propagation();
221 with_runs(cx, |runs, cx| runs.stop_and_open_session(run_id, cx));
222 }),
223 )
224 .child(
225 chip_button(format!("agent-stop-{run_id}"), "Stop", false).on_click(move |_, _, cx| {
226 cx.stop_propagation();
227 with_runs(cx, |runs, cx| runs.stop(run_id, cx));
228 }),
229 )
230}
225}
231
226
232fn detail_panel(run: &AgentRun, fill: Hsla) -> Div {
227fn detail_panel(run: &AgentRun, fill: Hsla) -> Div {
crates/app/src/app_state.rs +16 −0
@@ -168,6 +168,22 @@ pub fn chat_title(chat: &ChatRecord) -> String {
168 168 chat.display_title()
169 169 }
170 170
171 pub fn composer_name(sidebar: &Sidebar, selection: &Selection) -> String {
172 let unnamed_group = match selection {
173 Selection::Chat(id) => sidebar.chats.iter().any(|chat| {
174 &chat.id == id
175 && chat.title.trim().is_empty()
176 && !chat.kind.eq_ignore_ascii_case("oneOnOne")
177 }),
178 Selection::Channel(_) => false,
179 };
180 if unnamed_group {
181 String::new()
182 } else {
183 selection_title(sidebar, selection)
184 }
185 }
186
171 187 pub fn selection_title(sidebar: &Sidebar, selection: &Selection) -> String {
172 188 match selection {
173 189 Selection::Chat(id) => sidebar
@@ -168,6 +168,22 @@ pub fn chat_title(chat: &ChatRecord) -> String {
168 chat.display_title()
168 chat.display_title()
169}
169}
170
170
171pub fn composer_name(sidebar: &Sidebar, selection: &Selection) -> String {
172 let unnamed_group = match selection {
173 Selection::Chat(id) => sidebar.chats.iter().any(|chat| {
174 &chat.id == id
175 && chat.title.trim().is_empty()
176 && !chat.kind.eq_ignore_ascii_case("oneOnOne")
177 }),
178 Selection::Channel(_) => false,
179 };
180 if unnamed_group {
181 String::new()
182 } else {
183 selection_title(sidebar, selection)
184 }
185}
186
171pub fn selection_title(sidebar: &Sidebar, selection: &Selection) -> String {
187pub fn selection_title(sidebar: &Sidebar, selection: &Selection) -> String {
172 match selection {
188 match selection {
173 Selection::Chat(id) => sidebar
189 Selection::Chat(id) => sidebar
crates/app/src/pending_rows.rs +54 −7
@@ -1,11 +1,26 @@
1 1 use chrono::{DateTime, Local, Utc};
2 use teams_core::FileCard;
2 use teams_core::{FileCard, QuoteInfo};
3 3
4 use crate::render::layout_blocks;
4 use crate::render::{Block, layout_blocks};
5 5 use crate::rows::{Delivery, LocalImage, MessageRow, Receipt, Series};
6 6 use crate::views::attachment_tray::OutgoingImage;
7 7 use crate::views::composer::Outgoing;
8 8
9 fn pending_blocks(outgoing: &Outgoing) -> Vec<Block> {
10 let quote = outgoing.reply.as_ref().map(|reply| {
11 teams_core::quote_html(&QuoteInfo {
12 message_id: reply.message_id.clone(),
13 preview: reply.excerpt.clone(),
14 sender_name: Some(reply.author.clone()),
15 })
16 });
17 if quote.is_none() && outgoing.draft.is_blank() && outgoing.images.is_empty() {
18 return Vec::new();
19 }
20 let html = quote.unwrap_or_default() + &outgoing.html();
21 layout_blocks(&teams_core::html_to_spans(&html))
22 }
23
9 24 pub fn pending_row(
10 25 key: String,
11 26 conversation_id: String,
@@ -24,11 +39,7 @@ pub fn pending_row(
24 39 series: Series::default(),
25 40 time: created_at.with_timezone(&Local).format("%H:%M").to_string(),
26 41 day_header: None,
27 blocks: if outgoing.draft.is_blank() && outgoing.images.is_empty() {
28 Vec::new()
29 } else {
30 layout_blocks(&teams_core::html_to_spans(&outgoing.html()))
31 },
42 blocks: pending_blocks(outgoing),
32 43 edited: false,
33 44 deleted: false,
34 45 reactions: Vec::new(),
@@ -76,3 +87,39 @@ pub fn pending_row(
76 87 call: None,
77 88 }
78 89 }
90
91 #[cfg(test)]
92 mod tests {
93 use teams_core::Draft;
94
95 use super::*;
96 use crate::views::composer::ReplyPreview;
97
98 #[test]
99 fn a_pending_reply_shows_its_quote_before_the_server_echo() {
100 let outgoing = Outgoing {
101 draft: Draft::plain("agreed"),
102 subject: None,
103 mentions: Vec::new(),
104 reply: Some(ReplyPreview {
105 message_id: "message-1".to_owned(),
106 author: "Grace".to_owned(),
107 excerpt: "earlier".to_owned(),
108 }),
109 edit: None,
110 images: Vec::new(),
111 files: Vec::new(),
112 link_preview: None,
113 };
114 let row = pending_row(
115 "key".to_owned(),
116 "chat".to_owned(),
117 None,
118 Utc::now(),
119 &outgoing,
120 Delivery::Sending,
121 );
122 assert!(matches!(row.blocks.first(), Some(Block::Reply(_))));
123 assert_eq!(row.blocks.len(), 2);
124 }
125 }
@@ -1,11 +1,26 @@
1use chrono::{DateTime, Local, Utc};
1use chrono::{DateTime, Local, Utc};
2use teams_core::FileCard;
2use teams_core::{FileCard, QuoteInfo};
3
3
4use crate::render::layout_blocks;
4use crate::render::{Block, layout_blocks};
5use crate::rows::{Delivery, LocalImage, MessageRow, Receipt, Series};
5use crate::rows::{Delivery, LocalImage, MessageRow, Receipt, Series};
6use crate::views::attachment_tray::OutgoingImage;
6use crate::views::attachment_tray::OutgoingImage;
7use crate::views::composer::Outgoing;
7use crate::views::composer::Outgoing;
8
8
9fn pending_blocks(outgoing: &Outgoing) -> Vec<Block> {
10 let quote = outgoing.reply.as_ref().map(|reply| {
11 teams_core::quote_html(&QuoteInfo {
12 message_id: reply.message_id.clone(),
13 preview: reply.excerpt.clone(),
14 sender_name: Some(reply.author.clone()),
15 })
16 });
17 if quote.is_none() && outgoing.draft.is_blank() && outgoing.images.is_empty() {
18 return Vec::new();
19 }
20 let html = quote.unwrap_or_default() + &outgoing.html();
21 layout_blocks(&teams_core::html_to_spans(&html))
22}
23
9pub fn pending_row(
24pub fn pending_row(
10 key: String,
25 key: String,
11 conversation_id: String,
26 conversation_id: String,
@@ -24,11 +39,7 @@ pub fn pending_row(
24 series: Series::default(),
39 series: Series::default(),
25 time: created_at.with_timezone(&Local).format("%H:%M").to_string(),
40 time: created_at.with_timezone(&Local).format("%H:%M").to_string(),
26 day_header: None,
41 day_header: None,
27 blocks: if outgoing.draft.is_blank() && outgoing.images.is_empty() {
42 blocks: pending_blocks(outgoing),
28 Vec::new()
29 } else {
30 layout_blocks(&teams_core::html_to_spans(&outgoing.html()))
31 },
32 edited: false,
43 edited: false,
33 deleted: false,
44 deleted: false,
34 reactions: Vec::new(),
45 reactions: Vec::new(),
@@ -76,3 +87,39 @@ pub fn pending_row(
76 call: None,
87 call: None,
77 }
88 }
78}
89}
90
91#[cfg(test)]
92mod tests {
93 use teams_core::Draft;
94
95 use super::*;
96 use crate::views::composer::ReplyPreview;
97
98 #[test]
99 fn a_pending_reply_shows_its_quote_before_the_server_echo() {
100 let outgoing = Outgoing {
101 draft: Draft::plain("agreed"),
102 subject: None,
103 mentions: Vec::new(),
104 reply: Some(ReplyPreview {
105 message_id: "message-1".to_owned(),
106 author: "Grace".to_owned(),
107 excerpt: "earlier".to_owned(),
108 }),
109 edit: None,
110 images: Vec::new(),
111 files: Vec::new(),
112 link_preview: None,
113 };
114 let row = pending_row(
115 "key".to_owned(),
116 "chat".to_owned(),
117 None,
118 Utc::now(),
119 &outgoing,
120 Delivery::Sending,
121 );
122 assert!(matches!(row.blocks.first(), Some(Block::Reply(_))));
123 assert_eq!(row.blocks.len(), 2);
124 }
125}
crates/app/src/views/composer.rs +29 −5
@@ -1473,7 +1473,12 @@ impl Composer {
1473 1473 window: &mut Window,
1474 1474 cx: &mut Context<Self>,
1475 1475 ) {
1476 self.set_placeholder(&format!("Message {name}"), window, cx);
1476 let placeholder = if name.is_empty() {
1477 "Type a message".to_owned()
1478 } else {
1479 format!("Message {name}")
1480 };
1481 self.set_placeholder(&placeholder, window, cx);
1477 1482 if self.conversation_id.as_deref() != Some(conversation_id) {
1478 1483 self.save_draft_now(cx);
1479 1484 self.draft_save = None;
@@ -2486,6 +2491,7 @@ impl Render for Composer {
2486 2491 let send = div()
2487 2492 .id("composer-send")
2488 2493 .size(px(32.))
2494 .ml(px(6.))
2489 2495 .flex_none()
2490 2496 .flex()
2491 2497 .items_center()
@@ -2619,6 +2625,12 @@ impl Render for Composer {
2619 2625 .child(notice.to_owned())
2620 2626 });
2621 2627 let composer_bounds = self.composer_bounds.clone();
2628 let single_line = {
2629 let state = self.input.read(cx);
2630 state
2631 .line_height()
2632 .is_none_or(|line_height| state.input_bounds().size.height < line_height * 2.)
2633 };
2622 2634 let (inset, top, bottom) = if self.inline {
2623 2635 (0., 0., 0.)
2624 2636 } else {
@@ -2821,13 +2833,25 @@ impl Render for Composer {
2821 2833 .child(
2822 2834 h_flex()
2823 2835 .w_full()
2824 .items_end()
2825 .gap(px(6.))
2836 .map(|row| {
2837 if single_line {
2838 row.items_center()
2839 } else {
2840 row.items_end()
2841 }
2842 })
2826 2843 .py(px(6.))
2827 2844 .pl(px(if can_attach { 6. } else { 12. }))
2828 2845 .pr(px(6.))
2829 .children(fun)
2830 .children(attach)
2846 .when(can_attach, |row| {
2847 row.child(
2848 h_flex()
2849 .flex_none()
2850 .gap(px(6.))
2851 .children(fun)
2852 .children(attach),
2853 )
2854 })
2831 2855 .child(
2832 2856 div()
2833 2857 .flex_1()
@@ -1473,7 +1473,12 @@ impl Composer {
1473 window: &mut Window,
1473 window: &mut Window,
1474 cx: &mut Context<Self>,
1474 cx: &mut Context<Self>,
1475 ) {
1475 ) {
1476 self.set_placeholder(&format!("Message {name}"), window, cx);
1476 let placeholder = if name.is_empty() {
1477 "Type a message".to_owned()
1478 } else {
1479 format!("Message {name}")
1480 };
1481 self.set_placeholder(&placeholder, window, cx);
1477 if self.conversation_id.as_deref() != Some(conversation_id) {
1482 if self.conversation_id.as_deref() != Some(conversation_id) {
1478 self.save_draft_now(cx);
1483 self.save_draft_now(cx);
1479 self.draft_save = None;
1484 self.draft_save = None;
@@ -2486,6 +2491,7 @@ impl Render for Composer {
2486 let send = div()
2491 let send = div()
2487 .id("composer-send")
2492 .id("composer-send")
2488 .size(px(32.))
2493 .size(px(32.))
2494 .ml(px(6.))
2489 .flex_none()
2495 .flex_none()
2490 .flex()
2496 .flex()
2491 .items_center()
2497 .items_center()
@@ -2619,6 +2625,12 @@ impl Render for Composer {
2619 .child(notice.to_owned())
2625 .child(notice.to_owned())
2620 });
2626 });
2621 let composer_bounds = self.composer_bounds.clone();
2627 let composer_bounds = self.composer_bounds.clone();
2628 let single_line = {
2629 let state = self.input.read(cx);
2630 state
2631 .line_height()
2632 .is_none_or(|line_height| state.input_bounds().size.height < line_height * 2.)
2633 };
2622 let (inset, top, bottom) = if self.inline {
2634 let (inset, top, bottom) = if self.inline {
2623 (0., 0., 0.)
2635 (0., 0., 0.)
2624 } else {
2636 } else {
@@ -2821,13 +2833,25 @@ impl Render for Composer {
2821 .child(
2833 .child(
2822 h_flex()
2834 h_flex()
2823 .w_full()
2835 .w_full()
2824 .items_end()
2836 .map(|row| {
2825 .gap(px(6.))
2837 if single_line {
2838 row.items_center()
2839 } else {
2840 row.items_end()
2841 }
2842 })
2826 .py(px(6.))
2843 .py(px(6.))
2827 .pl(px(if can_attach { 6. } else { 12. }))
2844 .pl(px(if can_attach { 6. } else { 12. }))
2828 .pr(px(6.))
2845 .pr(px(6.))
2829 .children(fun)
2846 .when(can_attach, |row| {
2830 .children(attach)
2847 row.child(
2848 h_flex()
2849 .flex_none()
2850 .gap(px(6.))
2851 .children(fun)
2852 .children(attach),
2853 )
2854 })
2831 .child(
2855 .child(
2832 div()
2856 div()
2833 .flex_1()
2857 .flex_1()
crates/app/src/views/conversation.rs +5 −4
@@ -45,7 +45,7 @@ use super::reaction_pills::{ReactionControls, ReactionPopover};
45 45 use super::toolbar_placement::{TimelineBounds, record_bounds};
46 46 use super::widgets::{icon, symbol};
47 47 use crate::agents::{AgentRun, StartRequest};
48 use crate::app_state::{AppEvent, AppState, Selection, selection_title};
48 use crate::app_state::{AppEvent, AppState, Selection, composer_name, selection_title};
49 49 use crate::backend::Engine;
50 50 use crate::card_state::CardScope;
51 51 use crate::channel_files::DownloadSource;
@@ -670,10 +670,11 @@ impl ConversationView {
670 670 } else if let Some(current) = self.current.as_mut() {
671 671 let title = selection_title(&self.app.read(cx).sidebar, &current.selection);
672 672 if current.title != title {
673 current.title = title.clone();
673 current.title = title;
674 674 let conversation_id = current.selection.conversation_id().to_owned();
675 let name = composer_name(&self.app.read(cx).sidebar, &current.selection);
675 676 self.composer.update(cx, |composer, cx| {
676 composer.set_conversation(&conversation_id, &title, window, cx)
677 composer.set_conversation(&conversation_id, &name, window, cx)
677 678 });
678 679 cx.notify();
679 680 }
@@ -868,7 +869,7 @@ impl ConversationView {
868 869 .map(|current| {
869 870 (
870 871 current.selection.conversation_id().to_owned(),
871 current.title.clone(),
872 composer_name(&self.app.read(cx).sidebar, &current.selection),
872 873 )
873 874 })
874 875 .unwrap_or_default();
@@ -45,7 +45,7 @@ use super::reaction_pills::{ReactionControls, ReactionPopover};
45use super::toolbar_placement::{TimelineBounds, record_bounds};
45use super::toolbar_placement::{TimelineBounds, record_bounds};
46use super::widgets::{icon, symbol};
46use super::widgets::{icon, symbol};
47use crate::agents::{AgentRun, StartRequest};
47use crate::agents::{AgentRun, StartRequest};
48use crate::app_state::{AppEvent, AppState, Selection, selection_title};
48use crate::app_state::{AppEvent, AppState, Selection, composer_name, selection_title};
49use crate::backend::Engine;
49use crate::backend::Engine;
50use crate::card_state::CardScope;
50use crate::card_state::CardScope;
51use crate::channel_files::DownloadSource;
51use crate::channel_files::DownloadSource;
@@ -670,10 +670,11 @@ impl ConversationView {
670 } else if let Some(current) = self.current.as_mut() {
670 } else if let Some(current) = self.current.as_mut() {
671 let title = selection_title(&self.app.read(cx).sidebar, &current.selection);
671 let title = selection_title(&self.app.read(cx).sidebar, &current.selection);
672 if current.title != title {
672 if current.title != title {
673 current.title = title.clone();
673 current.title = title;
674 let conversation_id = current.selection.conversation_id().to_owned();
674 let conversation_id = current.selection.conversation_id().to_owned();
675 let name = composer_name(&self.app.read(cx).sidebar, &current.selection);
675 self.composer.update(cx, |composer, cx| {
676 self.composer.update(cx, |composer, cx| {
676 composer.set_conversation(&conversation_id, &title, window, cx)
677 composer.set_conversation(&conversation_id, &name, window, cx)
677 });
678 });
678 cx.notify();
679 cx.notify();
679 }
680 }
@@ -868,7 +869,7 @@ impl ConversationView {
868 .map(|current| {
869 .map(|current| {
869 (
870 (
870 current.selection.conversation_id().to_owned(),
871 current.selection.conversation_id().to_owned(),
871 current.title.clone(),
872 composer_name(&self.app.read(cx).sidebar, &current.selection),
872 )
873 )
873 })
874 })
874 .unwrap_or_default();
875 .unwrap_or_default();
crates/app/src/views/format_toolbar.rs +9 −2
@@ -152,8 +152,8 @@ pub fn place(center_x: Pixels, top: Pixels, edges: (Pixels, Pixels), width: f32)
152 152 let width = px(width);
153 153 let (left_edge, right_edge) = edges;
154 154 let left = (center_x - width / 2.)
155 .min(right_edge - width)
156 .max(left_edge);
155 .max(left_edge)
156 .min(right_edge - width);
157 157 Placement {
158 158 left,
159 159 bottom: top - px(GAP),
@@ -373,6 +373,13 @@ mod tests {
373 373 assert_eq!(near_right.arrow_x, px(200. - ARROW_MARGIN));
374 374 }
375 375
376 #[test]
377 fn a_bar_wider_than_the_composer_ends_at_its_right_edge() {
378 let placement = place(px(560.), px(300.), (px(500.), px(800.)), 400.);
379 assert_eq!(placement.left, px(400.));
380 assert_eq!(placement.arrow_x, px(160.));
381 }
382
376 383 #[test]
377 384 fn the_bar_holds_fourteen_buttons_in_five_groups() {
378 385 assert_eq!(GROUPS.iter().map(|group| group.len()).sum::<usize>(), 14);
@@ -152,8 +152,8 @@ pub fn place(center_x: Pixels, top: Pixels, edges: (Pixels, Pixels), width: f32)
152 let width = px(width);
152 let width = px(width);
153 let (left_edge, right_edge) = edges;
153 let (left_edge, right_edge) = edges;
154 let left = (center_x - width / 2.)
154 let left = (center_x - width / 2.)
155 .min(right_edge - width)
155 .max(left_edge)
156 .max(left_edge);
156 .min(right_edge - width);
157 Placement {
157 Placement {
158 left,
158 left,
159 bottom: top - px(GAP),
159 bottom: top - px(GAP),
@@ -373,6 +373,13 @@ mod tests {
373 assert_eq!(near_right.arrow_x, px(200. - ARROW_MARGIN));
373 assert_eq!(near_right.arrow_x, px(200. - ARROW_MARGIN));
374 }
374 }
375
375
376 #[test]
377 fn a_bar_wider_than_the_composer_ends_at_its_right_edge() {
378 let placement = place(px(560.), px(300.), (px(500.), px(800.)), 400.);
379 assert_eq!(placement.left, px(400.));
380 assert_eq!(placement.arrow_x, px(160.));
381 }
382
376 #[test]
383 #[test]
377 fn the_bar_holds_fourteen_buttons_in_five_groups() {
384 fn the_bar_holds_fourteen_buttons_in_five_groups() {
378 assert_eq!(GROUPS.iter().map(|group| group.len()).sum::<usize>(), 14);
385 assert_eq!(GROUPS.iter().map(|group| group.len()).sum::<usize>(), 14);
crates/app/src/views/message_row.rs +13 −5
@@ -1,5 +1,5 @@
1 1 use gpui_kit::assets::IconName;
2 use gpui_kit::component::{h_flex, v_flex};
2 use gpui_kit::component::{Icon, h_flex, v_flex};
3 3 use gpui_kit::prelude::FluentBuilder as _;
4 4 use gpui_kit::*;
5 5 use std::time::Duration;
@@ -310,7 +310,7 @@ struct BubbleExtras {
310 310 }
311 311
312 312 fn agent_chip(run: Option<AgentRun>) -> Option<Div> {
313 run.map(|run| div().pt(px(2.)).child(run_chip(&run, theme::row_hover())))
313 run.map(|run| div().py(px(2.)).child(run_chip(&run, theme::row_hover())))
314 314 }
315 315
316 316 pub(super) fn forwarded_header() -> Div {
@@ -355,13 +355,21 @@ fn bubble_meta(row: &MessageRow, own: bool, saved: bool) -> Div {
355 355 own && row.delivery == Delivery::Delivered,
356 356 |meta| match row.receipt {
357 357 Receipt::Hidden => meta,
358 Receipt::Pending => meta.child(receipt_slot(tint)),
359 Receipt::Sent => meta.child(symbol("done", META_CHECK_SIZE, tint)),
360 Receipt::Read => meta.child(symbol("done_all", META_CHECK_SIZE, theme::own_read())),
358 Receipt::Pending => meta.child(receipt_slot(tint).relative().top(px(1.))),
359 Receipt::Sent => meta.child(on_baseline(symbol("done", META_CHECK_SIZE, tint))),
360 Receipt::Read => meta.child(on_baseline(symbol(
361 "done_all",
362 META_CHECK_SIZE,
363 theme::own_read(),
364 ))),
361 365 },
362 366 )
363 367 }
364 368
369 fn on_baseline(check: Icon) -> Div {
370 div().relative().top(px(1.)).child(check)
371 }
372
365 373 fn pulse<E: IntoElement + Styled + 'static>(id: &'static str, element: E) -> AnimationElement<E> {
366 374 element.with_animation(
367 375 id,
@@ -1,5 +1,5 @@
1use gpui_kit::assets::IconName;
1use gpui_kit::assets::IconName;
2use gpui_kit::component::{h_flex, v_flex};
2use gpui_kit::component::{Icon, h_flex, v_flex};
3use gpui_kit::prelude::FluentBuilder as _;
3use gpui_kit::prelude::FluentBuilder as _;
4use gpui_kit::*;
4use gpui_kit::*;
5use std::time::Duration;
5use std::time::Duration;
@@ -310,7 +310,7 @@ struct BubbleExtras {
310}
310}
311
311
312fn agent_chip(run: Option<AgentRun>) -> Option<Div> {
312fn agent_chip(run: Option<AgentRun>) -> Option<Div> {
313 run.map(|run| div().pt(px(2.)).child(run_chip(&run, theme::row_hover())))
313 run.map(|run| div().py(px(2.)).child(run_chip(&run, theme::row_hover())))
314}
314}
315
315
316pub(super) fn forwarded_header() -> Div {
316pub(super) fn forwarded_header() -> Div {
@@ -355,13 +355,21 @@ fn bubble_meta(row: &MessageRow, own: bool, saved: bool) -> Div {
355 own && row.delivery == Delivery::Delivered,
355 own && row.delivery == Delivery::Delivered,
356 |meta| match row.receipt {
356 |meta| match row.receipt {
357 Receipt::Hidden => meta,
357 Receipt::Hidden => meta,
358 Receipt::Pending => meta.child(receipt_slot(tint)),
358 Receipt::Pending => meta.child(receipt_slot(tint).relative().top(px(1.))),
359 Receipt::Sent => meta.child(symbol("done", META_CHECK_SIZE, tint)),
359 Receipt::Sent => meta.child(on_baseline(symbol("done", META_CHECK_SIZE, tint))),
360 Receipt::Read => meta.child(symbol("done_all", META_CHECK_SIZE, theme::own_read())),
360 Receipt::Read => meta.child(on_baseline(symbol(
361 "done_all",
362 META_CHECK_SIZE,
363 theme::own_read(),
364 ))),
361 },
365 },
362 )
366 )
363}
367}
364
368
369fn on_baseline(check: Icon) -> Div {
370 div().relative().top(px(1.)).child(check)
371}
372
365fn pulse<E: IntoElement + Styled + 'static>(id: &'static str, element: E) -> AnimationElement<E> {
373fn pulse<E: IntoElement + Styled + 'static>(id: &'static str, element: E) -> AnimationElement<E> {
366 element.with_animation(
374 element.with_animation(
367 id,
375 id,
crates/app/src/views/new_chat.rs +5 −19
@@ -137,24 +137,11 @@ pub fn existing_one_on_one<'chats>(
137 137 })
138 138 }
139 139
140 pub fn group_label(chips: &[Pick], group_name: &str) -> String {
141 let name = group_name.trim();
142 if name.is_empty() {
143 chips
144 .iter()
145 .map(|chip| chip.name.as_str())
146 .collect::<Vec<_>>()
147 .join(", ")
148 } else {
149 name.to_owned()
150 }
151 }
152
153 140 pub fn composer_placeholder(chips: &[Pick], group_name: &str) -> String {
154 141 match chips {
155 [] => DEFAULT_PLACEHOLDER.to_owned(),
156 142 [chip] => format!("Message {}", chip.name),
157 _ => format!("Message {}", group_label(chips, group_name)),
143 [_, _, ..] if !group_name.trim().is_empty() => format!("Message {}", group_name.trim()),
144 _ => DEFAULT_PLACEHOLDER.to_owned(),
158 145 }
159 146 }
160 147
@@ -792,8 +779,8 @@ mod tests {
792 779 use store::{ChatRecord, MemberRecord};
793 780
794 781 use super::{
795 EnterAction, Pick, composer_placeholder, enter_action, existing_one_on_one, group_label,
796 search_results, suggested_people,
782 EnterAction, Pick, composer_placeholder, enter_action, existing_one_on_one, search_results,
783 suggested_people,
797 784 };
798 785 use crate::data::Person;
799 786
@@ -903,9 +890,8 @@ mod tests {
903 890 let two = [pick("ann", "Ann", None), pick("bob", "Bob", None)];
904 891 assert_eq!(composer_placeholder(&[], ""), "Type a message");
905 892 assert_eq!(composer_placeholder(&one, "ignored"), "Message Ann");
906 assert_eq!(composer_placeholder(&two, " "), "Message Ann, Bob");
893 assert_eq!(composer_placeholder(&two, " "), "Type a message");
907 894 assert_eq!(composer_placeholder(&two, " Crew "), "Message Crew");
908 assert_eq!(group_label(&two, ""), "Ann, Bob");
909 895 }
910 896
911 897 #[test]
@@ -137,24 +137,11 @@ pub fn existing_one_on_one<'chats>(
137 })
137 })
138}
138}
139
139
140pub fn group_label(chips: &[Pick], group_name: &str) -> String {
141 let name = group_name.trim();
142 if name.is_empty() {
143 chips
144 .iter()
145 .map(|chip| chip.name.as_str())
146 .collect::<Vec<_>>()
147 .join(", ")
148 } else {
149 name.to_owned()
150 }
151}
152
153pub fn composer_placeholder(chips: &[Pick], group_name: &str) -> String {
140pub fn composer_placeholder(chips: &[Pick], group_name: &str) -> String {
154 match chips {
141 match chips {
155 [] => DEFAULT_PLACEHOLDER.to_owned(),
156 [chip] => format!("Message {}", chip.name),
142 [chip] => format!("Message {}", chip.name),
157 _ => format!("Message {}", group_label(chips, group_name)),
143 [_, _, ..] if !group_name.trim().is_empty() => format!("Message {}", group_name.trim()),
144 _ => DEFAULT_PLACEHOLDER.to_owned(),
158 }
145 }
159}
146}
160
147
@@ -792,8 +779,8 @@ mod tests {
792 use store::{ChatRecord, MemberRecord};
779 use store::{ChatRecord, MemberRecord};
793
780
794 use super::{
781 use super::{
795 EnterAction, Pick, composer_placeholder, enter_action, existing_one_on_one, group_label,
782 EnterAction, Pick, composer_placeholder, enter_action, existing_one_on_one, search_results,
796 search_results, suggested_people,
783 suggested_people,
797 };
784 };
798 use crate::data::Person;
785 use crate::data::Person;
799
786
@@ -903,9 +890,8 @@ mod tests {
903 let two = [pick("ann", "Ann", None), pick("bob", "Bob", None)];
890 let two = [pick("ann", "Ann", None), pick("bob", "Bob", None)];
904 assert_eq!(composer_placeholder(&[], ""), "Type a message");
891 assert_eq!(composer_placeholder(&[], ""), "Type a message");
905 assert_eq!(composer_placeholder(&one, "ignored"), "Message Ann");
892 assert_eq!(composer_placeholder(&one, "ignored"), "Message Ann");
906 assert_eq!(composer_placeholder(&two, " "), "Message Ann, Bob");
893 assert_eq!(composer_placeholder(&two, " "), "Type a message");
907 assert_eq!(composer_placeholder(&two, " Crew "), "Message Crew");
894 assert_eq!(composer_placeholder(&two, " Crew "), "Message Crew");
908 assert_eq!(group_label(&two, ""), "Ann, Bob");
909 }
895 }
910
896
911 #[test]
897 #[test]
crates/core/src/lib.rs +1 −1
@@ -137,7 +137,7 @@ pub use stored::{
137 137 AttachmentInfo, FileCard, FileKind, ImageKind, ImageRef, MentionInfo, PROFILE_LINK_PREFIX,
138 138 QuoteInfo, ReactionInfo, ReactionSummary, adaptive_cards, attachments, can_delete, can_edit,
139 139 card_texts, copy_text, files, images, linked_message_spans, mentions, message_quote,
140 message_spans, quotes, reaction_summaries, reactions, readable_text, translated_spans,
140 message_spans, quote_html, quotes, reaction_summaries, reactions, readable_text, translated_spans,
141 141 user_mention_inputs,
142 142 };
143 143 pub use time_zone::local_time;
@@ -137,7 +137,7 @@ pub use stored::{
137 AttachmentInfo, FileCard, FileKind, ImageKind, ImageRef, MentionInfo, PROFILE_LINK_PREFIX,
137 AttachmentInfo, FileCard, FileKind, ImageKind, ImageRef, MentionInfo, PROFILE_LINK_PREFIX,
138 QuoteInfo, ReactionInfo, ReactionSummary, adaptive_cards, attachments, can_delete, can_edit,
138 QuoteInfo, ReactionInfo, ReactionSummary, adaptive_cards, attachments, can_delete, can_edit,
139 card_texts, copy_text, files, images, linked_message_spans, mentions, message_quote,
139 card_texts, copy_text, files, images, linked_message_spans, mentions, message_quote,
140 message_spans, quotes, reaction_summaries, reactions, readable_text, translated_spans,
140 message_spans, quote_html, quotes, reaction_summaries, reactions, readable_text, translated_spans,
141 user_mention_inputs,
141 user_mention_inputs,
142};
142};
143pub use time_zone::local_time;
143pub use time_zone::local_time;
crates/core/src/stored.rs +1 −1
@@ -632,7 +632,7 @@ fn with_inline_quotes(record: &MessageRecord) -> String {
632 632 html
633 633 }
634 634
635 fn quote_html(quote: &QuoteInfo) -> String {
635 pub fn quote_html(quote: &QuoteInfo) -> String {
636 636 let sender = quote
637 637 .sender_name
638 638 .as_deref()
@@ -632,7 +632,7 @@ fn with_inline_quotes(record: &MessageRecord) -> String {
632 html
632 html
633}
633}
634
634
635fn quote_html(quote: &QuoteInfo) -> String {
635pub fn quote_html(quote: &QuoteInfo) -> String {
636 let sender = quote
636 let sender = quote
637 .sender_name
637 .sender_name
638 .as_deref()
638 .as_deref()