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>
@@ -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(¢er, |_, _, 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 @@1
use app_ui_kit::settings_controls::PAGE_PADDING;1
use app_ui_kit::settings_controls::PAGE_PADDING;2
use gpui_kit::component::scroll::ScrollableElement as _;2
use gpui_kit::component::scroll::ScrollableElement as _;3
use gpui_kit::assets::IconName;3
use gpui_kit::assets::IconName;4
use gpui_kit::component::input::{Input, InputEvent, InputState};4
use gpui_kit::component::{h_flex, v_flex};5
use gpui_kit::component::{h_flex, v_flex};5
use gpui_kit::*;6
use gpui_kit::*;6
7
7
use super::devices::DevicesView;8
use super::devices::DevicesView;8
use super::mcp::McpView;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
use super::rows::ROW_INSET;11
use super::rows::ROW_INSET;11
use super::{about, appearance, calls, chats, general, notifications};12
use super::{about, appearance, calls, chats, general, notifications};12
use crate::agents::AgentsSettings;13
use crate::agents::AgentsSettings;@@ -26,6 +27,8 @@ const COMPACT_BELOW_WIDTH: f32 = 1100.;26
const COMPACT_BELOW_HEIGHT: f32 = 720.;27
const COMPACT_BELOW_HEIGHT: f32 = 720.;27
const NAV_WIDTH: f32 = 280.;28
const NAV_WIDTH: f32 = 280.;28
const PADDING: f32 = 24.;29
const PADDING: f32 = 24.;30
const SEARCH_HEIGHT: f32 = 32.;31
const SEARCH_PLACEHOLDER: &str = "Find in Settings";29
32
30
pub enum SettingsDialogEvent {33
pub 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
70
impl EventEmitter<SettingsDialogEvent> for SettingsDialog {}74
impl 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(¢er, |_, _, cx| cx.notify()),86
cx.observe(¢er, |_, _, 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
},