BlueGit

ict rusty-teams

feat(chat): comfy density caps the message column at 1060 px like Teams

- Teams chatPaneRunway: maxWidth 106rem, margin auto in comfy, full width in compact
- bubble max width follows the capped column

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

metis Daniel Däschle · pushed by metis

Authored 2026-11-05 · 3 weeks ago

Hash
47510b291478eb623bce70e9f6ca8803f682dfe7
Parent
07bded8c
3 files changed +36 −8
crates/app-ui-kit/src/layout.rs +1 −0
@@ -3,3 +3,4 @@ pub const RAIL_ITEM_WIDTH: f32 = 48.;
3 3 pub const RAIL_WIDTH: f32 = RAIL_ITEM_WIDTH + 2. * ISLAND_GAP;
4 4 pub const SIDEBAR_WIDTH: f32 = 300.;
5 5 pub const ROW_PADDING: f32 = 20.;
6 pub const COMFY_RUNWAY_WIDTH: f32 = 1060.;
@@ -3,3 +3,4 @@ pub const RAIL_ITEM_WIDTH: f32 = 48.;
3pub const RAIL_WIDTH: f32 = RAIL_ITEM_WIDTH + 2. * ISLAND_GAP;
3pub const RAIL_WIDTH: f32 = RAIL_ITEM_WIDTH + 2. * ISLAND_GAP;
4pub const SIDEBAR_WIDTH: f32 = 300.;
4pub const SIDEBAR_WIDTH: f32 = 300.;
5pub const ROW_PADDING: f32 = 20.;
5pub const ROW_PADDING: f32 = 20.;
6pub const COMFY_RUNWAY_WIDTH: f32 = 1060.;
crates/app/src/views/conversation.rs +13 −2
@@ -98,7 +98,7 @@ use crate::sidebar_model::{AvatarSpec, Face, channel_unread};
98 98 use crate::theme;
99 99 use crate::translation::TranslationLine;
100 100 use crate::typing::typing_tooltip;
101 use app_ui_kit::layout::{ISLAND_GAP, RAIL_WIDTH, SIDEBAR_WIDTH};
101 use app_ui_kit::layout::{COMFY_RUNWAY_WIDTH, ISLAND_GAP, RAIL_WIDTH, SIDEBAR_WIDTH};
102 102 use detached::DetachedWindow;
103 103 use feed::{FeedStash, subject_input};
104 104 use mcp::ReactionProposal;
@@ -3692,13 +3692,15 @@ impl Render for ConversationView {
3692 3692 .render_pin_banner(cx)
3693 3693 .filter(|_| !drafting && !self.shared_active() && !self.recap_active());
3694 3694 let timeline_top_inset = pin_banner_inset(pin_banner.is_some());
3695 let comfy = self.app.read(cx).account_chat_settings().message_density
3696 != teams_core::MessageDensity::Compact;
3695 3697 let scroller = MessageScroller::new(
3696 3698 "messages",
3697 3699 self.scroller.clone(),
3698 3700 move |index, window, cx| {
3699 3701 rows_seen.set(rows_seen.get().min(index));
3700 3702 let rows = rows.borrow();
3701 match rows.get(index) {
3703 let row = match rows.get(index) {
3702 3704 Some(Row::Message(message)) => {
3703 3705 let actions = env.message_actions(message, window, cx);
3704 3706 let state = env.app.read(cx);
@@ -3785,6 +3787,15 @@ impl Render for ConversationView {
3785 3787 .into_any_element()
3786 3788 }
3787 3789 None => div().into_any_element(),
3790 };
3791 if comfy {
3792 h_flex()
3793 .w_full()
3794 .justify_center()
3795 .child(div().w_full().max_w(px(COMFY_RUNWAY_WIDTH)).child(row))
3796 .into_any_element()
3797 } else {
3798 row
3788 3799 }
3789 3800 },
3790 3801 )
@@ -98,7 +98,7 @@ use crate::sidebar_model::{AvatarSpec, Face, channel_unread};
98use crate::theme;
98use crate::theme;
99use crate::translation::TranslationLine;
99use crate::translation::TranslationLine;
100use crate::typing::typing_tooltip;
100use crate::typing::typing_tooltip;
101use app_ui_kit::layout::{ISLAND_GAP, RAIL_WIDTH, SIDEBAR_WIDTH};
101use app_ui_kit::layout::{COMFY_RUNWAY_WIDTH, ISLAND_GAP, RAIL_WIDTH, SIDEBAR_WIDTH};
102use detached::DetachedWindow;
102use detached::DetachedWindow;
103use feed::{FeedStash, subject_input};
103use feed::{FeedStash, subject_input};
104use mcp::ReactionProposal;
104use mcp::ReactionProposal;
@@ -3692,13 +3692,15 @@ impl Render for ConversationView {
3692 .render_pin_banner(cx)
3692 .render_pin_banner(cx)
3693 .filter(|_| !drafting && !self.shared_active() && !self.recap_active());
3693 .filter(|_| !drafting && !self.shared_active() && !self.recap_active());
3694 let timeline_top_inset = pin_banner_inset(pin_banner.is_some());
3694 let timeline_top_inset = pin_banner_inset(pin_banner.is_some());
3695 let comfy = self.app.read(cx).account_chat_settings().message_density
3696 != teams_core::MessageDensity::Compact;
3695 let scroller = MessageScroller::new(
3697 let scroller = MessageScroller::new(
3696 "messages",
3698 "messages",
3697 self.scroller.clone(),
3699 self.scroller.clone(),
3698 move |index, window, cx| {
3700 move |index, window, cx| {
3699 rows_seen.set(rows_seen.get().min(index));
3701 rows_seen.set(rows_seen.get().min(index));
3700 let rows = rows.borrow();
3702 let rows = rows.borrow();
3701 match rows.get(index) {
3703 let row = match rows.get(index) {
3702 Some(Row::Message(message)) => {
3704 Some(Row::Message(message)) => {
3703 let actions = env.message_actions(message, window, cx);
3705 let actions = env.message_actions(message, window, cx);
3704 let state = env.app.read(cx);
3706 let state = env.app.read(cx);
@@ -3785,6 +3787,15 @@ impl Render for ConversationView {
3785 .into_any_element()
3787 .into_any_element()
3786 }
3788 }
3787 None => div().into_any_element(),
3789 None => div().into_any_element(),
3790 };
3791 if comfy {
3792 h_flex()
3793 .w_full()
3794 .justify_center()
3795 .child(div().w_full().max_w(px(COMFY_RUNWAY_WIDTH)).child(row))
3796 .into_any_element()
3797 } else {
3798 row
3788 }
3799 }
3789 },
3800 },
3790 )
3801 )
crates/app/src/views/message_row.rs +22 −6
@@ -28,7 +28,7 @@ use crate::restorable_deletes::{DELETED_TOMBSTONE, UNDO_DELETE_LABEL};
28 28 use crate::rows::{Delivery, MessageRow, Receipt, ScheduledState, Skeleton, bubble_corners};
29 29 use crate::sidebar_model::DELETED_PREVIEW;
30 30 use crate::theme;
31 use app_ui_kit::layout::ROW_PADDING;
31 use app_ui_kit::layout::{COMFY_RUNWAY_WIDTH, ROW_PADDING};
32 32
33 33 pub type RowAction = Option<Box<dyn Fn(&mut App)>>;
34 34 pub type SharedRowAction = Option<std::rc::Rc<dyn Fn(&mut App)>>;
@@ -198,14 +198,23 @@ pub(super) fn deleted_tombstone(index: usize, undo_delete: SharedRowAction) -> D
198 198 }
199 199 }
200 200
201 fn bubble_max_width(timeline: &TimelineBounds, reserved: f32) -> Length {
201 fn bubble_max_width(timeline: &TimelineBounds, reserved: f32, compact: bool) -> Length {
202 202 let Some(bounds) = timeline.get() else {
203 203 return relative(MAX_WIDTH_RATIO).into();
204 204 };
205 let row_width = (f32::from(bounds.size.width) - 2. * ROW_PADDING - reserved).max(0.);
205 let runway = runway_width(f32::from(bounds.size.width), compact);
206 let row_width = (runway - 2. * ROW_PADDING - reserved).max(0.);
206 207 px((row_width * MAX_WIDTH_RATIO).max(row_width.min(NARROW_BUBBLE_WIDTH))).into()
207 208 }
208 209
210 pub fn runway_width(timeline_width: f32, compact: bool) -> f32 {
211 if compact {
212 timeline_width
213 } else {
214 timeline_width.min(COMFY_RUNWAY_WIDTH)
215 }
216 }
217
209 218 fn bubble(
210 219 row: &MessageRow,
211 220 index: usize,
@@ -652,7 +661,7 @@ fn others_row(
652 661 .gap(px(2.))
653 662 .flex_1()
654 663 .min_w_0()
655 .max_w(bubble_max_width(&extras.timeline, AVATAR_SIZE + AVATAR_GAP))
664 .max_w(bubble_max_width(&extras.timeline, AVATAR_SIZE + AVATAR_GAP, extras.compact))
656 665 .items_start();
657 666 if first {
658 667 column = column.child(
@@ -719,7 +728,7 @@ fn own_row(
719 728 h_flex().w_full().justify_end().child(
720 729 div()
721 730 .min_w_0()
722 .max_w(bubble_max_width(&extras.timeline, 0.))
731 .max_w(bubble_max_width(&extras.timeline, 0., extras.compact))
723 732 .child(bubble(row, index, true, directory, extras, cx)),
724 733 ),
725 734 );
@@ -885,7 +894,7 @@ pub fn select_box(checked: bool, blocked: bool, index: usize) -> Div {
885 894
886 895 #[cfg(test)]
887 896 mod density_tests {
888 use super::{META_BOTTOM_INSET, bubble_padding_y, row_spacing};
897 use super::{META_BOTTOM_INSET, bubble_padding_y, row_spacing, runway_width};
889 898
890 899 #[test]
891 900 fn compact_density_tightens_gaps_and_bubble_padding() {
@@ -894,4 +903,11 @@ mod density_tests {
894 903 assert!(bubble_padding_y(true) < bubble_padding_y(false));
895 904 assert!(META_BOTTOM_INSET - bubble_padding_y(true) >= 0.);
896 905 }
906
907 #[test]
908 fn comfy_density_caps_the_runway_like_teams_and_compact_uses_the_full_width() {
909 assert_eq!(runway_width(2400., false), 1060.);
910 assert_eq!(runway_width(800., false), 800.);
911 assert_eq!(runway_width(2400., true), 2400.);
912 }
897 913 }
@@ -28,7 +28,7 @@ use crate::restorable_deletes::{DELETED_TOMBSTONE, UNDO_DELETE_LABEL};
28use crate::rows::{Delivery, MessageRow, Receipt, ScheduledState, Skeleton, bubble_corners};
28use crate::rows::{Delivery, MessageRow, Receipt, ScheduledState, Skeleton, bubble_corners};
29use crate::sidebar_model::DELETED_PREVIEW;
29use crate::sidebar_model::DELETED_PREVIEW;
30use crate::theme;
30use crate::theme;
31use app_ui_kit::layout::ROW_PADDING;
31use app_ui_kit::layout::{COMFY_RUNWAY_WIDTH, ROW_PADDING};
32
32
33pub type RowAction = Option<Box<dyn Fn(&mut App)>>;
33pub type RowAction = Option<Box<dyn Fn(&mut App)>>;
34pub type SharedRowAction = Option<std::rc::Rc<dyn Fn(&mut App)>>;
34pub type SharedRowAction = Option<std::rc::Rc<dyn Fn(&mut App)>>;
@@ -198,14 +198,23 @@ pub(super) fn deleted_tombstone(index: usize, undo_delete: SharedRowAction) -> D
198 }
198 }
199}
199}
200
200
201fn bubble_max_width(timeline: &TimelineBounds, reserved: f32) -> Length {
201fn bubble_max_width(timeline: &TimelineBounds, reserved: f32, compact: bool) -> Length {
202 let Some(bounds) = timeline.get() else {
202 let Some(bounds) = timeline.get() else {
203 return relative(MAX_WIDTH_RATIO).into();
203 return relative(MAX_WIDTH_RATIO).into();
204 };
204 };
205 let row_width = (f32::from(bounds.size.width) - 2. * ROW_PADDING - reserved).max(0.);
205 let runway = runway_width(f32::from(bounds.size.width), compact);
206 let row_width = (runway - 2. * ROW_PADDING - reserved).max(0.);
206 px((row_width * MAX_WIDTH_RATIO).max(row_width.min(NARROW_BUBBLE_WIDTH))).into()
207 px((row_width * MAX_WIDTH_RATIO).max(row_width.min(NARROW_BUBBLE_WIDTH))).into()
207}
208}
208
209
210pub fn runway_width(timeline_width: f32, compact: bool) -> f32 {
211 if compact {
212 timeline_width
213 } else {
214 timeline_width.min(COMFY_RUNWAY_WIDTH)
215 }
216}
217
209fn bubble(
218fn bubble(
210 row: &MessageRow,
219 row: &MessageRow,
211 index: usize,
220 index: usize,
@@ -652,7 +661,7 @@ fn others_row(
652 .gap(px(2.))
661 .gap(px(2.))
653 .flex_1()
662 .flex_1()
654 .min_w_0()
663 .min_w_0()
655 .max_w(bubble_max_width(&extras.timeline, AVATAR_SIZE + AVATAR_GAP))
664 .max_w(bubble_max_width(&extras.timeline, AVATAR_SIZE + AVATAR_GAP, extras.compact))
656 .items_start();
665 .items_start();
657 if first {
666 if first {
658 column = column.child(
667 column = column.child(
@@ -719,7 +728,7 @@ fn own_row(
719 h_flex().w_full().justify_end().child(
728 h_flex().w_full().justify_end().child(
720 div()
729 div()
721 .min_w_0()
730 .min_w_0()
722 .max_w(bubble_max_width(&extras.timeline, 0.))
731 .max_w(bubble_max_width(&extras.timeline, 0., extras.compact))
723 .child(bubble(row, index, true, directory, extras, cx)),
732 .child(bubble(row, index, true, directory, extras, cx)),
724 ),
733 ),
725 );
734 );
@@ -885,7 +894,7 @@ pub fn select_box(checked: bool, blocked: bool, index: usize) -> Div {
885
894
886#[cfg(test)]
895#[cfg(test)]
887mod density_tests {
896mod density_tests {
888 use super::{META_BOTTOM_INSET, bubble_padding_y, row_spacing};
897 use super::{META_BOTTOM_INSET, bubble_padding_y, row_spacing, runway_width};
889
898
890 #[test]
899 #[test]
891 fn compact_density_tightens_gaps_and_bubble_padding() {
900 fn compact_density_tightens_gaps_and_bubble_padding() {
@@ -894,4 +903,11 @@ mod density_tests {
894 assert!(bubble_padding_y(true) < bubble_padding_y(false));
903 assert!(bubble_padding_y(true) < bubble_padding_y(false));
895 assert!(META_BOTTOM_INSET - bubble_padding_y(true) >= 0.);
904 assert!(META_BOTTOM_INSET - bubble_padding_y(true) >= 0.);
896 }
905 }
906
907 #[test]
908 fn comfy_density_caps_the_runway_like_teams_and_compact_uses_the_full_width() {
909 assert_eq!(runway_width(2400., false), 1060.);
910 assert_eq!(runway_width(800., false), 800.);
911 assert_eq!(runway_width(2400., true), 2400.);
912 }
897}
913}