mirror of
https://github.com/zed-industries/zed.git
synced 2026-05-31 19:05:00 +07:00
agent_ui: Remove count for user rules in context tooltip (#57456)
Some checks are pending
Congratsbot / check-author (push) Waiting to run
Congratsbot / congrats (push) Blocked by required conditions
run_tests / orchestrate (push) Waiting to run
run_tests / check_style (push) Waiting to run
run_tests / clippy_windows (push) Blocked by required conditions
run_tests / clippy_linux (push) Blocked by required conditions
run_tests / clippy_mac (push) Blocked by required conditions
run_tests / clippy_mac_x86_64 (push) Blocked by required conditions
run_tests / run_tests_windows (push) Blocked by required conditions
run_tests / run_tests_linux (push) Blocked by required conditions
run_tests / run_tests_mac (push) Blocked by required conditions
run_tests / miri_scheduler (push) Blocked by required conditions
run_tests / doctests (push) Blocked by required conditions
run_tests / check_workspace_binaries (push) Blocked by required conditions
run_tests / build_visual_tests_binary (push) Blocked by required conditions
run_tests / check_wasm (push) Blocked by required conditions
run_tests / check_dependencies (push) Blocked by required conditions
run_tests / check_docs (push) Blocked by required conditions
run_tests / check_licenses (push) Blocked by required conditions
run_tests / check_scripts (push) Blocked by required conditions
run_tests / check_postgres_and_protobuf_migrations (push) Blocked by required conditions
run_tests / extension_tests (push) Blocked by required conditions
run_tests / tests_pass (push) Blocked by required conditions
deploy_nightly_docs / deploy_docs (push) Has been skipped
Some checks are pending
Congratsbot / check-author (push) Waiting to run
Congratsbot / congrats (push) Blocked by required conditions
run_tests / orchestrate (push) Waiting to run
run_tests / check_style (push) Waiting to run
run_tests / clippy_windows (push) Blocked by required conditions
run_tests / clippy_linux (push) Blocked by required conditions
run_tests / clippy_mac (push) Blocked by required conditions
run_tests / clippy_mac_x86_64 (push) Blocked by required conditions
run_tests / run_tests_windows (push) Blocked by required conditions
run_tests / run_tests_linux (push) Blocked by required conditions
run_tests / run_tests_mac (push) Blocked by required conditions
run_tests / miri_scheduler (push) Blocked by required conditions
run_tests / doctests (push) Blocked by required conditions
run_tests / check_workspace_binaries (push) Blocked by required conditions
run_tests / build_visual_tests_binary (push) Blocked by required conditions
run_tests / check_wasm (push) Blocked by required conditions
run_tests / check_dependencies (push) Blocked by required conditions
run_tests / check_docs (push) Blocked by required conditions
run_tests / check_licenses (push) Blocked by required conditions
run_tests / check_scripts (push) Blocked by required conditions
run_tests / check_postgres_and_protobuf_migrations (push) Blocked by required conditions
run_tests / extension_tests (push) Blocked by required conditions
run_tests / tests_pass (push) Blocked by required conditions
deploy_nightly_docs / deploy_docs (push) Has been skipped
The circular progress in the agent panel's message editor would previously display the number of default user rules auto-embedded into the thread. However, given default rules are all migrated to a global AGENTS.md file, that feature doesn't make a lot of sense anymore. So, this PR fixes it by adding a button that opens up the global file when it exists. Release Notes: - N/A
This commit is contained in:
parent
d5cf9a65d2
commit
e2a1c4ce0c
1 changed files with 43 additions and 36 deletions
|
|
@ -8,7 +8,7 @@ use agent_client_protocol::schema as acp;
|
|||
use std::cell::RefCell;
|
||||
|
||||
use acp_thread::{ContentBlock, PlanEntry};
|
||||
use agent::{SkillLoadingError, SkillLoadingErrorsUpdated};
|
||||
use agent::{SkillLoadingError, SkillLoadingErrorsUpdated, UserAgentsMd};
|
||||
use cloud_api_types::{SubmitAgentThreadFeedbackBody, SubmitAgentThreadFeedbackCommentsBody};
|
||||
use editor::actions::OpenExcerpts;
|
||||
use feature_flags::AcpBetaFeatureFlag;
|
||||
|
|
@ -3632,12 +3632,10 @@ impl ThreadView {
|
|||
|
||||
let tooltip_separator_color = Color::Custom(cx.theme().colors().text_disabled.opacity(0.6));
|
||||
|
||||
let (user_rules_count, first_user_rules_id, project_rules_count, project_entry_ids) = self
|
||||
let (project_rules_count, project_entry_ids) = self
|
||||
.as_native_thread(cx)
|
||||
.map(|thread| {
|
||||
let project_context = thread.read(cx).project_context().read(cx);
|
||||
let user_rules_count = project_context.user_rules.len();
|
||||
let first_user_rules_id = project_context.user_rules.first().map(|r| r.uuid.0);
|
||||
let project_entry_ids = project_context
|
||||
.worktrees
|
||||
.iter()
|
||||
|
|
@ -3645,15 +3643,14 @@ impl ThreadView {
|
|||
.map(|rf| ProjectEntryId::from_usize(rf.project_entry_id))
|
||||
.collect::<Vec<_>>();
|
||||
let project_rules_count = project_entry_ids.len();
|
||||
(
|
||||
user_rules_count,
|
||||
first_user_rules_id,
|
||||
project_rules_count,
|
||||
project_entry_ids,
|
||||
)
|
||||
(project_rules_count, project_entry_ids)
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
let global_agents_md_loaded = UserAgentsMd::global(cx)
|
||||
.and_then(|md| md.content())
|
||||
.is_some();
|
||||
|
||||
let workspace = self.workspace.clone();
|
||||
|
||||
let max_output_tokens = self
|
||||
|
|
@ -3688,8 +3685,7 @@ impl ThreadView {
|
|||
show_split,
|
||||
cost_label,
|
||||
separator_color: tooltip_separator_color,
|
||||
user_rules_count,
|
||||
first_user_rules_id,
|
||||
global_agents_md_loaded,
|
||||
project_rules_count,
|
||||
project_entry_ids,
|
||||
workspace,
|
||||
|
|
@ -4383,8 +4379,7 @@ struct TokenUsageTooltip {
|
|||
show_split: bool,
|
||||
cost_label: Option<String>,
|
||||
separator_color: Color,
|
||||
user_rules_count: usize,
|
||||
first_user_rules_id: Option<uuid::Uuid>,
|
||||
global_agents_md_loaded: bool,
|
||||
project_rules_count: usize,
|
||||
project_entry_ids: Vec<ProjectEntryId>,
|
||||
workspace: WeakEntity<Workspace>,
|
||||
|
|
@ -4402,8 +4397,7 @@ impl Render for TokenUsageTooltip {
|
|||
let output_max = self.output_max.clone();
|
||||
let show_split = self.show_split;
|
||||
let cost_label = self.cost_label.clone();
|
||||
let user_rules_count = self.user_rules_count;
|
||||
let first_user_rules_id = self.first_user_rules_id;
|
||||
let global_agents_md_loaded = self.global_agents_md_loaded;
|
||||
let project_rules_count = self.project_rules_count;
|
||||
let project_entry_ids = self.project_entry_ids.clone();
|
||||
let workspace = self.workspace.clone();
|
||||
|
|
@ -4466,7 +4460,7 @@ impl Render for TokenUsageTooltip {
|
|||
)
|
||||
})
|
||||
.when(
|
||||
user_rules_count > 0 || project_rules_count > 0,
|
||||
global_agents_md_loaded || project_rules_count > 0,
|
||||
move |this| {
|
||||
this.child(
|
||||
v_flex()
|
||||
|
|
@ -4484,26 +4478,39 @@ impl Render for TokenUsageTooltip {
|
|||
.child(
|
||||
v_flex()
|
||||
.mx_neg_1()
|
||||
.when(user_rules_count > 0, move |this| {
|
||||
this.child(
|
||||
Button::new(
|
||||
"open-user-rules",
|
||||
format!("{} user rules", user_rules_count),
|
||||
.when(global_agents_md_loaded, {
|
||||
let workspace = workspace.clone();
|
||||
move |this| {
|
||||
this.child(
|
||||
Button::new(
|
||||
"open-global-agents-md",
|
||||
"1 global rule",
|
||||
)
|
||||
.end_icon(
|
||||
Icon::new(IconName::ArrowUpRight)
|
||||
.color(Color::Muted)
|
||||
.size(IconSize::XSmall),
|
||||
)
|
||||
.on_click(move |_, window, cx| {
|
||||
workspace
|
||||
.update(cx, |workspace, cx| {
|
||||
workspace
|
||||
.open_abs_path(
|
||||
paths::agents_file()
|
||||
.clone(),
|
||||
workspace::OpenOptions {
|
||||
focus: Some(true),
|
||||
..Default::default()
|
||||
},
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
.detach_and_log_err(cx);
|
||||
})
|
||||
.log_err();
|
||||
}),
|
||||
)
|
||||
.end_icon(
|
||||
Icon::new(IconName::ArrowUpRight)
|
||||
.color(Color::Muted)
|
||||
.size(IconSize::XSmall),
|
||||
)
|
||||
.on_click(move |_, window, cx| {
|
||||
window.dispatch_action(
|
||||
Box::new(OpenRulesLibrary {
|
||||
prompt_to_select: first_user_rules_id,
|
||||
}),
|
||||
cx,
|
||||
);
|
||||
}),
|
||||
)
|
||||
}
|
||||
})
|
||||
.when(project_rules_count > 0, move |this| {
|
||||
let workspace = workspace.clone();
|
||||
|
|
|
|||
Loading…
Reference in a new issue