BlueGit

ict rusty-teams

feat(chat): composer, proposal card and pin banner share the comfy column

- layout_guard measures row and banner insets from the column edge

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
9b18c939be9b14164685b1ac9c1cb916dc3f7970
Parent
146edfcd
2 files changed +42 −25
crates/app/src/layout_guard.rs +16 −9
@@ -156,7 +156,7 @@ mod frames {
156 156 use std::sync::Arc;
157 157 use std::time::Duration;
158 158
159 use app_ui_kit::layout::ROW_PADDING;
159 use app_ui_kit::layout::{COMFY_RUNWAY_WIDTH, ROW_PADDING};
160 160 use gpui_kit::test::TestWindowExt as _;
161 161 use gpui_kit::{
162 162 AppContext as _, Bounds, Pixels, ScrollDelta, ScrollWheelEvent, TestAppContext,
@@ -237,6 +237,10 @@ mod frames {
237 237 label_selector as menu_label_selector,
238 238 };
239 239
240 fn runway_margin(width: f32) -> f32 {
241 ((width - COMFY_RUNWAY_WIDTH) / 2.).max(0.)
242 }
243
240 244 const GUARDED: &[&str] = &[
241 245 "shell",
242 246 "shell/title-bar",
@@ -1614,11 +1618,12 @@ mod frames {
1614 1618 if checks.is_empty() {
1615 1619 found.push(format!("forward@{width}x{height}: no checkbox rendered"));
1616 1620 }
1621 let expected_left = ROW_PADDING + runway_margin(f32::from(main.size.width));
1617 1622 for check in &checks {
1618 1623 let left = inset(main, *check, Edge::Left);
1619 if (left - ROW_PADDING).abs() > TOLERANCE {
1624 if (left - expected_left).abs() > TOLERANCE {
1620 1625 found.push(format!(
1621 "forward@{width}x{height}: checkbox {} starts {left} from the island, not {ROW_PADDING}",
1626 "forward@{width}x{height}: checkbox {} starts {left} from the island, not {expected_left}",
1622 1627 describe(*check)
1623 1628 ));
1624 1629 }
@@ -2021,12 +2026,14 @@ mod frames {
2021 2026 ("right", f32::from(timeline.right() - banner.right())),
2022 2027 ("below divider", f32::from(banner.top() - divider.bottom())),
2023 2028 ];
2024 let side = gaps[1].1;
2025 if (side - BANNER_INSET).abs() > INSET_TOLERANCE
2026 || gaps
2027 .iter()
2028 .any(|(_, gap)| (gap - side).abs() > INSET_TOLERANCE)
2029 {
2029 let runway = runway_margin(f32::from(timeline.size.width) - 2. * BANNER_INSET);
2030 let sides_ok = gaps[1..3]
2031 .iter()
2032 .all(|(_, gap)| (gap - BANNER_INSET - runway).abs() <= INSET_TOLERANCE);
2033 let vertical_ok = [gaps[0].1, gaps[3].1]
2034 .iter()
2035 .all(|gap| (gap - BANNER_INSET).abs() <= INSET_TOLERANCE);
2036 if !sides_ok || !vertical_ok {
2030 2037 found.push(format!(
2031 2038 "pin banner@{width}x{height}: gaps {gaps:?} must all be {BANNER_INSET}"
2032 2039 ));
@@ -156,7 +156,7 @@ mod frames {
156 use std::sync::Arc;
156 use std::sync::Arc;
157 use std::time::Duration;
157 use std::time::Duration;
158
158
159 use app_ui_kit::layout::ROW_PADDING;
159 use app_ui_kit::layout::{COMFY_RUNWAY_WIDTH, ROW_PADDING};
160 use gpui_kit::test::TestWindowExt as _;
160 use gpui_kit::test::TestWindowExt as _;
161 use gpui_kit::{
161 use gpui_kit::{
162 AppContext as _, Bounds, Pixels, ScrollDelta, ScrollWheelEvent, TestAppContext,
162 AppContext as _, Bounds, Pixels, ScrollDelta, ScrollWheelEvent, TestAppContext,
@@ -237,6 +237,10 @@ mod frames {
237 label_selector as menu_label_selector,
237 label_selector as menu_label_selector,
238 };
238 };
239
239
240 fn runway_margin(width: f32) -> f32 {
241 ((width - COMFY_RUNWAY_WIDTH) / 2.).max(0.)
242 }
243
240 const GUARDED: &[&str] = &[
244 const GUARDED: &[&str] = &[
241 "shell",
245 "shell",
242 "shell/title-bar",
246 "shell/title-bar",
@@ -1614,11 +1618,12 @@ mod frames {
1614 if checks.is_empty() {
1618 if checks.is_empty() {
1615 found.push(format!("forward@{width}x{height}: no checkbox rendered"));
1619 found.push(format!("forward@{width}x{height}: no checkbox rendered"));
1616 }
1620 }
1621 let expected_left = ROW_PADDING + runway_margin(f32::from(main.size.width));
1617 for check in &checks {
1622 for check in &checks {
1618 let left = inset(main, *check, Edge::Left);
1623 let left = inset(main, *check, Edge::Left);
1619 if (left - ROW_PADDING).abs() > TOLERANCE {
1624 if (left - expected_left).abs() > TOLERANCE {
1620 found.push(format!(
1625 found.push(format!(
1621 "forward@{width}x{height}: checkbox {} starts {left} from the island, not {ROW_PADDING}",
1626 "forward@{width}x{height}: checkbox {} starts {left} from the island, not {expected_left}",
1622 describe(*check)
1627 describe(*check)
1623 ));
1628 ));
1624 }
1629 }
@@ -2021,12 +2026,14 @@ mod frames {
2021 ("right", f32::from(timeline.right() - banner.right())),
2026 ("right", f32::from(timeline.right() - banner.right())),
2022 ("below divider", f32::from(banner.top() - divider.bottom())),
2027 ("below divider", f32::from(banner.top() - divider.bottom())),
2023 ];
2028 ];
2024 let side = gaps[1].1;
2029 let runway = runway_margin(f32::from(timeline.size.width) - 2. * BANNER_INSET);
2025 if (side - BANNER_INSET).abs() > INSET_TOLERANCE
2030 let sides_ok = gaps[1..3]
2026 || gaps
2031 .iter()
2027 .iter()
2032 .all(|(_, gap)| (gap - BANNER_INSET - runway).abs() <= INSET_TOLERANCE);
2028 .any(|(_, gap)| (gap - side).abs() > INSET_TOLERANCE)
2033 let vertical_ok = [gaps[0].1, gaps[3].1]
2029 {
2034 .iter()
2035 .all(|gap| (gap - BANNER_INSET).abs() <= INSET_TOLERANCE);
2036 if !sides_ok || !vertical_ok {
2030 found.push(format!(
2037 found.push(format!(
2031 "pin banner@{width}x{height}: gaps {gaps:?} must all be {BANNER_INSET}"
2038 "pin banner@{width}x{height}: gaps {gaps:?} must all be {BANNER_INSET}"
2032 ));
2039 ));
crates/app/src/views/conversation.rs +26 −16
@@ -3788,15 +3788,7 @@ impl Render for ConversationView {
3788 3788 }
3789 3789 None => div().into_any_element(),
3790 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
3799 }
3791 runway(row, comfy)
3800 3792 },
3801 3793 )
3802 3794 .with_row_style(StyleRefinement::default().px(px(0.)).pb(px(0.)))
@@ -3923,17 +3915,23 @@ impl Render for ConversationView {
3923 3915 .right_0(),
3924 3916 )
3925 3917 })
3926 .children(pin_banner.map(pin_banner_overlay)),
3918 .children(pin_banner.map(|banner| pin_banner_overlay(runway(banner, comfy)))),
3927 3919 )
3928 .children(self.render_draft_error(cx))
3920 .children(self.render_draft_error(cx).map(|error| runway(error, comfy)))
3929 3921 .when(
3930 3922 !in_feed && !recap_active,
3931 3923 |column| match &forward_selection {
3932 Some(snapshot) => column.child(self.render_forward_footer(snapshot, cx)),
3933 None => column
3934 .child(self.render_typing_line(cx))
3935 .children(self.render_proposal_card(cx))
3936 .child(self.composer.clone()),
3924 Some(snapshot) => {
3925 column.child(runway(self.render_forward_footer(snapshot, cx), comfy))
3926 }
3927 None => column.child(runway(
3928 v_flex()
3929 .w_full()
3930 .child(self.render_typing_line(cx))
3931 .children(self.render_proposal_card(cx))
3932 .child(self.composer.clone()),
3933 comfy,
3934 )),
3937 3935 },
3938 3936 )
3939 3937 .child(self.render_drop_overlay(cx));
@@ -4057,6 +4055,18 @@ fn add_people_button(app: &Entity<AppState>, chat_id: &str) -> AnyElement {
4057 4055 .into_any_element()
4058 4056 }
4059 4057
4058 fn runway(content: impl IntoElement, comfy: bool) -> AnyElement {
4059 if comfy {
4060 h_flex()
4061 .w_full()
4062 .justify_center()
4063 .child(div().w_full().max_w(px(COMFY_RUNWAY_WIDTH)).child(content))
4064 .into_any_element()
4065 } else {
4066 content.into_any_element()
4067 }
4068 }
4069
4060 4070 #[cfg(test)]
4061 4071 mod tests {
4062 4072 use std::sync::Arc;
@@ -3788,15 +3788,7 @@ impl Render for ConversationView {
3788 }
3788 }
3789 None => div().into_any_element(),
3789 None => div().into_any_element(),
3790 };
3790 };
3791 if comfy {
3791 runway(row, 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
3799 }
3800 },
3792 },
3801 )
3793 )
3802 .with_row_style(StyleRefinement::default().px(px(0.)).pb(px(0.)))
3794 .with_row_style(StyleRefinement::default().px(px(0.)).pb(px(0.)))
@@ -3923,17 +3915,23 @@ impl Render for ConversationView {
3923 .right_0(),
3915 .right_0(),
3924 )
3916 )
3925 })
3917 })
3926 .children(pin_banner.map(pin_banner_overlay)),
3918 .children(pin_banner.map(|banner| pin_banner_overlay(runway(banner, comfy)))),
3927 )
3919 )
3928 .children(self.render_draft_error(cx))
3920 .children(self.render_draft_error(cx).map(|error| runway(error, comfy)))
3929 .when(
3921 .when(
3930 !in_feed && !recap_active,
3922 !in_feed && !recap_active,
3931 |column| match &forward_selection {
3923 |column| match &forward_selection {
3932 Some(snapshot) => column.child(self.render_forward_footer(snapshot, cx)),
3924 Some(snapshot) => {
3933 None => column
3925 column.child(runway(self.render_forward_footer(snapshot, cx), comfy))
3934 .child(self.render_typing_line(cx))
3926 }
3935 .children(self.render_proposal_card(cx))
3927 None => column.child(runway(
3936 .child(self.composer.clone()),
3928 v_flex()
3929 .w_full()
3930 .child(self.render_typing_line(cx))
3931 .children(self.render_proposal_card(cx))
3932 .child(self.composer.clone()),
3933 comfy,
3934 )),
3937 },
3935 },
3938 )
3936 )
3939 .child(self.render_drop_overlay(cx));
3937 .child(self.render_drop_overlay(cx));
@@ -4057,6 +4055,18 @@ fn add_people_button(app: &Entity<AppState>, chat_id: &str) -> AnyElement {
4057 .into_any_element()
4055 .into_any_element()
4058}
4056}
4059
4057
4058fn runway(content: impl IntoElement, comfy: bool) -> AnyElement {
4059 if comfy {
4060 h_flex()
4061 .w_full()
4062 .justify_center()
4063 .child(div().w_full().max_w(px(COMFY_RUNWAY_WIDTH)).child(content))
4064 .into_any_element()
4065 } else {
4066 content.into_any_element()
4067 }
4068}
4069
4060#[cfg(test)]
4070#[cfg(test)]
4061mod tests {
4071mod tests {
4062 use std::sync::Arc;
4072 use std::sync::Arc;