BlueGit

ict rusty-teams

test(ui): guard hover styles against display toggles, pin activity repro to the row

- Source scan fails when a hover/group_hover closure calls hidden()/flex()/block()/grid().
- Repro test finds the hovered row by debug selector instead of list index.

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

metis Daniel Däschle · pushed by metis

Authored 2026-10-12 · 7 weeks ago

Hash
cd5dbbe813d35828ec7b06d0f88624ab9b9c645b
Parent
ee80c98c
2 files changed +46 −8
crates/app/src/views/activity_panel.rs +4 −8
@@ -197,6 +197,7 @@ impl ActivityPanel {
197 197 let group = SharedString::from(format!("activity-row-group-{id}"));
198 198 h_flex()
199 199 .id(ElementId::Name(format!("activity-row-{id}").into()))
200 .debug_selector(|| format!("activity-row-{id}"))
200 201 .group(group.clone())
201 202 .mx(px(6.))
202 203 .px(px(10.))
@@ -563,13 +564,7 @@ mod tests {
563 564 panel
564 565 });
565 566 cx.update(|window, cx| window.draw(cx).clear(cx));
566 let (activity, first_row) = cx.update(|_, cx| {
567 let panel = panel.read(cx);
568 (
569 panel.activity.clone(),
570 panel.scroll.bounds_for_item(1).unwrap(),
571 )
572 });
567 let activity = cx.update(|_, cx| panel.read(cx).activity.clone());
573 568 let first_unread = cx.update(|_, cx| {
574 569 let now = Local::now();
575 570 activity
@@ -579,10 +574,11 @@ mod tests {
579 574 .entries[0]
580 575 .id
581 576 });
577 let selector: &'static str = format!("activity-row-{first_unread}").leak();
578 let first_row = cx.debug_bounds(selector).unwrap();
582 579 cx.simulate_mouse_move(first_row.center(), None, Modifiers::none());
583 580 cx.update(|window, cx| window.draw(cx).clear(cx));
584 581 cx.update(|_, cx| activity.update(cx, |activity, cx| activity.mark_read(first_unread, cx)));
585 582 cx.update(|window, cx| window.draw(cx).clear(cx));
586 cx.update(|window, cx| window.draw(cx).clear(cx));
587 583 }
588 584 }
@@ -197,6 +197,7 @@ impl ActivityPanel {
197 let group = SharedString::from(format!("activity-row-group-{id}"));
197 let group = SharedString::from(format!("activity-row-group-{id}"));
198 h_flex()
198 h_flex()
199 .id(ElementId::Name(format!("activity-row-{id}").into()))
199 .id(ElementId::Name(format!("activity-row-{id}").into()))
200 .debug_selector(|| format!("activity-row-{id}"))
200 .group(group.clone())
201 .group(group.clone())
201 .mx(px(6.))
202 .mx(px(6.))
202 .px(px(10.))
203 .px(px(10.))
@@ -563,13 +564,7 @@ mod tests {
563 panel
564 panel
564 });
565 });
565 cx.update(|window, cx| window.draw(cx).clear(cx));
566 cx.update(|window, cx| window.draw(cx).clear(cx));
566 let (activity, first_row) = cx.update(|_, cx| {
567 let activity = cx.update(|_, cx| panel.read(cx).activity.clone());
567 let panel = panel.read(cx);
568 (
569 panel.activity.clone(),
570 panel.scroll.bounds_for_item(1).unwrap(),
571 )
572 });
573 let first_unread = cx.update(|_, cx| {
568 let first_unread = cx.update(|_, cx| {
574 let now = Local::now();
569 let now = Local::now();
575 activity
570 activity
@@ -579,10 +574,11 @@ mod tests {
579 .entries[0]
574 .entries[0]
580 .id
575 .id
581 });
576 });
577 let selector: &'static str = format!("activity-row-{first_unread}").leak();
578 let first_row = cx.debug_bounds(selector).unwrap();
582 cx.simulate_mouse_move(first_row.center(), None, Modifiers::none());
579 cx.simulate_mouse_move(first_row.center(), None, Modifiers::none());
583 cx.update(|window, cx| window.draw(cx).clear(cx));
580 cx.update(|window, cx| window.draw(cx).clear(cx));
584 cx.update(|_, cx| activity.update(cx, |activity, cx| activity.mark_read(first_unread, cx)));
581 cx.update(|_, cx| activity.update(cx, |activity, cx| activity.mark_read(first_unread, cx)));
585 cx.update(|window, cx| window.draw(cx).clear(cx));
582 cx.update(|window, cx| window.draw(cx).clear(cx));
586 cx.update(|window, cx| window.draw(cx).clear(cx));
587 }
583 }
588}
584}
crates/app/src/views/mod.rs +42 −0
@@ -59,3 +59,45 @@ pub mod title_bar;
59 59 pub mod transfer_picker;
60 60 pub mod translation_line;
61 61 pub mod widgets;
62
63 #[cfg(test)]
64 mod tests {
65 use std::path::Path;
66
67 fn rust_files(directory: &Path, files: &mut Vec<std::path::PathBuf>) {
68 for entry in std::fs::read_dir(directory).unwrap() {
69 let path = entry.unwrap().path();
70 if path.is_dir() {
71 rust_files(&path, files);
72 } else if path.extension().is_some_and(|extension| extension == "rs") {
73 files.push(path);
74 }
75 }
76 }
77
78 #[test]
79 fn hover_styles_never_toggle_display() {
80 let toggle = regex::Regex::new(
81 r"hover\([^|]*\|\w+\|\s*\w+\s*\.\s*(hidden|flex|block|grid)\(\)",
82 )
83 .unwrap();
84 let mut files = Vec::new();
85 rust_files(&Path::new(env!("CARGO_MANIFEST_DIR")).join("src"), &mut files);
86 let offenders: Vec<String> = files
87 .iter()
88 .flat_map(|path| {
89 let source = std::fs::read_to_string(path).unwrap();
90 source
91 .lines()
92 .enumerate()
93 .filter(|(_, line)| toggle.is_match(line))
94 .map(|(index, _)| format!("{}:{}", path.display(), index + 1))
95 .collect::<Vec<_>>()
96 })
97 .collect();
98 assert!(
99 offenders.is_empty(),
100 "hover styles must toggle visible()/invisible(), not display (gpui panics \"must call prepaint before paint\"): {offenders:?}"
101 );
102 }
103 }
@@ -59,3 +59,45 @@ pub mod title_bar;
59pub mod transfer_picker;
59pub mod transfer_picker;
60pub mod translation_line;
60pub mod translation_line;
61pub mod widgets;
61pub mod widgets;
62
63#[cfg(test)]
64mod tests {
65 use std::path::Path;
66
67 fn rust_files(directory: &Path, files: &mut Vec<std::path::PathBuf>) {
68 for entry in std::fs::read_dir(directory).unwrap() {
69 let path = entry.unwrap().path();
70 if path.is_dir() {
71 rust_files(&path, files);
72 } else if path.extension().is_some_and(|extension| extension == "rs") {
73 files.push(path);
74 }
75 }
76 }
77
78 #[test]
79 fn hover_styles_never_toggle_display() {
80 let toggle = regex::Regex::new(
81 r"hover\([^|]*\|\w+\|\s*\w+\s*\.\s*(hidden|flex|block|grid)\(\)",
82 )
83 .unwrap();
84 let mut files = Vec::new();
85 rust_files(&Path::new(env!("CARGO_MANIFEST_DIR")).join("src"), &mut files);
86 let offenders: Vec<String> = files
87 .iter()
88 .flat_map(|path| {
89 let source = std::fs::read_to_string(path).unwrap();
90 source
91 .lines()
92 .enumerate()
93 .filter(|(_, line)| toggle.is_match(line))
94 .map(|(index, _)| format!("{}:{}", path.display(), index + 1))
95 .collect::<Vec<_>>()
96 })
97 .collect();
98 assert!(
99 offenders.is_empty(),
100 "hover styles must toggle visible()/invisible(), not display (gpui panics \"must call prepaint before paint\"): {offenders:?}"
101 );
102 }
103}