BlueGit

ict rusty-teams

fix(composer): put the actions below the input when the composer is narrow

- under 400 px the input gets the full width, actions and send move to a row below (Teams meeting chat layout)
- layout_guard checks the stacked row and the send insets

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

metis Daniel Däschle · pushed by metis

Authored 2026-11-10 · 3 weeks ago

Hash
e3b8e0719760733cbf4836c5ec686212d5d32329
Parent
762fb676
2 files changed +49 −5
crates/app/src/layout_guard.rs +24 −1
@@ -185,7 +185,7 @@ mod frames {
185 185 use crate::views::composer::plus_menu::{COMPOSER_PLUS_TAG, PlusAction};
186 186 use crate::views::composer::{
187 187 COMPOSER_BOX_TAG, COMPOSER_FORMAT_BAR_TAG, COMPOSER_FORMAT_DIVIDER_TAG,
188 COMPOSER_ACTIONS_TAG, COMPOSER_FORMAT_TAG, COMPOSER_INPUT_TAG, COMPOSER_SEND_TAG,
188 COMPOSER_ACTIONS_TAG, COMPOSER_FORMAT_TAG, COMPOSER_INPUT_TAG, COMPOSER_SEND_TAG, COMPOSER_STACKED_ACTIONS_TAG,
189 189 POST_ANNOUNCEMENT_TAG, POST_ANNOUNCEMENT_TOGGLE_TAG, POST_AUDIENCE_TAG, POST_CARD_DIVIDER_TAG, POST_CARD_FOOTER_TAG, POST_CARD_HEADER_TAG, POST_CARD_SEND_TAG,
190 190 POST_CARD_SUBJECT_TAG,
191 191 };
@@ -1132,6 +1132,29 @@ mod frames {
1132 1132 );
1133 1133 }
1134 1134
1135 #[gpui_kit::test]
1136 fn a_narrow_composer_puts_its_actions_below_a_full_width_input(cx: &mut TestAppContext) {
1137 let (handle, _) = mount(cx);
1138 let mut visual = VisualTestContext::from_window(handle, cx);
1139 visual.simulate_resize(size(px(760.), px(700.)));
1140 collect(&mut visual, Some(COMPOSER_STACKED_ACTIONS_TAG));
1141 let bounds_of = |visual: &mut VisualTestContext, path: &'static str| {
1142 visual.debug_bounds(path).unwrap_or_else(|| panic!("{path} missing"))
1143 };
1144 let card = bounds_of(&mut visual, COMPOSER_BOX_TAG);
1145 let input = bounds_of(&mut visual, COMPOSER_INPUT_TAG);
1146 let stacked = bounds_of(&mut visual, COMPOSER_STACKED_ACTIONS_TAG);
1147 let send = bounds_of(&mut visual, COMPOSER_SEND_TAG);
1148 assert!(input.bottom() <= stacked.top(), "actions {} not below input {}", describe(stacked), describe(input));
1149 assert!(contains(card, stacked) && contains(stacked, send), "send {} outside {}", describe(send), describe(stacked));
1150 let side = f32::from(card.right() - send.right());
1151 let bottom = f32::from(card.bottom() - send.bottom());
1152 assert!((side - bottom).abs() < TOLERANCE, "send insets: side {side}, bottom {bottom}");
1153 visual.simulate_resize(size(px(1280.), px(800.)));
1154 collect(&mut visual, Some(COMPOSER_SEND_TAG));
1155 assert!(visual.debug_bounds(COMPOSER_STACKED_ACTIONS_TAG).is_none(), "wide composer stacked");
1156 }
1157
1135 1158 const TITLE_SEARCH: &str = "shell/title-bar/search";
1136 1159 const TITLE_NEIGHBOURS: &[&str] = &[
1137 1160 "shell/title-bar/leading",
@@ -185,7 +185,7 @@ mod frames {
185 use crate::views::composer::plus_menu::{COMPOSER_PLUS_TAG, PlusAction};
185 use crate::views::composer::plus_menu::{COMPOSER_PLUS_TAG, PlusAction};
186 use crate::views::composer::{
186 use crate::views::composer::{
187 COMPOSER_BOX_TAG, COMPOSER_FORMAT_BAR_TAG, COMPOSER_FORMAT_DIVIDER_TAG,
187 COMPOSER_BOX_TAG, COMPOSER_FORMAT_BAR_TAG, COMPOSER_FORMAT_DIVIDER_TAG,
188 COMPOSER_ACTIONS_TAG, COMPOSER_FORMAT_TAG, COMPOSER_INPUT_TAG, COMPOSER_SEND_TAG,
188 COMPOSER_ACTIONS_TAG, COMPOSER_FORMAT_TAG, COMPOSER_INPUT_TAG, COMPOSER_SEND_TAG, COMPOSER_STACKED_ACTIONS_TAG,
189 POST_ANNOUNCEMENT_TAG, POST_ANNOUNCEMENT_TOGGLE_TAG, POST_AUDIENCE_TAG, POST_CARD_DIVIDER_TAG, POST_CARD_FOOTER_TAG, POST_CARD_HEADER_TAG, POST_CARD_SEND_TAG,
189 POST_ANNOUNCEMENT_TAG, POST_ANNOUNCEMENT_TOGGLE_TAG, POST_AUDIENCE_TAG, POST_CARD_DIVIDER_TAG, POST_CARD_FOOTER_TAG, POST_CARD_HEADER_TAG, POST_CARD_SEND_TAG,
190 POST_CARD_SUBJECT_TAG,
190 POST_CARD_SUBJECT_TAG,
191 };
191 };
@@ -1132,6 +1132,29 @@ mod frames {
1132 );
1132 );
1133 }
1133 }
1134
1134
1135 #[gpui_kit::test]
1136 fn a_narrow_composer_puts_its_actions_below_a_full_width_input(cx: &mut TestAppContext) {
1137 let (handle, _) = mount(cx);
1138 let mut visual = VisualTestContext::from_window(handle, cx);
1139 visual.simulate_resize(size(px(760.), px(700.)));
1140 collect(&mut visual, Some(COMPOSER_STACKED_ACTIONS_TAG));
1141 let bounds_of = |visual: &mut VisualTestContext, path: &'static str| {
1142 visual.debug_bounds(path).unwrap_or_else(|| panic!("{path} missing"))
1143 };
1144 let card = bounds_of(&mut visual, COMPOSER_BOX_TAG);
1145 let input = bounds_of(&mut visual, COMPOSER_INPUT_TAG);
1146 let stacked = bounds_of(&mut visual, COMPOSER_STACKED_ACTIONS_TAG);
1147 let send = bounds_of(&mut visual, COMPOSER_SEND_TAG);
1148 assert!(input.bottom() <= stacked.top(), "actions {} not below input {}", describe(stacked), describe(input));
1149 assert!(contains(card, stacked) && contains(stacked, send), "send {} outside {}", describe(send), describe(stacked));
1150 let side = f32::from(card.right() - send.right());
1151 let bottom = f32::from(card.bottom() - send.bottom());
1152 assert!((side - bottom).abs() < TOLERANCE, "send insets: side {side}, bottom {bottom}");
1153 visual.simulate_resize(size(px(1280.), px(800.)));
1154 collect(&mut visual, Some(COMPOSER_SEND_TAG));
1155 assert!(visual.debug_bounds(COMPOSER_STACKED_ACTIONS_TAG).is_none(), "wide composer stacked");
1156 }
1157
1135 const TITLE_SEARCH: &str = "shell/title-bar/search";
1158 const TITLE_SEARCH: &str = "shell/title-bar/search";
1136 const TITLE_NEIGHBOURS: &[&str] = &[
1159 const TITLE_NEIGHBOURS: &[&str] = &[
1137 "shell/title-bar/leading",
1160 "shell/title-bar/leading",
crates/app/src/views/composer.rs +25 −4
@@ -98,6 +98,8 @@ const COMPOSER_BUTTON_SIZE: f32 = 32.;
98 98 const COMPOSER_BUTTON_INSET: f32 = 6.;
99 99 pub const COMPOSER_BOX_TAG: &str = "composer";
100 100 pub const COMPOSER_ACTIONS_TAG: &str = "composer/actions";
101 pub const COMPOSER_STACKED_ACTIONS_TAG: &str = "composer/stacked-actions";
102 const STACKED_ACTIONS_WIDTH: f32 = 400.;
101 103 pub const COMPOSER_INPUT_TAG: &str = "composer/input";
102 104 pub const COMPOSER_SEND_TAG: &str = "composer/send";
103 105 pub const COMPOSER_FORMAT_TAG: &str = "composer/actions/format";
@@ -2990,10 +2992,18 @@ impl Render for Composer {
2990 2992 .children(attach)
2991 2993 .children(self.render_rewrite_button(cx))
2992 2994 .children(self.render_plus_button(cx));
2993 let (row_actions, post_footer) = if post_layout {
2994 (None, Some(self.render_post_footer(actions, can_send, cx)))
2995 let stacked = !post_layout
2996 && self
2997 .composer_bounds
2998 .get()
2999 .is_some_and(|bounds| f32::from(bounds.size.width) < STACKED_ACTIONS_WIDTH);
3000 let mut send = Some(send);
3001 let (row_actions, stacked_actions, post_footer) = if post_layout {
3002 (None, None, Some(self.render_post_footer(actions, can_send, cx)))
3003 } else if stacked {
3004 (None, Some((actions, send.take())), None)
2995 3005 } else {
2996 (Some(actions.ml(px(COMPOSER_BUTTON_INSET))), None)
3006 (Some(actions.ml(px(COMPOSER_BUTTON_INSET))), None, None)
2997 3007 };
2998 3008 let post_header = self.render_post_header(cx);
2999 3009 let composer = cx.weak_entity();
@@ -3527,7 +3537,7 @@ impl Render for Composer {
3527 3537 .child(input),
3528 3538 )
3529 3539 .children(row_actions)
3530 .when(!post_layout, |row| {
3540 .when_some(send.filter(|_| !post_layout), |row, send| {
3531 3541 row.child(
3532 3542 div()
3533 3543 .flex_none()
@@ -3539,6 +3549,17 @@ impl Render for Composer {
3539 3549 .child(send)
3540 3550 }),
3541 3551 )
3552 .children(stacked_actions.map(|(actions, send)| {
3553 h_flex()
3554 .debug_selector(|| COMPOSER_STACKED_ACTIONS_TAG.into())
3555 .w_full()
3556 .items_center()
3557 .px(px(COMPOSER_BUTTON_INSET))
3558 .pb(px(COMPOSER_BUTTON_INSET))
3559 .child(actions)
3560 .child(div().flex_1())
3561 .children(send)
3562 }))
3542 3563 .children(post_footer),
3543 3564 ),
3544 3565 )
@@ -98,6 +98,8 @@ const COMPOSER_BUTTON_SIZE: f32 = 32.;
98const COMPOSER_BUTTON_INSET: f32 = 6.;
98const COMPOSER_BUTTON_INSET: f32 = 6.;
99pub const COMPOSER_BOX_TAG: &str = "composer";
99pub const COMPOSER_BOX_TAG: &str = "composer";
100pub const COMPOSER_ACTIONS_TAG: &str = "composer/actions";
100pub const COMPOSER_ACTIONS_TAG: &str = "composer/actions";
101pub const COMPOSER_STACKED_ACTIONS_TAG: &str = "composer/stacked-actions";
102const STACKED_ACTIONS_WIDTH: f32 = 400.;
101pub const COMPOSER_INPUT_TAG: &str = "composer/input";
103pub const COMPOSER_INPUT_TAG: &str = "composer/input";
102pub const COMPOSER_SEND_TAG: &str = "composer/send";
104pub const COMPOSER_SEND_TAG: &str = "composer/send";
103pub const COMPOSER_FORMAT_TAG: &str = "composer/actions/format";
105pub const COMPOSER_FORMAT_TAG: &str = "composer/actions/format";
@@ -2990,10 +2992,18 @@ impl Render for Composer {
2990 .children(attach)
2992 .children(attach)
2991 .children(self.render_rewrite_button(cx))
2993 .children(self.render_rewrite_button(cx))
2992 .children(self.render_plus_button(cx));
2994 .children(self.render_plus_button(cx));
2993 let (row_actions, post_footer) = if post_layout {
2995 let stacked = !post_layout
2994 (None, Some(self.render_post_footer(actions, can_send, cx)))
2996 && self
2997 .composer_bounds
2998 .get()
2999 .is_some_and(|bounds| f32::from(bounds.size.width) < STACKED_ACTIONS_WIDTH);
3000 let mut send = Some(send);
3001 let (row_actions, stacked_actions, post_footer) = if post_layout {
3002 (None, None, Some(self.render_post_footer(actions, can_send, cx)))
3003 } else if stacked {
3004 (None, Some((actions, send.take())), None)
2995 } else {
3005 } else {
2996 (Some(actions.ml(px(COMPOSER_BUTTON_INSET))), None)
3006 (Some(actions.ml(px(COMPOSER_BUTTON_INSET))), None, None)
2997 };
3007 };
2998 let post_header = self.render_post_header(cx);
3008 let post_header = self.render_post_header(cx);
2999 let composer = cx.weak_entity();
3009 let composer = cx.weak_entity();
@@ -3527,7 +3537,7 @@ impl Render for Composer {
3527 .child(input),
3537 .child(input),
3528 )
3538 )
3529 .children(row_actions)
3539 .children(row_actions)
3530 .when(!post_layout, |row| {
3540 .when_some(send.filter(|_| !post_layout), |row, send| {
3531 row.child(
3541 row.child(
3532 div()
3542 div()
3533 .flex_none()
3543 .flex_none()
@@ -3539,6 +3549,17 @@ impl Render for Composer {
3539 .child(send)
3549 .child(send)
3540 }),
3550 }),
3541 )
3551 )
3552 .children(stacked_actions.map(|(actions, send)| {
3553 h_flex()
3554 .debug_selector(|| COMPOSER_STACKED_ACTIONS_TAG.into())
3555 .w_full()
3556 .items_center()
3557 .px(px(COMPOSER_BUTTON_INSET))
3558 .pb(px(COMPOSER_BUTTON_INSET))
3559 .child(actions)
3560 .child(div().flex_1())
3561 .children(send)
3562 }))
3542 .children(post_footer),
3563 .children(post_footer),
3543 ),
3564 ),
3544 )
3565 )