BlueGit

ict rusty-teams

feat(parity): Find in Settings

- Search field above the settings navigation, filters sections by name and by setting
- Typing jumps to the first matching section
- Test keeps every search term on its page

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

metis Daniel Däschle · pushed by metis

Authored 2026-11-08 · 3 weeks ago

Hash
5411189c684b30fb909b2915cb287952071aa4c6
Parent
78ae3e37
2 files changed +195 −12
crates/app/src/settings/dialog.rs +48 −2
@@ -1,12 +1,13 @@
1 1 use app_ui_kit::settings_controls::PAGE_PADDING;
2 2 use gpui_kit::component::scroll::ScrollableElement as _;
3 3 use gpui_kit::assets::IconName;
4 use gpui_kit::component::input::{Input, InputEvent, InputState};
4 5 use gpui_kit::component::{h_flex, v_flex};
5 6 use gpui_kit::*;
6 7
7 8 use super::devices::DevicesView;
8 9 use super::mcp::McpView;
9 use super::nav::{NavLayout, label, render_nav};
10 use super::nav::{NavLayout, NavSearch, first_match, label, matches, render_nav};
10 11 use super::rows::ROW_INSET;
11 12 use super::{about, appearance, calls, chats, general, notifications};
12 13 use crate::agents::AgentsSettings;
@@ -26,6 +27,8 @@ const COMPACT_BELOW_WIDTH: f32 = 1100.;
26 27 const COMPACT_BELOW_HEIGHT: f32 = 720.;
27 28 const NAV_WIDTH: f32 = 280.;
28 29 const PADDING: f32 = 24.;
30 const SEARCH_HEIGHT: f32 = 32.;
31 const SEARCH_PLACEHOLDER: &str = "Find in Settings";
29 32
30 33 pub enum SettingsDialogEvent {
31 34 Close,
@@ -64,7 +67,8 @@ pub struct SettingsDialog {
64 67 agents: Option<Entity<AgentsSettings>>,
65 68 body_scroll: ScrollHandle,
66 69 focus_handle: FocusHandle,
67 _subscriptions: [Subscription; 2],
70 search: Entity<InputState>,
71 _subscriptions: [Subscription; 3],
68 72 }
69 73
70 74 impl EventEmitter<SettingsDialogEvent> for SettingsDialog {}
@@ -77,9 +81,15 @@ impl SettingsDialog {
77 81 window: &mut Window,
78 82 cx: &mut Context<Self>,
79 83 ) -> Self {
84 let search = cx.new(|cx| InputState::new(window, cx).placeholder(SEARCH_PLACEHOLDER));
80 85 let subscriptions = [
81 86 cx.observe(&center, |_, _, cx| cx.notify()),
82 87 cx.observe(&app, |_, _, cx| cx.notify()),
88 cx.subscribe_in(&search, window, |this, _, event: &InputEvent, window, cx| {
89 if matches!(event, InputEvent::Change) {
90 this.follow_search(window, cx);
91 }
92 }),
83 93 ];
84 94 let focus_handle = cx.focus_handle();
85 95 window.focus(&focus_handle, cx);
@@ -92,6 +102,7 @@ impl SettingsDialog {
92 102 agents: None,
93 103 body_scroll: ScrollHandle::new(),
94 104 focus_handle,
105 search,
95 106 _subscriptions: subscriptions,
96 107 };
97 108 dialog.show(section, window, cx);
@@ -123,6 +134,36 @@ impl SettingsDialog {
123 134 cx.notify();
124 135 }
125 136
137 fn follow_search(&mut self, window: &mut Window, cx: &mut Context<Self>) {
138 let query = self.search.read(cx).value().to_string();
139 if !matches(self.section, &query) {
140 let agents_available = crate::agents::runs_handle(cx).is_some();
141 if let Some(section) = first_match(&query, agents_available) {
142 self.show(section, window, cx);
143 }
144 }
145 cx.notify();
146 }
147
148 fn search_input(&self) -> AnyElement {
149 h_flex()
150 .h(px(SEARCH_HEIGHT))
151 .w_full()
152 .px(px(10.))
153 .gap(px(8.))
154 .items_center()
155 .rounded(px(6.))
156 .bg(theme::popup())
157 .child(icon(IconName::Search, 14., theme::text_muted()))
158 .child(
159 div()
160 .flex_1()
161 .min_w_0()
162 .child(Input::new(&self.search).appearance(false).bordered(false)),
163 )
164 .into_any_element()
165 }
166
126 167 fn on_key_down(&mut self, event: &KeyDownEvent, _: &mut Window, cx: &mut Context<Self>) {
127 168 if event.keystroke.key == "escape" {
128 169 cx.emit(SettingsDialogEvent::Close);
@@ -201,6 +242,7 @@ impl Render for SettingsDialog {
201 242 let viewport = window.viewport_size();
202 243 let metrics = metrics(f32::from(viewport.width), f32::from(viewport.height));
203 244 let dialog = cx.entity();
245 let query = self.search.read(cx).value().to_string();
204 246 let nav = render_nav(
205 247 self.section,
206 248 crate::agents::runs_handle(cx).is_some(),
@@ -208,6 +250,10 @@ impl Render for SettingsDialog {
208 250 width: metrics.nav_width,
209 251 padding_y: metrics.padding,
210 252 },
253 NavSearch {
254 input: self.search_input(),
255 query: &query,
256 },
211 257 move |section, window, cx| {
212 258 dialog.update(cx, |dialog, cx| dialog.show(section, window, cx))
213 259 },
@@ -1,12 +1,13 @@
1use app_ui_kit::settings_controls::PAGE_PADDING;
1use app_ui_kit::settings_controls::PAGE_PADDING;
2use gpui_kit::component::scroll::ScrollableElement as _;
2use gpui_kit::component::scroll::ScrollableElement as _;
3use gpui_kit::assets::IconName;
3use gpui_kit::assets::IconName;
4use gpui_kit::component::input::{Input, InputEvent, InputState};
4use gpui_kit::component::{h_flex, v_flex};
5use gpui_kit::component::{h_flex, v_flex};
5use gpui_kit::*;
6use gpui_kit::*;
6
7
7use super::devices::DevicesView;
8use super::devices::DevicesView;
8use super::mcp::McpView;
9use super::mcp::McpView;
9use super::nav::{NavLayout, label, render_nav};
10use super::nav::{NavLayout, NavSearch, first_match, label, matches, render_nav};
10use super::rows::ROW_INSET;
11use super::rows::ROW_INSET;
11use super::{about, appearance, calls, chats, general, notifications};
12use super::{about, appearance, calls, chats, general, notifications};
12use crate::agents::AgentsSettings;
13use crate::agents::AgentsSettings;
@@ -26,6 +27,8 @@ const COMPACT_BELOW_WIDTH: f32 = 1100.;
26const COMPACT_BELOW_HEIGHT: f32 = 720.;
27const COMPACT_BELOW_HEIGHT: f32 = 720.;
27const NAV_WIDTH: f32 = 280.;
28const NAV_WIDTH: f32 = 280.;
28const PADDING: f32 = 24.;
29const PADDING: f32 = 24.;
30const SEARCH_HEIGHT: f32 = 32.;
31const SEARCH_PLACEHOLDER: &str = "Find in Settings";
29
32
30pub enum SettingsDialogEvent {
33pub enum SettingsDialogEvent {
31 Close,
34 Close,
@@ -64,7 +67,8 @@ pub struct SettingsDialog {
64 agents: Option<Entity<AgentsSettings>>,
67 agents: Option<Entity<AgentsSettings>>,
65 body_scroll: ScrollHandle,
68 body_scroll: ScrollHandle,
66 focus_handle: FocusHandle,
69 focus_handle: FocusHandle,
67 _subscriptions: [Subscription; 2],
70 search: Entity<InputState>,
71 _subscriptions: [Subscription; 3],
68}
72}
69
73
70impl EventEmitter<SettingsDialogEvent> for SettingsDialog {}
74impl EventEmitter<SettingsDialogEvent> for SettingsDialog {}
@@ -77,9 +81,15 @@ impl SettingsDialog {
77 window: &mut Window,
81 window: &mut Window,
78 cx: &mut Context<Self>,
82 cx: &mut Context<Self>,
79 ) -> Self {
83 ) -> Self {
84 let search = cx.new(|cx| InputState::new(window, cx).placeholder(SEARCH_PLACEHOLDER));
80 let subscriptions = [
85 let subscriptions = [
81 cx.observe(&center, |_, _, cx| cx.notify()),
86 cx.observe(&center, |_, _, cx| cx.notify()),
82 cx.observe(&app, |_, _, cx| cx.notify()),
87 cx.observe(&app, |_, _, cx| cx.notify()),
88 cx.subscribe_in(&search, window, |this, _, event: &InputEvent, window, cx| {
89 if matches!(event, InputEvent::Change) {
90 this.follow_search(window, cx);
91 }
92 }),
83 ];
93 ];
84 let focus_handle = cx.focus_handle();
94 let focus_handle = cx.focus_handle();
85 window.focus(&focus_handle, cx);
95 window.focus(&focus_handle, cx);
@@ -92,6 +102,7 @@ impl SettingsDialog {
92 agents: None,
102 agents: None,
93 body_scroll: ScrollHandle::new(),
103 body_scroll: ScrollHandle::new(),
94 focus_handle,
104 focus_handle,
105 search,
95 _subscriptions: subscriptions,
106 _subscriptions: subscriptions,
96 };
107 };
97 dialog.show(section, window, cx);
108 dialog.show(section, window, cx);
@@ -123,6 +134,36 @@ impl SettingsDialog {
123 cx.notify();
134 cx.notify();
124 }
135 }
125
136
137 fn follow_search(&mut self, window: &mut Window, cx: &mut Context<Self>) {
138 let query = self.search.read(cx).value().to_string();
139 if !matches(self.section, &query) {
140 let agents_available = crate::agents::runs_handle(cx).is_some();
141 if let Some(section) = first_match(&query, agents_available) {
142 self.show(section, window, cx);
143 }
144 }
145 cx.notify();
146 }
147
148 fn search_input(&self) -> AnyElement {
149 h_flex()
150 .h(px(SEARCH_HEIGHT))
151 .w_full()
152 .px(px(10.))
153 .gap(px(8.))
154 .items_center()
155 .rounded(px(6.))
156 .bg(theme::popup())
157 .child(icon(IconName::Search, 14., theme::text_muted()))
158 .child(
159 div()
160 .flex_1()
161 .min_w_0()
162 .child(Input::new(&self.search).appearance(false).bordered(false)),
163 )
164 .into_any_element()
165 }
166
126 fn on_key_down(&mut self, event: &KeyDownEvent, _: &mut Window, cx: &mut Context<Self>) {
167 fn on_key_down(&mut self, event: &KeyDownEvent, _: &mut Window, cx: &mut Context<Self>) {
127 if event.keystroke.key == "escape" {
168 if event.keystroke.key == "escape" {
128 cx.emit(SettingsDialogEvent::Close);
169 cx.emit(SettingsDialogEvent::Close);
@@ -201,6 +242,7 @@ impl Render for SettingsDialog {
201 let viewport = window.viewport_size();
242 let viewport = window.viewport_size();
202 let metrics = metrics(f32::from(viewport.width), f32::from(viewport.height));
243 let metrics = metrics(f32::from(viewport.width), f32::from(viewport.height));
203 let dialog = cx.entity();
244 let dialog = cx.entity();
245 let query = self.search.read(cx).value().to_string();
204 let nav = render_nav(
246 let nav = render_nav(
205 self.section,
247 self.section,
206 crate::agents::runs_handle(cx).is_some(),
248 crate::agents::runs_handle(cx).is_some(),
@@ -208,6 +250,10 @@ impl Render for SettingsDialog {
208 width: metrics.nav_width,
250 width: metrics.nav_width,
209 padding_y: metrics.padding,
251 padding_y: metrics.padding,
210 },
252 },
253 NavSearch {
254 input: self.search_input(),
255 query: &query,
256 },
211 move |section, window, cx| {
257 move |section, window, cx| {
212 dialog.update(cx, |dialog, cx| dialog.show(section, window, cx))
258 dialog.update(cx, |dialog, cx| dialog.show(section, window, cx))
213 },
259 },
crates/app/src/settings/nav.rs +147 −10
@@ -24,6 +24,77 @@ const ITEM_GAP: f32 = 2.;
24 24 const ITEM_RADIUS: f32 = 6.;
25 25 const ITEM_ICON: f32 = 16.;
26 26 const NAV_PADDING_X: f32 = 12.;
27 const NO_RESULTS: &str = "No settings found";
28
29 fn search_terms(section: SettingsSection) -> &'static [&'static str] {
30 match section {
31 SettingsSection::General => &[
32 "Auto-start Teams",
33 "Open application in background",
34 "On close, keep the application running",
35 "Up arrow key behaviour in compose box",
36 "Translate messages into this language",
37 "How to handle messages in other languages",
38 "Never translate messages in these languages",
39 ],
40 SettingsSection::Notifications => &[
41 "Chat message notifications",
42 "Meeting chat notifications",
43 "Likes and reactions",
44 "Teams and channels",
45 "Show message preview",
46 "Notification sound",
47 "Urgent sound",
48 "Position on the screen",
49 "Flash taskbar when notifications are received",
50 "Hide notifications during calls and meetings",
51 "Send test notification",
52 ],
53 SettingsSection::Appearance => &["Theme", "Color scheme", "App icon"],
54 SettingsSection::Chats => &[
55 "Message density",
56 "Read receipts",
57 "Show message actions on right click",
58 "Show muted items in their own section",
59 "When writing a message, press Enter to",
60 "Format messages using mark-down",
61 ],
62 SettingsSection::Calls => &["Use Teams on the web for calls and meetings", "Ringtones"],
63 SettingsSection::Devices => &[
64 "Speaker",
65 "Microphone",
66 "Noise suppression",
67 "Music mode",
68 "Camera",
69 "Background",
70 "Soft focus",
71 "Adjust brightness",
72 "Mirror my video",
73 "Make a test call",
74 "Save a test report after each call",
75 ],
76 SettingsSection::Agents => &["Claude", "Agent runs"],
77 SettingsSection::Mcp => &["Model Context Protocol", "Conversation access"],
78 SettingsSection::About => &["Version", "Build"],
79 }
80 }
81
82 pub fn matches(section: SettingsSection, query: &str) -> bool {
83 let query = query.trim().to_lowercase();
84 query.is_empty()
85 || std::iter::once(label(section))
86 .chain(search_terms(section).iter().copied())
87 .any(|text| text.to_lowercase().contains(&query))
88 }
89
90 pub fn first_match(query: &str, agents_available: bool) -> Option<SettingsSection> {
91 TEAMS_GROUP
92 .into_iter()
93 .chain(RUSTY_GROUP)
94 .chain([SettingsSection::About])
95 .filter(|section| agents_available || *section != SettingsSection::Agents)
96 .find(|section| matches(*section, query))
97 }
27 98
28 99 pub fn label(section: SettingsSection) -> &'static str {
29 100 match section {
@@ -80,18 +151,33 @@ pub struct NavLayout {
80 151 pub padding_y: f32,
81 152 }
82 153
154 pub struct NavSearch<'a> {
155 pub input: AnyElement,
156 pub query: &'a str,
157 }
158
83 159 pub fn render_nav(
84 160 active: SettingsSection,
85 161 agents_available: bool,
86 162 layout: NavLayout,
163 search: NavSearch<'_>,
87 164 on_select: impl Fn(SettingsSection, &mut Window, &mut App) + Clone + 'static,
88 165 ) -> Div {
89 166 let item = |section: SettingsSection| nav_item(section, section == active, on_select.clone());
167 let query = search.query;
168 let teams: Vec<Stateful<Div>> = TEAMS_GROUP
169 .into_iter()
170 .filter(|section| matches(*section, query))
171 .map(item)
172 .collect();
90 173 let rusty: Vec<Stateful<Div>> = RUSTY_GROUP
91 174 .into_iter()
92 175 .filter(|section| agents_available || *section != SettingsSection::Agents)
176 .filter(|section| matches(*section, query))
93 177 .map(item)
94 178 .collect();
179 let about_shown = matches(SettingsSection::About, query);
180 let nothing_found = teams.is_empty() && rusty.is_empty() && !about_shown;
95 181 let group = |items: Vec<Stateful<Div>>| {
96 182 v_flex()
97 183 .w_full()
@@ -119,6 +205,14 @@ pub fn render_nav(
119 205 .text_color(theme::text())
120 206 .child("Settings"),
121 207 )
208 .child(
209 div()
210 .debug_selector(|| "settings/nav/search".into())
211 .w_full()
212 .px(px(NAV_PADDING_X))
213 .pb(px(10.))
214 .child(search.input),
215 )
122 216 .child(
123 217 v_flex()
124 218 .id("settings-nav-groups")
@@ -127,8 +221,18 @@ pub fn render_nav(
127 221 .min_h(px(0.))
128 222 .overflow_y_scrollbar()
129 223 .gap(px(ITEM_GAP))
130 .child(group(TEAMS_GROUP.into_iter().map(item).collect()))
131 .child(
224 .child(group(teams))
225 .when(nothing_found, |groups| {
226 groups.child(
227 div()
228 .px(px(2. * NAV_PADDING_X))
229 .py(px(ITEM_PADDING_Y))
230 .text_size(px(13.))
231 .text_color(theme::text_muted())
232 .child(NO_RESULTS),
233 )
234 })
235 .when(!rusty.is_empty(), |groups| groups.child(
132 236 div()
133 237 .debug_selector(|| "settings/nav/divider".into())
134 238 .w_full()
@@ -146,15 +250,15 @@ pub fn render_nav(
146 250 .font_weight(FontWeight::SEMIBOLD)
147 251 .text_color(theme::text_muted())
148 252 .child("RUSTY TEAMS"),
149 )
150 .child(group(rusty)),
151 )
152 .child(
153 div()
154 .w_full()
155 .px(px(NAV_PADDING_X))
156 .child(item(SettingsSection::About).debug_selector(|| "settings/nav/about".into())),
253 ).child(group(rusty))),
157 254 )
255 .when(about_shown, |nav| {
256 nav.child(
257 div().w_full().px(px(NAV_PADDING_X)).child(
258 item(SettingsSection::About).debug_selector(|| "settings/nav/about".into()),
259 ),
260 )
261 })
158 262 }
159 263
160 264 fn nav_item(
@@ -201,3 +305,36 @@ fn nav_item(
201 305 )
202 306 .on_click(move |_, window, cx| on_select(section, window, cx))
203 307 }
308
309 #[cfg(test)]
310 mod tests {
311 use super::{SettingsSection, first_match, label, matches, search_terms};
312
313 #[test]
314 fn search_finds_sections_by_name_and_by_setting() {
315 assert!(matches(SettingsSection::Chats, "read receipts"));
316 assert!(matches(SettingsSection::Devices, "MICRO"));
317 assert!(matches(SettingsSection::Calls, "calls"));
318 assert!(!matches(SettingsSection::Appearance, "receipts"));
319 assert!(matches(SettingsSection::Appearance, " "));
320 assert_eq!(first_match("noise", true), Some(SettingsSection::Devices));
321 assert_eq!(first_match("claude", false), None);
322 assert_eq!(first_match("xyz", true), None);
323 }
324
325 #[test]
326 fn every_search_term_names_a_setting_on_its_page() {
327 let pages = [
328 (SettingsSection::General, include_str!("general.rs")),
329 (SettingsSection::Notifications, include_str!("notifications.rs")),
330 (SettingsSection::Appearance, include_str!("appearance.rs")),
331 (SettingsSection::Chats, include_str!("chats.rs")),
332 (SettingsSection::Devices, include_str!("devices.rs")),
333 ];
334 for (section, source) in pages {
335 for term in search_terms(section) {
336 assert!(source.contains(term), "{term} is not on {}", label(section));
337 }
338 }
339 }
340 }
@@ -24,6 +24,77 @@ const ITEM_GAP: f32 = 2.;
24const ITEM_RADIUS: f32 = 6.;
24const ITEM_RADIUS: f32 = 6.;
25const ITEM_ICON: f32 = 16.;
25const ITEM_ICON: f32 = 16.;
26const NAV_PADDING_X: f32 = 12.;
26const NAV_PADDING_X: f32 = 12.;
27const NO_RESULTS: &str = "No settings found";
28
29fn search_terms(section: SettingsSection) -> &'static [&'static str] {
30 match section {
31 SettingsSection::General => &[
32 "Auto-start Teams",
33 "Open application in background",
34 "On close, keep the application running",
35 "Up arrow key behaviour in compose box",
36 "Translate messages into this language",
37 "How to handle messages in other languages",
38 "Never translate messages in these languages",
39 ],
40 SettingsSection::Notifications => &[
41 "Chat message notifications",
42 "Meeting chat notifications",
43 "Likes and reactions",
44 "Teams and channels",
45 "Show message preview",
46 "Notification sound",
47 "Urgent sound",
48 "Position on the screen",
49 "Flash taskbar when notifications are received",
50 "Hide notifications during calls and meetings",
51 "Send test notification",
52 ],
53 SettingsSection::Appearance => &["Theme", "Color scheme", "App icon"],
54 SettingsSection::Chats => &[
55 "Message density",
56 "Read receipts",
57 "Show message actions on right click",
58 "Show muted items in their own section",
59 "When writing a message, press Enter to",
60 "Format messages using mark-down",
61 ],
62 SettingsSection::Calls => &["Use Teams on the web for calls and meetings", "Ringtones"],
63 SettingsSection::Devices => &[
64 "Speaker",
65 "Microphone",
66 "Noise suppression",
67 "Music mode",
68 "Camera",
69 "Background",
70 "Soft focus",
71 "Adjust brightness",
72 "Mirror my video",
73 "Make a test call",
74 "Save a test report after each call",
75 ],
76 SettingsSection::Agents => &["Claude", "Agent runs"],
77 SettingsSection::Mcp => &["Model Context Protocol", "Conversation access"],
78 SettingsSection::About => &["Version", "Build"],
79 }
80}
81
82pub fn matches(section: SettingsSection, query: &str) -> bool {
83 let query = query.trim().to_lowercase();
84 query.is_empty()
85 || std::iter::once(label(section))
86 .chain(search_terms(section).iter().copied())
87 .any(|text| text.to_lowercase().contains(&query))
88}
89
90pub fn first_match(query: &str, agents_available: bool) -> Option<SettingsSection> {
91 TEAMS_GROUP
92 .into_iter()
93 .chain(RUSTY_GROUP)
94 .chain([SettingsSection::About])
95 .filter(|section| agents_available || *section != SettingsSection::Agents)
96 .find(|section| matches(*section, query))
97}
27
98
28pub fn label(section: SettingsSection) -> &'static str {
99pub fn label(section: SettingsSection) -> &'static str {
29 match section {
100 match section {
@@ -80,18 +151,33 @@ pub struct NavLayout {
80 pub padding_y: f32,
151 pub padding_y: f32,
81}
152}
82
153
154pub struct NavSearch<'a> {
155 pub input: AnyElement,
156 pub query: &'a str,
157}
158
83pub fn render_nav(
159pub fn render_nav(
84 active: SettingsSection,
160 active: SettingsSection,
85 agents_available: bool,
161 agents_available: bool,
86 layout: NavLayout,
162 layout: NavLayout,
163 search: NavSearch<'_>,
87 on_select: impl Fn(SettingsSection, &mut Window, &mut App) + Clone + 'static,
164 on_select: impl Fn(SettingsSection, &mut Window, &mut App) + Clone + 'static,
88) -> Div {
165) -> Div {
89 let item = |section: SettingsSection| nav_item(section, section == active, on_select.clone());
166 let item = |section: SettingsSection| nav_item(section, section == active, on_select.clone());
167 let query = search.query;
168 let teams: Vec<Stateful<Div>> = TEAMS_GROUP
169 .into_iter()
170 .filter(|section| matches(*section, query))
171 .map(item)
172 .collect();
90 let rusty: Vec<Stateful<Div>> = RUSTY_GROUP
173 let rusty: Vec<Stateful<Div>> = RUSTY_GROUP
91 .into_iter()
174 .into_iter()
92 .filter(|section| agents_available || *section != SettingsSection::Agents)
175 .filter(|section| agents_available || *section != SettingsSection::Agents)
176 .filter(|section| matches(*section, query))
93 .map(item)
177 .map(item)
94 .collect();
178 .collect();
179 let about_shown = matches(SettingsSection::About, query);
180 let nothing_found = teams.is_empty() && rusty.is_empty() && !about_shown;
95 let group = |items: Vec<Stateful<Div>>| {
181 let group = |items: Vec<Stateful<Div>>| {
96 v_flex()
182 v_flex()
97 .w_full()
183 .w_full()
@@ -119,6 +205,14 @@ pub fn render_nav(
119 .text_color(theme::text())
205 .text_color(theme::text())
120 .child("Settings"),
206 .child("Settings"),
121 )
207 )
208 .child(
209 div()
210 .debug_selector(|| "settings/nav/search".into())
211 .w_full()
212 .px(px(NAV_PADDING_X))
213 .pb(px(10.))
214 .child(search.input),
215 )
122 .child(
216 .child(
123 v_flex()
217 v_flex()
124 .id("settings-nav-groups")
218 .id("settings-nav-groups")
@@ -127,8 +221,18 @@ pub fn render_nav(
127 .min_h(px(0.))
221 .min_h(px(0.))
128 .overflow_y_scrollbar()
222 .overflow_y_scrollbar()
129 .gap(px(ITEM_GAP))
223 .gap(px(ITEM_GAP))
130 .child(group(TEAMS_GROUP.into_iter().map(item).collect()))
224 .child(group(teams))
131 .child(
225 .when(nothing_found, |groups| {
226 groups.child(
227 div()
228 .px(px(2. * NAV_PADDING_X))
229 .py(px(ITEM_PADDING_Y))
230 .text_size(px(13.))
231 .text_color(theme::text_muted())
232 .child(NO_RESULTS),
233 )
234 })
235 .when(!rusty.is_empty(), |groups| groups.child(
132 div()
236 div()
133 .debug_selector(|| "settings/nav/divider".into())
237 .debug_selector(|| "settings/nav/divider".into())
134 .w_full()
238 .w_full()
@@ -146,15 +250,15 @@ pub fn render_nav(
146 .font_weight(FontWeight::SEMIBOLD)
250 .font_weight(FontWeight::SEMIBOLD)
147 .text_color(theme::text_muted())
251 .text_color(theme::text_muted())
148 .child("RUSTY TEAMS"),
252 .child("RUSTY TEAMS"),
149 )
253 ).child(group(rusty))),
150 .child(group(rusty)),
151 )
152 .child(
153 div()
154 .w_full()
155 .px(px(NAV_PADDING_X))
156 .child(item(SettingsSection::About).debug_selector(|| "settings/nav/about".into())),
157 )
254 )
255 .when(about_shown, |nav| {
256 nav.child(
257 div().w_full().px(px(NAV_PADDING_X)).child(
258 item(SettingsSection::About).debug_selector(|| "settings/nav/about".into()),
259 ),
260 )
261 })
158}
262}
159
263
160fn nav_item(
264fn nav_item(
@@ -201,3 +305,36 @@ fn nav_item(
201 )
305 )
202 .on_click(move |_, window, cx| on_select(section, window, cx))
306 .on_click(move |_, window, cx| on_select(section, window, cx))
203}
307}
308
309#[cfg(test)]
310mod tests {
311 use super::{SettingsSection, first_match, label, matches, search_terms};
312
313 #[test]
314 fn search_finds_sections_by_name_and_by_setting() {
315 assert!(matches(SettingsSection::Chats, "read receipts"));
316 assert!(matches(SettingsSection::Devices, "MICRO"));
317 assert!(matches(SettingsSection::Calls, "calls"));
318 assert!(!matches(SettingsSection::Appearance, "receipts"));
319 assert!(matches(SettingsSection::Appearance, " "));
320 assert_eq!(first_match("noise", true), Some(SettingsSection::Devices));
321 assert_eq!(first_match("claude", false), None);
322 assert_eq!(first_match("xyz", true), None);
323 }
324
325 #[test]
326 fn every_search_term_names_a_setting_on_its_page() {
327 let pages = [
328 (SettingsSection::General, include_str!("general.rs")),
329 (SettingsSection::Notifications, include_str!("notifications.rs")),
330 (SettingsSection::Appearance, include_str!("appearance.rs")),
331 (SettingsSection::Chats, include_str!("chats.rs")),
332 (SettingsSection::Devices, include_str!("devices.rs")),
333 ];
334 for (section, source) in pages {
335 for term in search_terms(section) {
336 assert!(source.contains(term), "{term} is not on {}", label(section));
337 }
338 }
339 }
340}