assistant: Refine settings view's instruction visuals (#25812)
I've been bothered by using simple hyphens for bullet lists here for a while; it kinda looked cheap and not well-formatted. So, in this PR, I'm adding a new, custom UI component in the `language_models` crate, called `InstructionListItem`, based off the `ListItem` that's somewhat mimic'ing what a `<li>` would be on the web. It does have a "rigid" structure as in it's always a label followed by a button (which is optional), but that seems okay given it has been the overall shape of the copy we've been using here. Also, never really loved that we were pasting URLs directly, that kinda felt cheap, too. I could see an argument where it's just clearer, but it looks too cluttered, as URLs aren't super pretty, necessarily. | Before | After | |--------|--------| | <img src="https://github.com/user-attachments/assets/ffd1ac27-b1f4-450d-abf5-079285fc9877" width="700px" /> | <img src="https://github.com/user-attachments/assets/28fb9d0d-205d-45d8-9e43-1aaa947adc96" width="700px" /> | Release Notes: - N/A
This commit is contained in:
parent
c9aba6c10a
commit
508b581215
9 changed files with 180 additions and 148 deletions
|
@ -18,10 +18,10 @@ use serde::{Deserialize, Serialize};
|
|||
use settings::{Settings, SettingsStore};
|
||||
use std::sync::Arc;
|
||||
use theme::ThemeSettings;
|
||||
use ui::{prelude::*, Icon, IconName};
|
||||
use ui::{prelude::*, Icon, IconName, List};
|
||||
use util::ResultExt;
|
||||
|
||||
use crate::AllLanguageModelSettings;
|
||||
use crate::{ui::InstructionListItem, AllLanguageModelSettings};
|
||||
|
||||
const PROVIDER_ID: &str = "deepseek";
|
||||
const PROVIDER_NAME: &str = "DeepSeek";
|
||||
|
@ -607,13 +607,6 @@ impl ConfigurationView {
|
|||
|
||||
impl Render for ConfigurationView {
|
||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
const DEEPSEEK_CONSOLE_URL: &str = "https://platform.deepseek.com/api_keys";
|
||||
const INSTRUCTIONS: [&str; 3] = [
|
||||
"To use DeepSeek in Zed, you need an API key:",
|
||||
"- Get your API key from:",
|
||||
"- Paste it below and press enter:",
|
||||
];
|
||||
|
||||
let env_var_set = self.state.read(cx).api_key_from_env;
|
||||
|
||||
if self.load_credentials_task.is_some() {
|
||||
|
@ -622,18 +615,18 @@ impl Render for ConfigurationView {
|
|||
v_flex()
|
||||
.size_full()
|
||||
.on_action(cx.listener(Self::save_api_key))
|
||||
.child(Label::new(INSTRUCTIONS[0]))
|
||||
.child(Label::new("To use DeepSeek in Zed, you need an API key:"))
|
||||
.child(
|
||||
h_flex().child(Label::new(INSTRUCTIONS[1])).child(
|
||||
Button::new("deepseek_console", DEEPSEEK_CONSOLE_URL)
|
||||
.style(ButtonStyle::Subtle)
|
||||
.icon(IconName::ArrowUpRight)
|
||||
.icon_size(IconSize::XSmall)
|
||||
.icon_color(Color::Muted)
|
||||
.on_click(move |_, _window, cx| cx.open_url(DEEPSEEK_CONSOLE_URL)),
|
||||
),
|
||||
List::new()
|
||||
.child(InstructionListItem::new(
|
||||
"Get your API key from the",
|
||||
Some("DeepSeek console"),
|
||||
Some("https://platform.deepseek.com/api_keys"),
|
||||
))
|
||||
.child(InstructionListItem::text_only(
|
||||
"Paste your API key below and hit enter to start using the assistant",
|
||||
)),
|
||||
)
|
||||
.child(Label::new(INSTRUCTIONS[2]))
|
||||
.child(
|
||||
h_flex()
|
||||
.w_full()
|
||||
|
@ -651,7 +644,8 @@ impl Render for ConfigurationView {
|
|||
"Or set the {} environment variable.",
|
||||
DEEPSEEK_API_KEY_VAR
|
||||
))
|
||||
.size(LabelSize::Small),
|
||||
.size(LabelSize::Small)
|
||||
.color(Color::Muted),
|
||||
)
|
||||
.into_any()
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue