BlueGit

ict rusty-teams

fix(chat-members): keep fixed row heights in scroll lists

- member rows no longer shrink in the 300 px list, own row 43 px like Teams
- reaction popover rows had the same shrink, flex_none there too
- flex_none on all other fixed-height rows
- layout_guard rule fixed_height_rows_never_shrink

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

metis Daniel Däschle · pushed by metis

Authored 2026-10-17 · 6 weeks ago

Hash
f68a2a18067b0d78aa7c0542f9bf14a7ef7b915a
Parent
1c2a98df
9 files changed +91 −1
crates/app/src/layout_guard.rs +70 −0
@@ -928,3 +928,73 @@ fn lines_are_solid() {
928 928 .collect();
929 929 assert!(violations.is_empty(), "{}", violations.join("\n"));
930 930 }
931
932 fn indentation(line: &str) -> usize {
933 line.len() - line.trim_start().len()
934 }
935
936 fn chain_lines<'a>(lines: &[&'a str], index: usize) -> Vec<&'a str> {
937 let indent = indentation(lines[index]);
938 let belongs = |line: &&str| line.trim().is_empty() || indentation(line) >= indent;
939 let start = lines[..index]
940 .iter()
941 .rposition(|line| !belongs(line))
942 .map_or(0, |position| position + 1);
943 let end = lines[index..]
944 .iter()
945 .position(|line| !belongs(line))
946 .map_or(lines.len(), |position| index + position);
947 lines[start..end]
948 .iter()
949 .filter(|line| indentation(line) == indent)
950 .copied()
951 .collect()
952 }
953
954 fn shrinking_rows(row_height: &Regex, source: &str) -> Vec<usize> {
955 let lines: Vec<&str> = source.lines().collect();
956 (0..lines.len())
957 .filter(|&index| row_height.is_match(lines[index]))
958 .filter(|&index| {
959 !chain_lines(&lines, index).iter().any(|line| {
960 let line = line.trim();
961 line.starts_with(".flex_none()") || line.starts_with(".flex_shrink_0()")
962 })
963 })
964 .map(|index| index + 1)
965 .collect()
966 }
967
968 fn row_height_pattern() -> Regex {
969 Regex::new(r"^\s*\.h\(px\(((\w+_)?(ROW|ENTRY)_HEIGHT|row_height)\)\)").expect("pattern")
970 }
971
972 #[test]
973 fn matcher_finds_rows_without_flex_none() {
974 let source = "fn rows() {\n h_flex()\n .h(px(ROW_HEIGHT))\n .child(\n div()\n .flex_none(),\n );\n div()\n .id(1)\n .h(px(OWN_ROW_HEIGHT))\n .flex_none();\n}\n";
975 assert_eq!(shrinking_rows(&row_height_pattern(), source), [3]);
976 }
977
978 #[test]
979 fn fixed_height_rows_never_shrink() {
980 let row_height = row_height_pattern();
981 let mut files = Vec::new();
982 for root in source_roots() {
983 source_files(&root, &mut files);
984 }
985 let violations: Vec<String> = files
986 .iter()
987 .filter(|file| !file.ends_with("layout_guard.rs"))
988 .flat_map(|file| {
989 let source = fs::read_to_string(file).expect("read source file");
990 shrinking_rows(&row_height, &source)
991 .into_iter()
992 .map(|line| format!("{}:{line}", file.display()))
993 .collect::<Vec<_>>()
994 })
995 .collect();
996 assert!(
997 violations.is_empty(),
998 "a fixed-height row needs .flex_none(), or a max_h scroll list shrinks it to its content: {violations:?}"
999 );
1000 }
@@ -928,3 +928,73 @@ fn lines_are_solid() {
928 .collect();
928 .collect();
929 assert!(violations.is_empty(), "{}", violations.join("\n"));
929 assert!(violations.is_empty(), "{}", violations.join("\n"));
930}
930}
931
932fn indentation(line: &str) -> usize {
933 line.len() - line.trim_start().len()
934}
935
936fn chain_lines<'a>(lines: &[&'a str], index: usize) -> Vec<&'a str> {
937 let indent = indentation(lines[index]);
938 let belongs = |line: &&str| line.trim().is_empty() || indentation(line) >= indent;
939 let start = lines[..index]
940 .iter()
941 .rposition(|line| !belongs(line))
942 .map_or(0, |position| position + 1);
943 let end = lines[index..]
944 .iter()
945 .position(|line| !belongs(line))
946 .map_or(lines.len(), |position| index + position);
947 lines[start..end]
948 .iter()
949 .filter(|line| indentation(line) == indent)
950 .copied()
951 .collect()
952}
953
954fn shrinking_rows(row_height: &Regex, source: &str) -> Vec<usize> {
955 let lines: Vec<&str> = source.lines().collect();
956 (0..lines.len())
957 .filter(|&index| row_height.is_match(lines[index]))
958 .filter(|&index| {
959 !chain_lines(&lines, index).iter().any(|line| {
960 let line = line.trim();
961 line.starts_with(".flex_none()") || line.starts_with(".flex_shrink_0()")
962 })
963 })
964 .map(|index| index + 1)
965 .collect()
966}
967
968fn row_height_pattern() -> Regex {
969 Regex::new(r"^\s*\.h\(px\(((\w+_)?(ROW|ENTRY)_HEIGHT|row_height)\)\)").expect("pattern")
970}
971
972#[test]
973fn matcher_finds_rows_without_flex_none() {
974 let source = "fn rows() {\n h_flex()\n .h(px(ROW_HEIGHT))\n .child(\n div()\n .flex_none(),\n );\n div()\n .id(1)\n .h(px(OWN_ROW_HEIGHT))\n .flex_none();\n}\n";
975 assert_eq!(shrinking_rows(&row_height_pattern(), source), [3]);
976}
977
978#[test]
979fn fixed_height_rows_never_shrink() {
980 let row_height = row_height_pattern();
981 let mut files = Vec::new();
982 for root in source_roots() {
983 source_files(&root, &mut files);
984 }
985 let violations: Vec<String> = files
986 .iter()
987 .filter(|file| !file.ends_with("layout_guard.rs"))
988 .flat_map(|file| {
989 let source = fs::read_to_string(file).expect("read source file");
990 shrinking_rows(&row_height, &source)
991 .into_iter()
992 .map(|line| format!("{}:{line}", file.display()))
993 .collect::<Vec<_>>()
994 })
995 .collect();
996 assert!(
997 violations.is_empty(),
998 "a fixed-height row needs .flex_none(), or a max_h scroll list shrinks it to its content: {violations:?}"
999 );
1000}
crates/app/src/views/calls_tab.rs +2 −0
@@ -62,6 +62,7 @@ fn call_row(
62 62 .id(SharedString::from(format!("call-{}", row.key)))
63 63 .mx(px(6.))
64 64 .h(px(CALL_ROW_HEIGHT))
65 .flex_none()
65 66 .px(px(10.))
66 67 .gap(px(12.))
67 68 .items_center()
@@ -336,6 +337,7 @@ fn agenda_row(
336 337 .id(SharedString::from(format!("agenda-{}", row.key)))
337 338 .mx(px(6.))
338 339 .h(px(AGENDA_ROW_HEIGHT))
340 .flex_none()
339 341 .px(px(10.))
340 342 .gap(px(12.))
341 343 .items_center()
@@ -62,6 +62,7 @@ fn call_row(
62 .id(SharedString::from(format!("call-{}", row.key)))
62 .id(SharedString::from(format!("call-{}", row.key)))
63 .mx(px(6.))
63 .mx(px(6.))
64 .h(px(CALL_ROW_HEIGHT))
64 .h(px(CALL_ROW_HEIGHT))
65 .flex_none()
65 .px(px(10.))
66 .px(px(10.))
66 .gap(px(12.))
67 .gap(px(12.))
67 .items_center()
68 .items_center()
@@ -336,6 +337,7 @@ fn agenda_row(
336 .id(SharedString::from(format!("agenda-{}", row.key)))
337 .id(SharedString::from(format!("agenda-{}", row.key)))
337 .mx(px(6.))
338 .mx(px(6.))
338 .h(px(AGENDA_ROW_HEIGHT))
339 .h(px(AGENDA_ROW_HEIGHT))
340 .flex_none()
339 .px(px(10.))
341 .px(px(10.))
340 .gap(px(12.))
342 .gap(px(12.))
341 .items_center()
343 .items_center()
crates/app/src/views/chat_members.rs +9 −1
@@ -22,6 +22,7 @@ const LIST_MAX_HEIGHT: f32 = 300.;
22 22 const POPUP_OFFSET: f32 = 16.;
23 23 const SECTION_HEIGHT: f32 = 24.;
24 24 const ROW_HEIGHT: f32 = 40.;
25 const OWN_ROW_HEIGHT: f32 = 43.;
25 26 const AVATAR_SIZE: f32 = 32.;
26 27 const EDGE_PADDING: f32 = 12.;
27 28 const ACTION_HEIGHT: f32 = 36.;
@@ -75,6 +76,7 @@ fn members_panel(
75 76 .child(
76 77 div()
77 78 .h(px(SECTION_HEIGHT))
79 .flex_none()
78 80 .px(px(EDGE_PADDING))
79 81 .flex()
80 82 .items_center()
@@ -148,10 +150,16 @@ fn member_row(
148 150 None => avatar,
149 151 };
150 152 let opens_chat = user_id.filter(|_| !row.is_self).map(str::to_owned);
153 let row_height = if row.is_self {
154 OWN_ROW_HEIGHT
155 } else {
156 ROW_HEIGHT
157 };
151 158 h_flex()
152 159 .id(("chat-member", index))
153 160 .group(group.clone())
154 .h(px(ROW_HEIGHT))
161 .h(px(row_height))
162 .flex_none()
155 163 .px(px(EDGE_PADDING))
156 164 .gap(px(8.))
157 165 .items_center()
@@ -22,6 +22,7 @@ const LIST_MAX_HEIGHT: f32 = 300.;
22const POPUP_OFFSET: f32 = 16.;
22const POPUP_OFFSET: f32 = 16.;
23const SECTION_HEIGHT: f32 = 24.;
23const SECTION_HEIGHT: f32 = 24.;
24const ROW_HEIGHT: f32 = 40.;
24const ROW_HEIGHT: f32 = 40.;
25const OWN_ROW_HEIGHT: f32 = 43.;
25const AVATAR_SIZE: f32 = 32.;
26const AVATAR_SIZE: f32 = 32.;
26const EDGE_PADDING: f32 = 12.;
27const EDGE_PADDING: f32 = 12.;
27const ACTION_HEIGHT: f32 = 36.;
28const ACTION_HEIGHT: f32 = 36.;
@@ -75,6 +76,7 @@ fn members_panel(
75 .child(
76 .child(
76 div()
77 div()
77 .h(px(SECTION_HEIGHT))
78 .h(px(SECTION_HEIGHT))
79 .flex_none()
78 .px(px(EDGE_PADDING))
80 .px(px(EDGE_PADDING))
79 .flex()
81 .flex()
80 .items_center()
82 .items_center()
@@ -148,10 +150,16 @@ fn member_row(
148 None => avatar,
150 None => avatar,
149 };
151 };
150 let opens_chat = user_id.filter(|_| !row.is_self).map(str::to_owned);
152 let opens_chat = user_id.filter(|_| !row.is_self).map(str::to_owned);
153 let row_height = if row.is_self {
154 OWN_ROW_HEIGHT
155 } else {
156 ROW_HEIGHT
157 };
151 h_flex()
158 h_flex()
152 .id(("chat-member", index))
159 .id(("chat-member", index))
153 .group(group.clone())
160 .group(group.clone())
154 .h(px(ROW_HEIGHT))
161 .h(px(row_height))
162 .flex_none()
155 .px(px(EDGE_PADDING))
163 .px(px(EDGE_PADDING))
156 .gap(px(8.))
164 .gap(px(8.))
157 .items_center()
165 .items_center()
crates/app/src/views/composer.rs +1 −0
@@ -2107,6 +2107,7 @@ impl Composer {
2107 2107 .mx(px(6.))
2108 2108 .px(px(6.))
2109 2109 .h(px(POPUP_ROW_HEIGHT))
2110 .flex_none()
2110 2111 .gap(px(8.))
2111 2112 .items_center()
2112 2113 .rounded(px(6.))
@@ -2107,6 +2107,7 @@ impl Composer {
2107 .mx(px(6.))
2107 .mx(px(6.))
2108 .px(px(6.))
2108 .px(px(6.))
2109 .h(px(POPUP_ROW_HEIGHT))
2109 .h(px(POPUP_ROW_HEIGHT))
2110 .flex_none()
2110 .gap(px(8.))
2111 .gap(px(8.))
2111 .items_center()
2112 .items_center()
2112 .rounded(px(6.))
2113 .rounded(px(6.))
crates/app/src/views/composer/schedule.rs +1 −0
@@ -57,6 +57,7 @@ fn menu_row(id: ElementId, highlighted: bool) -> Stateful<Div> {
57 57 h_flex()
58 58 .id(id)
59 59 .h(px(ROW_HEIGHT))
60 .flex_none()
60 61 .px(px(10.))
61 62 .gap(px(10.))
62 63 .items_center()
@@ -57,6 +57,7 @@ fn menu_row(id: ElementId, highlighted: bool) -> Stateful<Div> {
57 h_flex()
57 h_flex()
58 .id(id)
58 .id(id)
59 .h(px(ROW_HEIGHT))
59 .h(px(ROW_HEIGHT))
60 .flex_none()
60 .px(px(10.))
61 .px(px(10.))
61 .gap(px(10.))
62 .gap(px(10.))
62 .items_center()
63 .items_center()
crates/app/src/views/new_chat.rs +1 −0
@@ -474,6 +474,7 @@ impl NewChatDraft {
474 474 .id(ElementId::Name(format!("new-chat-result-{index}").into()))
475 475 .px(px(6.))
476 476 .h(px(POPUP_ROW_HEIGHT))
477 .flex_none()
477 478 .gap(px(8.))
478 479 .items_center()
479 480 .rounded(px(6.))
@@ -474,6 +474,7 @@ impl NewChatDraft {
474 .id(ElementId::Name(format!("new-chat-result-{index}").into()))
474 .id(ElementId::Name(format!("new-chat-result-{index}").into()))
475 .px(px(6.))
475 .px(px(6.))
476 .h(px(POPUP_ROW_HEIGHT))
476 .h(px(POPUP_ROW_HEIGHT))
477 .flex_none()
477 .gap(px(8.))
478 .gap(px(8.))
478 .items_center()
479 .items_center()
479 .rounded(px(6.))
480 .rounded(px(6.))
crates/app/src/views/reaction_pills.rs +1 −0
@@ -197,6 +197,7 @@ fn tab_button(tab: &ReactionTab, active: bool, select_tab: SelectTab) -> Statefu
197 197 fn entry_row(entry: &ReactionEntry, directory: &Directory) -> Div {
198 198 h_flex()
199 199 .h(px(ENTRY_HEIGHT))
200 .flex_none()
200 201 .px(px(8.))
201 202 .gap(px(8.))
202 203 .items_center()
@@ -197,6 +197,7 @@ fn tab_button(tab: &ReactionTab, active: bool, select_tab: SelectTab) -> Statefu
197fn entry_row(entry: &ReactionEntry, directory: &Directory) -> Div {
197fn entry_row(entry: &ReactionEntry, directory: &Directory) -> Div {
198 h_flex()
198 h_flex()
199 .h(px(ENTRY_HEIGHT))
199 .h(px(ENTRY_HEIGHT))
200 .flex_none()
200 .px(px(8.))
201 .px(px(8.))
201 .gap(px(8.))
202 .gap(px(8.))
202 .items_center()
203 .items_center()
crates/app/src/views/shared_tab.rs +1 −0
@@ -348,6 +348,7 @@ fn skeleton_rows() -> impl IntoElement {
348 348 ))
349 349 .w_full()
350 350 .h(px(ROW_HEIGHT))
351 .flex_none()
351 352 .px(px(SIDE_PADDING))
352 353 .gap(px(12.))
353 354 .items_center()
@@ -348,6 +348,7 @@ fn skeleton_rows() -> impl IntoElement {
348 ))
348 ))
349 .w_full()
349 .w_full()
350 .h(px(ROW_HEIGHT))
350 .h(px(ROW_HEIGHT))
351 .flex_none()
351 .px(px(SIDE_PADDING))
352 .px(px(SIDE_PADDING))
352 .gap(px(12.))
353 .gap(px(12.))
353 .items_center()
354 .items_center()
crates/app/src/views/sidebar.rs +5 −0
@@ -746,6 +746,7 @@ impl SidebarView {
746 746 .id("new-chat-draft")
747 747 .mx(px(6.))
748 748 .h(px(ROW_HEIGHT))
749 .flex_none()
749 750 .px(px(10.))
750 751 .gap(px(12.))
751 752 .items_center()
@@ -1010,6 +1011,7 @@ impl SidebarView {
1010 1011 .id(SharedString::from(format!("chat-{}", item.id)))
1011 1012 .mx(px(6.))
1012 1013 .h(px(ROW_HEIGHT))
1014 .flex_none()
1013 1015 .px(px(10.))
1014 1016 .gap(px(12.))
1015 1017 .items_center()
@@ -1327,6 +1329,7 @@ impl SidebarView {
1327 1329 .id(SharedString::from(format!("team-{team_id}")))
1328 1330 .mx(px(6.))
1329 1331 .h(px(TEAM_ROW_HEIGHT))
1332 .flex_none()
1330 1333 .px(px(10.))
1331 1334 .gap(px(8.))
1332 1335 .items_center()
@@ -1426,6 +1429,7 @@ impl SidebarView {
1426 1429 .id(id)
1427 1430 .mx(px(6.))
1428 1431 .h(px(REVEAL_ROW_HEIGHT))
1432 .flex_none()
1429 1433 .pl(px(indent))
1430 1434 .pr(px(10.))
1431 1435 .gap(px(8.))
@@ -1466,6 +1470,7 @@ impl SidebarView {
1466 1470 .id(SharedString::from(format!("channel-{}", channel.id)))
1467 1471 .mx(px(6.))
1468 1472 .h(px(TEAM_ROW_HEIGHT))
1473 .flex_none()
1469 1474 .pl(px(40.))
1470 1475 .pr(px(10.))
1471 1476 .gap(px(8.))
@@ -746,6 +746,7 @@ impl SidebarView {
746 .id("new-chat-draft")
746 .id("new-chat-draft")
747 .mx(px(6.))
747 .mx(px(6.))
748 .h(px(ROW_HEIGHT))
748 .h(px(ROW_HEIGHT))
749 .flex_none()
749 .px(px(10.))
750 .px(px(10.))
750 .gap(px(12.))
751 .gap(px(12.))
751 .items_center()
752 .items_center()
@@ -1010,6 +1011,7 @@ impl SidebarView {
1010 .id(SharedString::from(format!("chat-{}", item.id)))
1011 .id(SharedString::from(format!("chat-{}", item.id)))
1011 .mx(px(6.))
1012 .mx(px(6.))
1012 .h(px(ROW_HEIGHT))
1013 .h(px(ROW_HEIGHT))
1014 .flex_none()
1013 .px(px(10.))
1015 .px(px(10.))
1014 .gap(px(12.))
1016 .gap(px(12.))
1015 .items_center()
1017 .items_center()
@@ -1327,6 +1329,7 @@ impl SidebarView {
1327 .id(SharedString::from(format!("team-{team_id}")))
1329 .id(SharedString::from(format!("team-{team_id}")))
1328 .mx(px(6.))
1330 .mx(px(6.))
1329 .h(px(TEAM_ROW_HEIGHT))
1331 .h(px(TEAM_ROW_HEIGHT))
1332 .flex_none()
1330 .px(px(10.))
1333 .px(px(10.))
1331 .gap(px(8.))
1334 .gap(px(8.))
1332 .items_center()
1335 .items_center()
@@ -1426,6 +1429,7 @@ impl SidebarView {
1426 .id(id)
1429 .id(id)
1427 .mx(px(6.))
1430 .mx(px(6.))
1428 .h(px(REVEAL_ROW_HEIGHT))
1431 .h(px(REVEAL_ROW_HEIGHT))
1432 .flex_none()
1429 .pl(px(indent))
1433 .pl(px(indent))
1430 .pr(px(10.))
1434 .pr(px(10.))
1431 .gap(px(8.))
1435 .gap(px(8.))
@@ -1466,6 +1470,7 @@ impl SidebarView {
1466 .id(SharedString::from(format!("channel-{}", channel.id)))
1470 .id(SharedString::from(format!("channel-{}", channel.id)))
1467 .mx(px(6.))
1471 .mx(px(6.))
1468 .h(px(TEAM_ROW_HEIGHT))
1472 .h(px(TEAM_ROW_HEIGHT))
1473 .flex_none()
1469 .pl(px(40.))
1474 .pl(px(40.))
1470 .pr(px(10.))
1475 .pr(px(10.))
1471 .gap(px(8.))
1476 .gap(px(8.))