settings_ui: Add pickers for theme and icon themes (#40829)

In the process of adding pickers for the theme and icon themes fields in
the settings UI, I felt like there was an improvement opportunity in
regards to where some of these components are stored. The `ui_input`
crate originally was meant only for the text field-like component, which
couldn't be in the regular `ui` crate due to the dependency with
`editor`. Given we had also added the number field there—which is
similar in also having the same dependency—it made sense to think of
this crate more like a home for form-like components rather than for
only one component.

However, we were also storing some settings UI-specific stuff in that
crate, which didn't feel right. So I ended up creating a new directory
within the `settings_ui` for components and moved all the pickers and
the custom input field there. I think this makes it for a cleaner
structure.

Release Notes:

- settings_ui: Added the ability to search for theme and icon themes in
their respective fields.
This commit is contained in:
Danilo Leal
2025-10-21 19:58:43 -03:00
committed by GitHub
parent b519f53b3e
commit 8f3da5c5cd
28 changed files with 881 additions and 538 deletions
@@ -21,7 +21,7 @@ use std::str::FromStr;
use std::sync::{Arc, LazyLock};
use strum::IntoEnumIterator;
use ui::{Icon, IconName, List, Tooltip, prelude::*};
use ui_input::SingleLineInput;
use ui_input::InputField;
use util::{ResultExt, truncate_and_trailoff};
use zed_env_vars::{EnvVar, env_var};
@@ -823,7 +823,7 @@ fn convert_usage(usage: &Usage) -> language_model::TokenUsage {
}
struct ConfigurationView {
api_key_editor: Entity<SingleLineInput>,
api_key_editor: Entity<InputField>,
state: Entity<State>,
load_credentials_task: Option<Task<()>>,
target_agent: ConfigurationViewTargetAgent,
@@ -862,7 +862,7 @@ impl ConfigurationView {
}));
Self {
api_key_editor: cx.new(|cx| SingleLineInput::new(window, cx, Self::PLACEHOLDER_TEXT)),
api_key_editor: cx.new(|cx| InputField::new(window, cx, Self::PLACEHOLDER_TEXT)),
state,
load_credentials_task,
target_agent,
+10 -11
View File
@@ -42,7 +42,7 @@ use settings::{BedrockAvailableModel as AvailableModel, Settings, SettingsStore}
use smol::lock::OnceCell;
use strum::{EnumIter, IntoEnumIterator, IntoStaticStr};
use ui::{Icon, IconName, List, Tooltip, prelude::*};
use ui_input::SingleLineInput;
use ui_input::InputField;
use util::ResultExt;
use crate::AllLanguageModelSettings;
@@ -1006,10 +1006,10 @@ pub fn map_to_language_model_completion_events(
}
struct ConfigurationView {
access_key_id_editor: Entity<SingleLineInput>,
secret_access_key_editor: Entity<SingleLineInput>,
session_token_editor: Entity<SingleLineInput>,
region_editor: Entity<SingleLineInput>,
access_key_id_editor: Entity<InputField>,
secret_access_key_editor: Entity<InputField>,
session_token_editor: Entity<InputField>,
region_editor: Entity<InputField>,
state: Entity<State>,
load_credentials_task: Option<Task<()>>,
}
@@ -1047,20 +1047,19 @@ impl ConfigurationView {
Self {
access_key_id_editor: cx.new(|cx| {
SingleLineInput::new(window, cx, Self::PLACEHOLDER_ACCESS_KEY_ID_TEXT)
InputField::new(window, cx, Self::PLACEHOLDER_ACCESS_KEY_ID_TEXT)
.label("Access Key ID")
}),
secret_access_key_editor: cx.new(|cx| {
SingleLineInput::new(window, cx, Self::PLACEHOLDER_SECRET_ACCESS_KEY_TEXT)
InputField::new(window, cx, Self::PLACEHOLDER_SECRET_ACCESS_KEY_TEXT)
.label("Secret Access Key")
}),
session_token_editor: cx.new(|cx| {
SingleLineInput::new(window, cx, Self::PLACEHOLDER_SESSION_TOKEN_TEXT)
InputField::new(window, cx, Self::PLACEHOLDER_SESSION_TOKEN_TEXT)
.label("Session Token (Optional)")
}),
region_editor: cx.new(|cx| {
SingleLineInput::new(window, cx, Self::PLACEHOLDER_REGION).label("Region")
}),
region_editor: cx
.new(|cx| InputField::new(window, cx, Self::PLACEHOLDER_REGION).label("Region")),
state,
load_credentials_task,
}
@@ -20,7 +20,7 @@ use std::str::FromStr;
use std::sync::{Arc, LazyLock};
use ui::{Icon, IconName, List, prelude::*};
use ui_input::SingleLineInput;
use ui_input::InputField;
use util::{ResultExt, truncate_and_trailoff};
use zed_env_vars::{EnvVar, env_var};
@@ -525,7 +525,7 @@ impl DeepSeekEventMapper {
}
struct ConfigurationView {
api_key_editor: Entity<SingleLineInput>,
api_key_editor: Entity<InputField>,
state: Entity<State>,
load_credentials_task: Option<Task<()>>,
}
@@ -533,7 +533,7 @@ struct ConfigurationView {
impl ConfigurationView {
fn new(state: Entity<State>, window: &mut Window, cx: &mut Context<Self>) -> Self {
let api_key_editor =
cx.new(|cx| SingleLineInput::new(window, cx, "sk-00000000000000000000000000000000"));
cx.new(|cx| InputField::new(window, cx, "sk-00000000000000000000000000000000"));
cx.observe(&state, |_, _, cx| {
cx.notify();
@@ -29,7 +29,7 @@ use std::sync::{
};
use strum::IntoEnumIterator;
use ui::{Icon, IconName, List, Tooltip, prelude::*};
use ui_input::SingleLineInput;
use ui_input::InputField;
use util::{ResultExt, truncate_and_trailoff};
use zed_env_vars::EnvVar;
@@ -751,7 +751,7 @@ fn convert_usage(usage: &UsageMetadata) -> language_model::TokenUsage {
}
struct ConfigurationView {
api_key_editor: Entity<SingleLineInput>,
api_key_editor: Entity<InputField>,
state: Entity<State>,
target_agent: language_model::ConfigurationViewTargetAgent,
load_credentials_task: Option<Task<()>>,
@@ -788,7 +788,7 @@ impl ConfigurationView {
}));
Self {
api_key_editor: cx.new(|cx| SingleLineInput::new(window, cx, "AIzaSy...")),
api_key_editor: cx.new(|cx| InputField::new(window, cx, "AIzaSy...")),
target_agent,
state,
load_credentials_task,
@@ -20,7 +20,7 @@ use std::str::FromStr;
use std::sync::{Arc, LazyLock};
use strum::IntoEnumIterator;
use ui::{Icon, IconName, List, Tooltip, prelude::*};
use ui_input::SingleLineInput;
use ui_input::InputField;
use util::{ResultExt, truncate_and_trailoff};
use zed_env_vars::{EnvVar, env_var};
@@ -744,8 +744,8 @@ struct RawToolCall {
}
struct ConfigurationView {
api_key_editor: Entity<SingleLineInput>,
codestral_api_key_editor: Entity<SingleLineInput>,
api_key_editor: Entity<InputField>,
codestral_api_key_editor: Entity<InputField>,
state: Entity<State>,
load_credentials_task: Option<Task<()>>,
}
@@ -753,9 +753,9 @@ struct ConfigurationView {
impl ConfigurationView {
fn new(state: Entity<State>, window: &mut Window, cx: &mut Context<Self>) -> Self {
let api_key_editor =
cx.new(|cx| SingleLineInput::new(window, cx, "0aBCDEFGhIjKLmNOpqrSTUVwxyzabCDE1f2"));
cx.new(|cx| InputField::new(window, cx, "0aBCDEFGhIjKLmNOpqrSTUVwxyzabCDE1f2"));
let codestral_api_key_editor =
cx.new(|cx| SingleLineInput::new(window, cx, "0aBCDEFGhIjKLmNOpqrSTUVwxyzabCDE1f2"));
cx.new(|cx| InputField::new(window, cx, "0aBCDEFGhIjKLmNOpqrSTUVwxyzabCDE1f2"));
cx.observe(&state, |_, _, cx| {
cx.notify();
@@ -23,7 +23,7 @@ use std::sync::LazyLock;
use std::sync::atomic::{AtomicU64, Ordering};
use std::{collections::HashMap, sync::Arc};
use ui::{ButtonLike, ElevationIndex, List, Tooltip, prelude::*};
use ui_input::SingleLineInput;
use ui_input::InputField;
use zed_env_vars::{EnvVar, env_var};
use crate::AllLanguageModelSettings;
@@ -623,18 +623,17 @@ fn map_to_language_model_completion_events(
}
struct ConfigurationView {
api_key_editor: Entity<SingleLineInput>,
api_url_editor: Entity<SingleLineInput>,
api_key_editor: Entity<InputField>,
api_url_editor: Entity<InputField>,
state: Entity<State>,
}
impl ConfigurationView {
pub fn new(state: Entity<State>, window: &mut Window, cx: &mut Context<Self>) -> Self {
let api_key_editor =
cx.new(|cx| SingleLineInput::new(window, cx, "63e02e...").label("API key"));
let api_key_editor = cx.new(|cx| InputField::new(window, cx, "63e02e...").label("API key"));
let api_url_editor = cx.new(|cx| {
let input = SingleLineInput::new(window, cx, OLLAMA_API_URL).label("API URL");
let input = InputField::new(window, cx, OLLAMA_API_URL).label("API URL");
input.set_text(OllamaLanguageModelProvider::api_url(cx), window, cx);
input
});
@@ -21,7 +21,7 @@ use std::str::FromStr as _;
use std::sync::{Arc, LazyLock};
use strum::IntoEnumIterator;
use ui::{ElevationIndex, List, Tooltip, prelude::*};
use ui_input::SingleLineInput;
use ui_input::InputField;
use util::{ResultExt, truncate_and_trailoff};
use zed_env_vars::{EnvVar, env_var};
@@ -675,7 +675,7 @@ pub fn count_open_ai_tokens(
}
struct ConfigurationView {
api_key_editor: Entity<SingleLineInput>,
api_key_editor: Entity<InputField>,
state: Entity<State>,
load_credentials_task: Option<Task<()>>,
}
@@ -683,7 +683,7 @@ struct ConfigurationView {
impl ConfigurationView {
fn new(state: Entity<State>, window: &mut Window, cx: &mut Context<Self>) -> Self {
let api_key_editor = cx.new(|cx| {
SingleLineInput::new(
InputField::new(
window,
cx,
"sk-000000000000000000000000000000000000000000000000",
@@ -14,7 +14,7 @@ use open_ai::{ResponseStreamEvent, stream_completion};
use settings::{Settings, SettingsStore};
use std::sync::Arc;
use ui::{ElevationIndex, Tooltip, prelude::*};
use ui_input::SingleLineInput;
use ui_input::InputField;
use util::{ResultExt, truncate_and_trailoff};
use zed_env_vars::EnvVar;
@@ -340,7 +340,7 @@ impl LanguageModel for OpenAiCompatibleLanguageModel {
}
struct ConfigurationView {
api_key_editor: Entity<SingleLineInput>,
api_key_editor: Entity<InputField>,
state: Entity<State>,
load_credentials_task: Option<Task<()>>,
}
@@ -348,7 +348,7 @@ struct ConfigurationView {
impl ConfigurationView {
fn new(state: Entity<State>, window: &mut Window, cx: &mut Context<Self>) -> Self {
let api_key_editor = cx.new(|cx| {
SingleLineInput::new(
InputField::new(
window,
cx,
"000000000000000000000000000000000000000000000000000",
@@ -18,7 +18,7 @@ use std::pin::Pin;
use std::str::FromStr as _;
use std::sync::{Arc, LazyLock};
use ui::{Icon, IconName, List, Tooltip, prelude::*};
use ui_input::SingleLineInput;
use ui_input::InputField;
use util::{ResultExt, truncate_and_trailoff};
use zed_env_vars::{EnvVar, env_var};
@@ -692,7 +692,7 @@ pub fn count_open_router_tokens(
}
struct ConfigurationView {
api_key_editor: Entity<SingleLineInput>,
api_key_editor: Entity<InputField>,
state: Entity<State>,
load_credentials_task: Option<Task<()>>,
}
@@ -700,7 +700,7 @@ struct ConfigurationView {
impl ConfigurationView {
fn new(state: Entity<State>, window: &mut Window, cx: &mut Context<Self>) -> Self {
let api_key_editor = cx.new(|cx| {
SingleLineInput::new(
InputField::new(
window,
cx,
"sk_or_000000000000000000000000000000000000000000000000",
@@ -15,7 +15,7 @@ use settings::{Settings, SettingsStore};
use std::sync::{Arc, LazyLock};
use strum::IntoEnumIterator;
use ui::{ElevationIndex, List, Tooltip, prelude::*};
use ui_input::SingleLineInput;
use ui_input::InputField;
use util::{ResultExt, truncate_and_trailoff};
use vercel::{Model, VERCEL_API_URL};
use zed_env_vars::{EnvVar, env_var};
@@ -362,7 +362,7 @@ pub fn count_vercel_tokens(
}
struct ConfigurationView {
api_key_editor: Entity<SingleLineInput>,
api_key_editor: Entity<InputField>,
state: Entity<State>,
load_credentials_task: Option<Task<()>>,
}
@@ -370,7 +370,7 @@ struct ConfigurationView {
impl ConfigurationView {
fn new(state: Entity<State>, window: &mut Window, cx: &mut Context<Self>) -> Self {
let api_key_editor = cx.new(|cx| {
SingleLineInput::new(
InputField::new(
window,
cx,
"v1:0000000000000000000000000000000000000000000000000",
+3 -3
View File
@@ -15,7 +15,7 @@ use settings::{Settings, SettingsStore};
use std::sync::{Arc, LazyLock};
use strum::IntoEnumIterator;
use ui::{ElevationIndex, List, Tooltip, prelude::*};
use ui_input::SingleLineInput;
use ui_input::InputField;
use util::{ResultExt, truncate_and_trailoff};
use x_ai::{Model, XAI_API_URL};
use zed_env_vars::{EnvVar, env_var};
@@ -359,7 +359,7 @@ pub fn count_xai_tokens(
}
struct ConfigurationView {
api_key_editor: Entity<SingleLineInput>,
api_key_editor: Entity<InputField>,
state: Entity<State>,
load_credentials_task: Option<Task<()>>,
}
@@ -367,7 +367,7 @@ struct ConfigurationView {
impl ConfigurationView {
fn new(state: Entity<State>, window: &mut Window, cx: &mut Context<Self>) -> Self {
let api_key_editor = cx.new(|cx| {
SingleLineInput::new(
InputField::new(
window,
cx,
"xai-0000000000000000000000000000000000000000000000000",