Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Improve warning display UI related to skills (#58838)
Danilo Leale7edca8fd0af
diff --git a/crates/agent_ui/src/completion_provider.rs b/crates/agent_ui/src/completion_provider.rsindex 87e0e09c81a..f38568624db 100644--- a/crates/agent_ui/src/completion_provider.rs+++ b/crates/agent_ui/src/completion_provider.rs@@ -12,7 +12,9 @@ use anyhow::Result;use editor::{CompletionProvider, Editor, code_context_menus::COMPLETION_MENU_MAX_WIDTH};use futures::FutureExt as _;use fuzzy::{PathMatch, StringMatch, StringMatchCandidate};-use gpui::{App, BackgroundExecutor, Entity, Focusable, SharedString, Task, WeakEntity, Window};+use gpui::{+ App, BackgroundExecutor, Entity, Focusable, Hsla, SharedString, Task, WeakEntity, Window,+};use language::{Buffer, CodeLabel, CodeLabelBuilder, HighlightId};use lsp::CompletionContext;use multi_buffer::ToOffset as _;@@ -303,22 +305,27 @@ pub struct AvailableSkill {}fn skill_completion_icon_path(- _skill: &AvailableSkill,+ skill: &AvailableSkill,uri: &MentionUri,cx: &mut App,) -> SharedString {- uri.icon_path(cx)+ if skill.warning.is_some() {+ IconName::Warning.path().into()+ } else {+ uri.icon_path(cx)+ }+}++fn skill_completion_icon_color(skill: &AvailableSkill, cx: &App) -> Option<Hsla> {+ skill.warning.is_some().then(|| cx.theme().status().warning)}fn skill_completion_documentation(skill: &AvailableSkill) -> CompletionDocumentation {- if let Some(warning) = &skill.warning {- CompletionDocumentation::WarningAndMultiLinePlainText {- warning: "".into(),- plain_text: Some(warning.clone()),- }- } else {- CompletionDocumentation::MultiLinePlainText(skill.description.to_string().into())- }+ let text = match &skill.warning {+ Some(warning) => warning.clone(),+ None => skill.description.to_string().into(),+ };+ CompletionDocumentation::MultiLinePlainText(text)}#[derive(Debug, Clone)]@@ -400,6 +407,7 @@ impl<T: PromptCompletionProviderDelegate> PromptCompletionProvider<T> {new_text: format!("@{} ", mode.keyword()),label: CodeLabel::plain(mode.label().to_string(), None),icon_path: Some(mode.icon().path().into()),+ icon_color: None,documentation: None,source: project::CompletionSource::Custom,match_start: None,@@ -457,6 +465,7 @@ impl<T: PromptCompletionProviderDelegate> PromptCompletionProvider<T> {match_start: None,snippet_deduplication_key: None,icon_path: Some(icon_for_completion),+ icon_color: None,confirm: Some(confirm_completion_callback(title,source_range.start,@@ -505,6 +514,7 @@ impl<T: PromptCompletionProviderDelegate> PromptCompletionProvider<T> {match_start: None,snippet_deduplication_key: None,icon_path: Some(icon_path),+ icon_color: skill_completion_icon_color(&skill, cx),confirm: Some(confirm_completion_callback(crease_text,source_range.start,@@ -569,6 +579,7 @@ impl<T: PromptCompletionProviderDelegate> PromptCompletionProvider<T> {documentation: None,source: project::CompletionSource::Custom,icon_path: Some(completion_icon_path),+ icon_color: None,match_start: None,snippet_deduplication_key: None,insert_text_mode: None,@@ -635,6 +646,7 @@ impl<T: PromptCompletionProviderDelegate> PromptCompletionProvider<T> {documentation: None,source: project::CompletionSource::Custom,icon_path: Some(icon_path),+ icon_color: None,match_start: None,snippet_deduplication_key: None,insert_text_mode: None,@@ -676,6 +688,7 @@ impl<T: PromptCompletionProviderDelegate> PromptCompletionProvider<T> {documentation: None,source: project::CompletionSource::Custom,icon_path: Some(icon_path),+ icon_color: None,match_start: None,snippet_deduplication_key: None,insert_text_mode: None,@@ -726,6 +739,7 @@ impl<T: PromptCompletionProviderDelegate> PromptCompletionProvider<T> {new_text,label: CodeLabel::plain(action.label().to_string(), None),icon_path: Some(action.icon().path().into()),+ icon_color: None,documentation: None,source: project::CompletionSource::Custom,match_start: None,@@ -820,6 +834,7 @@ impl<T: PromptCompletionProviderDelegate> PromptCompletionProvider<T> {documentation: None,source: project::CompletionSource::Custom,icon_path: Some(icon_path),+ icon_color: None,match_start: None,snippet_deduplication_key: None,insert_text_mode: None,@@ -862,6 +877,7 @@ impl<T: PromptCompletionProviderDelegate> PromptCompletionProvider<T> {documentation: None,source: project::CompletionSource::Custom,icon_path: Some(icon_path),+ icon_color: None,match_start: None,snippet_deduplication_key: None,insert_text_mode: None,@@ -1325,6 +1341,7 @@ impl<T: PromptCompletionProviderDelegate> CompletionProvider for PromptCompletiotype SkillInfo = (String,SharedString,+ Option<Hsla>,Arc<dyn Fn(CompletionIntent, &mut Window, &mut App) -> bool + Send + Sync>,);let slash_candidates: Task<Vec<(SlashCompletionCandidate, Option<SkillInfo>)>> = {@@ -1344,6 +1361,7 @@ impl<T: PromptCompletionProviderDelegate> CompletionProvider for PromptCompletiolet new_text = format!("{} ", uri.as_link());let new_text_len = new_text.len();let icon_path = skill_completion_icon_path(skill, &uri, cx);+ let icon_color = skill_completion_icon_color(skill, cx);let crease_text: SharedString = uri.name().into();let confirm = confirm_completion_callback(crease_text,@@ -1355,7 +1373,10 @@ impl<T: PromptCompletionProviderDelegate> CompletionProvider for PromptCompletiomention_set.clone(),workspace.clone(),);- (candidate, Some((new_text, icon_path, confirm)))+ (+ candidate,+ Some((new_text, icon_path, icon_color, confirm)),+ )}SlashCompletionCandidate::Command(_) => (candidate, None),})@@ -1379,7 +1400,8 @@ impl<T: PromptCompletionProviderDelegate> CompletionProvider for PromptCompletioSome(&skill.source),source_highlight_id,);- let Some((new_text, icon_path, confirm)) = skill_info else {+ let Some((new_text, icon_path, icon_color, confirm)) = skill_info+ else {unreachable!("skill candidates always have confirm callbacks")};Completion {@@ -1389,6 +1411,7 @@ impl<T: PromptCompletionProviderDelegate> CompletionProvider for PromptCompletiodocumentation: Some(skill_completion_documentation(&skill)),source: project::CompletionSource::Custom,icon_path: Some(icon_path),+ icon_color,match_start: None,snippet_deduplication_key: None,insert_text_mode: None,@@ -1429,6 +1452,7 @@ impl<T: PromptCompletionProviderDelegate> CompletionProvider for PromptCompletio),source: project::CompletionSource::Custom,icon_path: None,+ icon_color: None,match_start: None,snippet_deduplication_key: None,insert_text_mode: None,diff --git a/crates/agent_ui/src/conversation_view/thread_view.rs b/crates/agent_ui/src/conversation_view/thread_view.rsindex 82ee5a3b2b9..0e5570e06ec 100644--- a/crates/agent_ui/src/conversation_view/thread_view.rs+++ b/crates/agent_ui/src/conversation_view/thread_view.rs@@ -10,7 +10,7 @@ use std::cell::RefCell;use acp_thread::{ContentBlock, PlanEntry, SandboxAuthorizationDetails};use agent::{SkillLoadingIssue, SkillLoadingIssueKind, SkillLoadingIssuesUpdated};use agent_settings::UserAgentsMd;-use agent_skills::global_skills_dir;+use agent_skills::MAX_SKILL_DESCRIPTION_LEN;use cloud_api_types::{SubmitAgentThreadFeedbackBody, SubmitAgentThreadFeedbackCommentsBody};use editor::actions::OpenExcerpts;@@ -27,7 +27,10 @@ use language_model::{LanguageModelRegistry, Speed,};use settings::update_settings_file;-use ui::{ButtonLike, SpinnerLabel, SpinnerVariant, SplitButton, SplitButtonStyle, Tab};+use ui::{+ ButtonLike, CalloutBorderPosition, SpinnerLabel, SpinnerVariant, SplitButton, SplitButtonStyle,+ Tab,+};use workspace::notifications::NotificationId;use workspace::{OpenOptions, SERIALIZATION_THROTTLE_TIME};@@ -684,70 +687,6 @@ fn skill_issue_file_label(path: &std::path::Path) -> String {}}-#[derive(Clone)]-struct SkillSettingsTarget {- label: String,- target: Option<zed_actions::OpenSettingsAtTarget>,-}--fn skill_warning_settings_targets(- warnings: &[SkillLoadingIssue],- project: &WeakEntity<Project>,- cx: &App,-) -> Vec<SkillSettingsTarget> {- let global_skills_dir = global_skills_dir();- let worktrees = project- .upgrade()- .map(|project| project.read(cx).visible_worktrees(cx).collect::<Vec<_>>())- .unwrap_or_default();-- let mut has_global_warnings = false;- let mut project_targets: Vec<(usize, String)> = Vec::new();-- for warning in warnings {- if warning.path.starts_with(&global_skills_dir) {- has_global_warnings = true;- continue;- }-- for worktree in &worktrees {- let worktree = worktree.read(cx);- let worktree_id = worktree.id().to_usize();- if warning.path.starts_with(worktree.abs_path().as_ref())- && !project_targets- .iter()- .any(|(target_worktree_id, _)| *target_worktree_id == worktree_id)- {- project_targets.push((worktree_id, worktree.root_name_str().to_string()));- break;- }- }- }-- let mut targets = Vec::new();- if has_global_warnings {- targets.push(SkillSettingsTarget {- label: "Manage Global Skills".to_string(),- target: Some(zed_actions::OpenSettingsAtTarget::User),- });- }-- let multiple_project_targets = project_targets.len() > 1;- for (worktree_id, worktree_root_name) in project_targets {- let label = if multiple_project_targets {- format!("Manage {worktree_root_name} Skills")- } else {- "Manage Project Skills".to_string()- };- targets.push(SkillSettingsTarget {- label,- target: Some(zed_actions::OpenSettingsAtTarget::Project { worktree_id }),- });- }-- targets-}-pub fn open_markdown_in_workspace(title: String,markdown: String,@@ -2674,7 +2613,13 @@ impl ThreadView {telemetry::event!("Follow Agent Selected", following = !following);}- // other+ fn callout_border_position(&self) -> CalloutBorderPosition {+ if self.list_state.item_count() > 0 {+ CalloutBorderPosition::Top+ } else {+ CalloutBorderPosition::Bottom+ }+ }pub fn render_thread_retry_status_callout(&self) -> Option<Callout> {let state = self.thread_retry_status.as_ref()?;@@ -2708,6 +2653,7 @@ impl ThreadView {Some(Callout::new()+ .border_position(self.callout_border_position()).icon(IconName::Warning).severity(Severity::Warning).title(state.last_error.clone())@@ -9356,7 +9302,7 @@ impl ThreadView {window: &mut Window,cx: &mut Context<Self>,) -> Option<Div> {- let content = match self.thread_error.as_ref()? {+ let callout = match self.thread_error.as_ref()? {ThreadError::Other { message, .. } => {self.render_any_thread_error(message.clone(), window, cx)}@@ -9470,7 +9416,7 @@ impl ThreadView {),};- Some(div().child(content))+ Some(div().child(callout.border_position(self.callout_border_position())))}fn render_refusal_error(&self, cx: &mut Context<'_, Self>) -> Callout {@@ -9734,7 +9680,7 @@ impl ThreadView {let description = "This agent does not support viewing previous messages. However, your session will still continue from where you last left off.";Callout::new()- .border_position(ui::BorderPosition::Bottom)+ .border_position(CalloutBorderPosition::Bottom).severity(Severity::Info).icon(IconName::Info).title("Resumed Session")@@ -9744,6 +9690,7 @@ impl ThreadView {fn render_codex_windows_warning(&self, cx: &mut Context<Self>) -> Callout {Callout::new()+ .border_position(self.callout_border_position()).icon(IconName::Warning).severity(Severity::Warning).title("Codex on Windows")@@ -9775,7 +9722,8 @@ impl ThreadView {}fn render_skill_loading_issues(&self, cx: &mut Context<Self>) -> Vec<Callout> {- let mut callouts = Vec::new();+ let border_position = self.callout_border_position();+let description_warnings = self.skill_loading_issues.iter()@@ -9783,61 +9731,37 @@ impl ThreadView {.cloned().collect::<Vec<_>>();- if !description_warnings.is_empty() {- let warning_count = description_warnings.len();- let title = if warning_count == 1 {- "1 skill loaded with warning".to_string()- } else {- format!("{warning_count} skills loaded with warnings")- };-- let mut callout = Callout::new()- .icon(IconName::Warning)- .severity(Severity::Warning)- .title(title);+ let long_description_warning =+ self.render_skill_description_warnings(description_warnings, cx);- if warning_count == 1 {- let rows = description_warnings- .iter()- .enumerate()- .map(|(index, issue)| {- let abs_path = issue.path.clone();- let workspace = self.workspace.clone();- let full_path = issue.path.display().to_string();- let file_label = skill_issue_file_label(&issue.path);- let file_icon = FileIcons::get_icon(issue.path.as_path(), cx)- .map(Icon::from_path)- .map(|icon| icon.color(Color::Muted).size(IconSize::Small))- .unwrap_or_else(|| {- Icon::new(IconName::File)- .color(Color::Muted)- .size(IconSize::Small)- });+ let other_warnings = self+ .skill_loading_issues+ .iter()+ .filter(|issue| issue.kind != SkillLoadingIssueKind::DescriptionTooLong)+ .enumerate()+ .map(|(index, issue)| {+ let abs_path = issue.path.clone();+ let workspace = self.workspace.clone();+ let path_label = issue.path.display().to_string();+ let target = issue.clone();++ let title = match issue.kind {+ SkillLoadingIssueKind::LoadFailed => "Skill Failed to Load",+ SkillLoadingIssueKind::DescriptionTooLong => unreachable!(),+ SkillLoadingIssueKind::CatalogBudgetExceeded => {+ "Skill Omitted from Model Catalog"+ }+ };- v_flex()- .id(("skill-description-warning-file", index))- .w_full()- .min_w_0()- .gap_0p5()- .p_1()- .rounded_sm()- .cursor_pointer()- .hover(|style| style.bg(cx.theme().colors().element_hover))- .child(- h_flex().min_w_0().gap_1().child(file_icon).child(- Label::new(file_label)- .size(LabelSize::Small)- .buffer_font(cx),- ),- )- .child(- Label::new(issue.message.clone())- .size(LabelSize::XSmall)- .color(Color::Muted),- )- .tooltip(move |_, cx| {- Tooltip::with_meta("Open File", None, full_path.clone(), cx)- })+ Callout::new()+ .icon(IconName::Warning)+ .severity(Severity::Warning)+ .title(title)+ .description(format!("{}\n{path_label}", issue.message))+ .actions_slot(+ Button::new(("open-skill-file", index), "Open Skill")+ .style(ButtonStyle::Outlined)+ .label_size(LabelSize::Small).on_click(cx.listener(move |_, _, window, cx| {let abs_path = abs_path.clone();workspace@@ -9852,136 +9776,134 @@ impl ThreadView {.detach_and_log_err(cx);}).ok();- }))- .into_any_element()- })- .collect::<Vec<_>>();- callout = callout.description_slot(v_flex().gap_1().children(rows));- } else {- let settings_targets =- skill_warning_settings_targets(&description_warnings, &self.project, cx);- if settings_targets.is_empty() {- callout = callout.description(- "Some skill descriptions exceed the recommended limit and may consume more model-context tokens.",- );- } else {- let manage_buttons =+ })),+ )+ .dismiss_action(+ IconButton::new(("dismiss-skill-issue", index), IconName::Close)+ .icon_size(IconSize::Small)+ .tooltip(Tooltip::text("Dismiss"))+ .on_click(cx.listener(move |this, _, _, cx| {+ this.skill_loading_issues.retain(|issue| *issue != target);+ this.dismissed_skill_loading_issues.insert(target.clone());+ cx.notify();+ })),+ )+ })+ .collect::<Vec<_>>();++ long_description_warning+ .into_iter()+ .chain(other_warnings)+ .map(|callout| callout.border_position(border_position))+ .collect()+ }++ fn render_skill_description_warnings(+ &self,+ description_warnings: Vec<SkillLoadingIssue>,+ cx: &mut Context<Self>,+ ) -> Option<Callout> {+ if description_warnings.is_empty() {+ return None;+ }++ let warning_count = description_warnings.len();+ let title = if warning_count == 1 {+ "1 Skill Loaded with a Long Description".to_string()+ } else {+ format!("{warning_count} Skills Loaded with Long Descriptions")+ };++ let rows = description_warnings+ .iter()+ .enumerate()+ .map(|(index, issue)| {+ let abs_path = issue.path.clone();+ let workspace = self.workspace.clone();+ let full_path = issue.path.display().to_string();+ let file_label = skill_issue_file_label(&issue.path);++ ButtonLike::new(("skill-description-warning-file", index))+ .full_width()+ .child(h_flex()- .gap_0p5()- .children(settings_targets.into_iter().enumerate().map(- |(index, settings_target)| {- let target = settings_target.target.clone();- Button::new(- ("open-skills-settings", index),- settings_target.label,+ .w_full()+ .gap_1()+ .child(+ Icon::new(IconName::Dash)+ .size(IconSize::XSmall)+ .color(Color::Muted),+ )+ .child(Label::new(file_label).size(LabelSize::Small)),+ )+ .tooltip(move |_, cx| {+ Tooltip::with_meta("Open Skill", None, full_path.clone(), cx)+ })+ .on_click(cx.listener(move |_, _, window, cx| {+ let abs_path = abs_path.clone();+ workspace+ .update(cx, |workspace, cx| {+ workspace+ .open_abs_path(+ abs_path,+ workspace::OpenOptions::default(),+ window,+ cx,)- .label_size(LabelSize::Small)- .on_click(move |_, window, cx| {- window.dispatch_action(- Box::new(zed_actions::OpenSettingsAt {- path: zed_actions::AGENT_SKILLS_SETTINGS_PATH- .to_string(),- target: target.clone(),- }),- cx,- );- })- .into_any_element()- },- ));- callout = callout- .description("Open Skills settings to review these warnings and manage skill descriptions in one place.")- .actions_slot(manage_buttons);- }- }+ .detach_and_log_err(cx);+ })+ .ok();+ }))+ .into_any_element()+ })+ .collect::<Vec<_>>();- let targets = description_warnings;- callouts.push(- callout.dismiss_action(- IconButton::new("dismiss-skill-description-warnings", IconName::Close)- .icon_size(IconSize::Small)- .icon_color(Color::Muted)- .tooltip(Tooltip::text("Dismiss"))- .on_click(cx.listener(move |this, _, _, cx| {- this.skill_loading_issues- .retain(|issue| !targets.contains(issue));- for target in &targets {- this.dismissed_skill_loading_issues.insert(target.clone());- }- cx.notify();- })),- ),+ let callout = Callout::new()+ .icon(IconName::Warning)+ .severity(Severity::Warning)+ .title(title)+ .description_slot(+ v_flex()+ .gap_1()+ .child(+ Label::new(format!(+ "Ensure skill descriptions are at most {MAX_SKILL_DESCRIPTION_LEN} bytes; longer ones may consume more model-context tokens."+ ))+ .size(LabelSize::Small)+ .color(Color::Muted),+ )+ .children(rows),);- }- callouts.extend(- self.skill_loading_issues- .iter()- .filter(|issue| issue.kind != SkillLoadingIssueKind::DescriptionTooLong)- .enumerate()- .map(|(index, issue)| {- let abs_path = issue.path.clone();- let workspace = self.workspace.clone();- let path_label = issue.path.display().to_string();- let target = issue.clone();- let title = match issue.kind {- SkillLoadingIssueKind::LoadFailed => "Skill failed to load",- SkillLoadingIssueKind::DescriptionTooLong => unreachable!(),- SkillLoadingIssueKind::CatalogBudgetExceeded => {- "Skill omitted from model catalog"- }- };- Callout::new()- .icon(IconName::Warning)- .severity(Severity::Warning)- .title(title)- .description(format!("{}\n{path_label}", issue.message))- .actions_slot(- Button::new(("open-skill-file", index), "Open File").on_click(- cx.listener(move |_, _, window, cx| {- let abs_path = abs_path.clone();- workspace- .update(cx, |workspace, cx| {- workspace- .open_abs_path(- abs_path,- workspace::OpenOptions::default(),- window,- cx,- )- .detach_and_log_err(cx);- })- .ok();- }),- ),- )- .dismiss_action(- IconButton::new(("dismiss-skill-issue", index), IconName::Close)- .icon_size(IconSize::Small)- .icon_color(Color::Muted)- .tooltip(Tooltip::text("Dismiss"))- .on_click(cx.listener(move |this, _, _, cx| {- this.skill_loading_issues.retain(|issue| *issue != target);- this.dismissed_skill_loading_issues.insert(target.clone());- cx.notify();- })),- )- }),- );+ let targets = description_warnings;- callouts+ Some(+ callout.dismiss_action(+ IconButton::new("dismiss-skill-description-warnings", IconName::Close)+ .icon_size(IconSize::Small)+ .tooltip(Tooltip::text("Dismiss"))+ .on_click(cx.listener(move |this, _, _, cx| {+ this.skill_loading_issues+ .retain(|issue| !targets.contains(issue));+ for target in &targets {+ this.dismissed_skill_loading_issues.insert(target.clone());+ }+ cx.notify();+ })),+ ),+ )}fn render_external_source_prompt_warning(&self, cx: &mut Context<Self>) -> Callout {Callout::new()+ .border_position(self.callout_border_position()).icon(IconName::Warning).severity(Severity::Warning)- .title("Review before sending")- .description("This prompt was pre-filled by an external link. Read it carefully before you send it.")+ .title("Review Before Sending")+ .description("This prompt was pre-filled by an external link. Read it carefully before you submit it to the model.").dismiss_action(IconButton::new("dismiss-external-source-prompt-warning", IconName::Close).icon_size(IconSize::Small)- .icon_color(Color::Muted).tooltip(Tooltip::text("Dismiss Warning")).on_click(cx.listener({move |this, _, _, cx| {@@ -10033,7 +9955,7 @@ impl ThreadView {"It currently only operates by default on \"{}\".",active_dir))- .border_position(ui::BorderPosition::Bottom)+ .border_position(self.callout_border_position()).dismiss_action(IconButton::new("dismiss-multi-root-callout", IconName::Close).icon_size(IconSize::Small)@@ -10050,9 +9972,9 @@ impl ThreadView {let server_view = self.server_view.clone();let has_version = !version.is_empty();let title = if has_version {- "New version available"+ "New Version Available"} else {- "Agent update available"+ "Agent Update Available"};let button_label = if has_version {format!("Update to v{}", version)@@ -10066,7 +9988,7 @@ impl ThreadView {.pr_3().w_full().gap_1p5()- .border_t_1()+ .border_b_1().border_color(cx.theme().colors().border).bg(cx.theme().colors().element_background).child(@@ -10131,6 +10053,7 @@ impl ThreadView {Some(Callout::new()+ .border_position(self.callout_border_position()).severity(severity).icon(icon).title(title)diff --git a/crates/debugger_ui/src/session/running/console.rs b/crates/debugger_ui/src/session/running/console.rsindex 910637343c0..fd1373ebf49 100644--- a/crates/debugger_ui/src/session/running/console.rs+++ b/crates/debugger_ui/src/session/running/console.rs@@ -652,6 +652,7 @@ impl ConsoleQueryBarCompletionProvider {match_start: None,snippet_deduplication_key: None,icon_path: None,+ icon_color: None,documentation: Some(CompletionDocumentation::MultiLineMarkdown(variable_value.into(),)),@@ -762,6 +763,7 @@ impl ConsoleQueryBarCompletionProvider {new_text,label: CodeLabel::plain(completion.label, None),icon_path: None,+ icon_color: None,documentation: completion.detail.map(|detail| {CompletionDocumentation::MultiLineMarkdown(detail.into())}),diff --git a/crates/edit_prediction_ui/src/rate_prediction_modal.rs b/crates/edit_prediction_ui/src/rate_prediction_modal.rsindex 3b9a80ea372..782fc93f996 100644--- a/crates/edit_prediction_ui/src/rate_prediction_modal.rs+++ b/crates/edit_prediction_ui/src/rate_prediction_modal.rs@@ -1375,6 +1375,7 @@ impl editor::CompletionProvider for FeedbackCompletionProvider {documentation: None,source: CompletionSource::Custom,icon_path: None,+ icon_color: None,match_start: None,snippet_deduplication_key: None,insert_text_mode: None,diff --git a/crates/editor/src/code_completion_tests.rs b/crates/editor/src/code_completion_tests.rsindex cf8023cad8e..babcbede3bc 100644--- a/crates/editor/src/code_completion_tests.rs+++ b/crates/editor/src/code_completion_tests.rs@@ -482,6 +482,7 @@ impl CompletionBuilder {resolved: false,},icon_path: None,+ icon_color: None,insert_text_mode: None,confirm: None,match_start: None,diff --git a/crates/editor/src/code_context_menus.rs b/crates/editor/src/code_context_menus.rsindex d515692a08f..25ac00a495c 100644--- a/crates/editor/src/code_context_menus.rs+++ b/crates/editor/src/code_context_menus.rs@@ -392,6 +392,7 @@ impl CompletionsMenu {match_start: None,snippet_deduplication_key: None,icon_path: None,+ icon_color: None,documentation: None,confirm: None,insert_text_mode: None,@@ -896,12 +897,7 @@ impl CompletionsMenu {let documentation = &completion.documentation;let mut len = completion.label.text.chars().count();- let show_completion_detail = show_completion_documentation- || matches!(- documentation,- Some(CompletionDocumentation::WarningAndMultiLinePlainText { .. })- );- if show_completion_detail {+ if show_completion_documentation {match documentation {Some(CompletionDocumentation::SingleLine(text)) => {len += text.chars().count();@@ -912,12 +908,6 @@ impl CompletionsMenu {}) => {len += single_line.chars().count();}- Some(CompletionDocumentation::WarningAndMultiLinePlainText {- warning,- ..- }) => {- len += warning.chars().count();- }_ => {}}}@@ -965,12 +955,7 @@ impl CompletionsMenu {};let completion = &completions_guard[mat.candidate_id];- let show_completion_detail = show_completion_documentation- || matches!(- completion.documentation.as_ref(),- Some(CompletionDocumentation::WarningAndMultiLinePlainText { .. })- );- let documentation = if show_completion_detail {+ let documentation = if show_completion_documentation {&completion.documentation} else {&None@@ -1085,32 +1070,10 @@ impl CompletionsMenu {Label::new(text.trim().to_string()).ml_4().size(LabelSize::Small)- .color(Color::Muted)- .into_any_element(),+ .color(Color::Muted),)}}- Some(CompletionDocumentation::WarningAndMultiLinePlainText {- warning,- ..- }) => {- let warning = warning.trim();- let mut label = h_flex().ml_4().gap_0p5().child(- Icon::new(IconName::Warning)- .size(IconSize::XSmall)- .color(Color::Warning),- );-- if !warning.is_empty() {- label = label.child(- Label::new(warning.to_string())- .size(LabelSize::Small)- .color(Color::Warning),- );- }-- Some(label.into_any_element())- }_ => None,};@@ -1128,7 +1091,11 @@ impl CompletionsMenu {completion.icon_path.as_ref().map(|path| {Icon::from_path(path).size(IconSize::XSmall)- .color(Color::Muted)+ .color(+ completion+ .icon_color+ .map_or(Color::Muted, Color::Custom),+ ).into_any_element()})});@@ -1192,7 +1159,7 @@ impl CompletionsMenu {this.child(div().truncate().child(suffix))}),)- .end_slot::<AnyElement>(documentation_label),+ .end_slot::<Label>(documentation_label),).into_any_element()})@@ -1244,10 +1211,6 @@ impl CompletionsMenu {Some(CompletionDocumentation::SingleLineAndMultiLinePlainText {plain_text: Some(text),..- })- | Some(CompletionDocumentation::WarningAndMultiLinePlainText {- plain_text: Some(text),- ..}) => div().child(text.clone()),Some(CompletionDocumentation::MultiLineMarkdown(source)) if !source.is_empty() => {let Some((false, markdown)) = self.get_or_create_markdown(@@ -1281,10 +1244,6 @@ impl CompletionsMenu {Some(CompletionDocumentation::SingleLineAndMultiLinePlainText {plain_text: None,..- })- | Some(CompletionDocumentation::WarningAndMultiLinePlainText {- plain_text: None,- ..}) => {return None;}diff --git a/crates/editor/src/completions.rs b/crates/editor/src/completions.rsindex 6ccb819f080..07ebf31457a 100644--- a/crates/editor/src/completions.rs+++ b/crates/editor/src/completions.rs@@ -591,6 +591,7 @@ impl Editor {match_start: None,snippet_deduplication_key: None,icon_path: None,+ icon_color: None,documentation: None,source: CompletionSource::BufferWord {word_range,@@ -1344,6 +1345,7 @@ fn snippet_completions(filter_range: 0..matching_prefix.len(),},icon_path: None,+ icon_color: None,documentation: Some(CompletionDocumentation::SingleLineAndMultiLinePlainText {single_line: snippet.name.clone().into(),plain_text: snippetdiff --git a/crates/editor/src/edit_prediction_tests.rs b/crates/editor/src/edit_prediction_tests.rsindex 80849c4b79d..24ac960b916 100644--- a/crates/editor/src/edit_prediction_tests.rs+++ b/crates/editor/src/edit_prediction_tests.rs@@ -1697,6 +1697,7 @@ impl CompletionProvider for FakeCompletionMenuProvider {documentation: None,source: CompletionSource::Custom,icon_path: None,+ icon_color: None,match_start: None,snippet_deduplication_key: None,insert_text_mode: None,diff --git a/crates/inspector_ui/src/div_inspector.rs b/crates/inspector_ui/src/div_inspector.rsindex 4c15196341e..aa930418bf9 100644--- a/crates/inspector_ui/src/div_inspector.rs+++ b/crates/inspector_ui/src/div_inspector.rs@@ -667,6 +667,7 @@ impl CompletionProvider for RustStyleCompletionProvider {match_start: None,snippet_deduplication_key: None,icon_path: None,+ icon_color: None,documentation: method.documentation.map(|documentation| {CompletionDocumentation::MultiLineMarkdown(documentation.into())}),diff --git a/crates/keymap_editor/src/action_completion_provider.rs b/crates/keymap_editor/src/action_completion_provider.rsindex 34324f9a337..849709b8ec6 100644--- a/crates/keymap_editor/src/action_completion_provider.rs+++ b/crates/keymap_editor/src/action_completion_provider.rs@@ -102,6 +102,7 @@ impl CompletionProvider for ActionCompletionProvider {documentation: None,source: project::CompletionSource::Custom,icon_path: None,+ icon_color: None,match_start: None,snippet_deduplication_key: None,insert_text_mode: None,diff --git a/crates/keymap_editor/src/keymap_editor.rs b/crates/keymap_editor/src/keymap_editor.rsindex 6677fe667dd..0bb66ab988c 100644--- a/crates/keymap_editor/src/keymap_editor.rs+++ b/crates/keymap_editor/src/keymap_editor.rs@@ -3515,6 +3515,7 @@ impl CompletionProvider for KeyContextCompletionProvider {documentation: None,source: project::CompletionSource::Custom,icon_path: None,+ icon_color: None,match_start: None,snippet_deduplication_key: None,insert_text_mode: None,diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rsindex 0f13f6633ca..e2b21ccdf51 100644--- a/crates/project/src/lsp_store.rs+++ b/crates/project/src/lsp_store.rs@@ -10994,6 +10994,7 @@ impl LspStore {snippet_deduplication_key: None,insert_text_mode: None,icon_path: None,+ icon_color: None,confirm: None,group: None,}]))),@@ -14142,6 +14143,7 @@ async fn populate_labels_for_completions(insert_text_mode: lsp_completion.insert_text_mode,source: completion.source,icon_path: None,+ icon_color: None,confirm: None,match_start: None,snippet_deduplication_key: None,@@ -14159,6 +14161,7 @@ async fn populate_labels_for_completions(source: completion.source,insert_text_mode: None,icon_path: None,+ icon_color: None,confirm: None,match_start: None,snippet_deduplication_key: None,@@ -14603,11 +14606,6 @@ pub enum CompletionDocumentation {single_line: SharedString,plain_text: Option<SharedString>,},- /// A warning label shown alongside multiple lines of plain text documentation.- WarningAndMultiLinePlainText {- warning: SharedString,- plain_text: Option<SharedString>,- },}impl CompletionDocumentation {@@ -14621,9 +14619,6 @@ impl CompletionDocumentation {CompletionDocumentation::SingleLineAndMultiLinePlainText { single_line, .. } => {single_line.clone()}- CompletionDocumentation::WarningAndMultiLinePlainText { warning, .. } => {- warning.clone()- }}}}diff --git a/crates/project/src/project.rs b/crates/project/src/project.rsindex cd6dc042ffb..d03b341a8ac 100644--- a/crates/project/src/project.rs+++ b/crates/project/src/project.rs@@ -557,6 +557,9 @@ pub struct Completion {pub source: CompletionSource,/// A path to an icon for this completion that is shown in the menu.pub icon_path: Option<SharedString>,+ /// An optional color to tint this completion's icon with in the menu.+ /// When `None`, the menu's default muted color is used.+ pub icon_color: Option<Hsla>,/// Text starting here and ending at the cursor will be used as the query for filtering this completion.////// If None, the start of the surrounding word is used.diff --git a/crates/settings_ui/src/pages/skills_setup.rs b/crates/settings_ui/src/pages/skills_setup.rsindex fbae3912c96..837f044bede 100644--- a/crates/settings_ui/src/pages/skills_setup.rs+++ b/crates/settings_ui/src/pages/skills_setup.rs@@ -1,12 +1,10 @@-use agent_skills::{MAX_SKILL_DESCRIPTION_LEN, Skill, SkillIndex, encode_skill_share_link};+use agent_skills::{Skill, SkillIndex, encode_skill_share_link};use fs::RemoveOptions;use gpui::{App, ClipboardItem, ScrollHandle, SharedString, prelude::*};use ui::{Divider, Tooltip, prelude::*};use util::ResultExt as _;-use std::borrow::Cow;-use crate::pages::SkillCreatorOpenMode;use crate::{SettingsUiFile, SettingsWindow};@@ -175,7 +173,19 @@ fn render_skill_row(.detach();}))})- .child(Label::new(skill.name.clone()));+ .child(Label::new(skill.name.clone()))+ .when_some(warning_message, |this, warning_message| {+ this.child(+ h_flex()+ .id(SharedString::from(format!("warning-{}", skill.name)))+ .child(+ Icon::new(IconName::Warning)+ .size(IconSize::XSmall)+ .color(Color::Warning),+ )+ .tooltip(Tooltip::text(warning_message)),+ )+ });h_flex().group(group)@@ -185,35 +195,12 @@ fn render_skill_row(.px_8().gap_4().child(- v_flex()- .gap_0p5()- .min_w_0()- .flex_1()- .child(title)- .when_some(warning_message, |this, warning_message| {- this.child(- h_flex()- .id(SharedString::from(format!("warning-{}", skill.name)))- .min_w_0()- .gap_1()- .items_start()- .child(- Icon::new(IconName::Warning)- .size(IconSize::XSmall)- .color(Color::Warning),- )- .child(- Label::new(warning_message)- .size(LabelSize::XSmall)- .color(Color::Warning),- ),- )- })- .child(- Label::new(truncated_skill_description(&skill.description))- .size(LabelSize::Small)- .color(Color::Muted),- ),+ v_flex().gap_0p5().min_w_0().flex_1().child(title).child(+ Label::new(skill.description.clone())+ .size(LabelSize::Small)+ .color(Color::Muted)+ .line_clamp(5),+ ),).child(h_flex()@@ -304,58 +291,3 @@ fn render_skill_row().into_any_element()}--fn truncated_skill_description(description: &str) -> Cow<'_, str> {- if description.len() <= MAX_SKILL_DESCRIPTION_LEN {- return Cow::Borrowed(description);- }-- let mut end = MAX_SKILL_DESCRIPTION_LEN;- while !description.is_char_boundary(end) {- end -= 1;- }- let hidden_bytes = description.len() - end;- let truncated = &description[..end];- if hidden_bytes > 100 {- Cow::Owned(format!("{truncated}... ({hidden_bytes} bytes not shown)"))- } else {- Cow::Owned(format!("{truncated}..."))- }-}--#[cfg(test)]-mod tests {- use super::*;-- #[test]- fn truncated_skill_description_preserves_char_boundaries() {- let mut description = "a".repeat(MAX_SKILL_DESCRIPTION_LEN - 1);- description.push('é');-- let truncated = truncated_skill_description(&description);-- assert!(truncated.starts_with(&"a".repeat(MAX_SKILL_DESCRIPTION_LEN - 1)));- assert!(truncated.ends_with("..."));- }-- #[test]- fn truncated_skill_description_leaves_short_descriptions_untouched() {- let description = "a".repeat(MAX_SKILL_DESCRIPTION_LEN);- assert_eq!(truncated_skill_description(&description), description);- }-- #[test]- fn truncated_skill_description_reports_hidden_bytes_over_100() {- let description = "a".repeat(MAX_SKILL_DESCRIPTION_LEN + 101);- let truncated = truncated_skill_description(&description);- assert!(truncated.ends_with("... (101 bytes not shown)"));- }-- #[test]- fn truncated_skill_description_omits_byte_count_at_or_under_100() {- let description = "a".repeat(MAX_SKILL_DESCRIPTION_LEN + 100);- let truncated = truncated_skill_description(&description);- assert!(truncated.ends_with("..."));- assert!(!truncated.contains("not shown"));- }-}diff --git a/crates/ui/src/components/callout.rs b/crates/ui/src/components/callout.rsindex 9a897df1ac4..d270aa19f81 100644--- a/crates/ui/src/components/callout.rs+++ b/crates/ui/src/components/callout.rs@@ -3,7 +3,7 @@ use gpui::AnyElement;use crate::prelude::*;#[derive(Debug, Clone, Copy, PartialEq, Eq)]-pub enum BorderPosition {+pub enum CalloutBorderPosition {Top,Bottom,}@@ -34,7 +34,7 @@ pub struct Callout {actions_slot: Option<AnyElement>,dismiss_action: Option<AnyElement>,line_height: Option<Pixels>,- border_position: BorderPosition,+ border_position: CalloutBorderPosition,}impl Callout {@@ -49,7 +49,7 @@ impl Callout {actions_slot: None,dismiss_action: None,line_height: None,- border_position: BorderPosition::Top,+ border_position: CalloutBorderPosition::Top,}}@@ -105,7 +105,7 @@ impl Callout {}/// Sets the border position in the callout.- pub fn border_position(mut self, border_position: BorderPosition) -> Self {+ pub fn border_position(mut self, border_position: CalloutBorderPosition) -> Self {self.border_position = border_position;self}@@ -147,8 +147,8 @@ impl RenderOnce for Callout {.gap_2().items_start().map(|this| match self.border_position {- BorderPosition::Top => this.border_t_1(),- BorderPosition::Bottom => this.border_b_1(),+ CalloutBorderPosition::Top => this.border_t_1(),+ CalloutBorderPosition::Bottom => this.border_b_1(),}).border_color(cx.theme().colors().border).bg(bg_color)diff --git a/crates/ui/src/components/label/label.rs b/crates/ui/src/components/label/label.rsindex 370c9166c36..8b98817b050 100644--- a/crates/ui/src/components/label/label.rs+++ b/crates/ui/src/components/label/label.rs@@ -73,6 +73,13 @@ impl Label {self.base = self.base.truncate_start();self}++ /// Wraps the text and truncates it with an ellipsis (`…`) at the end of+ /// the last visible line if it exceeds the given number of lines.+ pub fn line_clamp(mut self, lines: usize) -> Self {+ self.base = self.base.line_clamp(lines);+ self+ }}// Style methods.diff --git a/crates/ui/src/components/label/label_like.rs b/crates/ui/src/components/label/label_like.rsindex 27eb9e797fa..4218c5d1fe7 100644--- a/crates/ui/src/components/label/label_like.rs+++ b/crates/ui/src/components/label/label_like.rs@@ -134,6 +134,15 @@ impl LabelLike {self.truncate_start = true;self}++ /// Wraps the text and truncates it with an ellipsis (`…`) at the end of+ /// the last visible line if it exceeds the given number of lines.+ pub fn line_clamp(mut self, lines: usize) -> Self {+ // `line_clamp` alone hard-cuts the text; the ellipsis on the last+ // visible line is only rendered when a text overflow style is set.+ self.base = self.base.line_clamp(lines).text_ellipsis();+ self+ }}impl LabelCommon for LabelLike {