From 2f812c339c1e1f01a3c04d38ca5190520df73c85 Mon Sep 17 00:00:00 2001 From: Umesh Yadav <23421535+imumesh18@users.noreply.github.com> Date: Fri, 25 Jul 2025 22:25:38 +0530 Subject: [PATCH] agent_ui: Fix delay when loading keybindings in the Agent panel settings (#34954) Fixes a annoying lag in agent settings panel where the keybindings would show up after a lag. Close to 1-2 secs. It was a simple fix previously we were not passing the focus handler to context menu which made the keybindings lookup slower compared to other parts like git panel and title bar profile dropdown. | Before | After | |--------|--------| | | | Release Notes: - Fix delay when loading keybindings in the Agent panel settings --- crates/agent_ui/src/agent_panel.rs | 116 +++++++++++++++-------------- 1 file changed, 60 insertions(+), 56 deletions(-) diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs index 4b3db4bc1df00466291c69be89b4edba90ccedc2..43c1167af80cd35a48f340ded8933fda3f4e6175 100644 --- a/crates/agent_ui/src/agent_panel.rs +++ b/crates/agent_ui/src/agent_panel.rs @@ -2016,65 +2016,69 @@ impl AgentPanel { ) .anchor(Corner::TopRight) .with_handle(self.agent_panel_menu_handle.clone()) - .menu(move |window, cx| { - Some(ContextMenu::build(window, cx, |mut menu, _window, _| { - if let Some(usage) = usage { - menu = menu - .header_with_link("Prompt Usage", "Manage", account_url.clone()) - .custom_entry( - move |_window, cx| { - let used_percentage = match usage.limit { - UsageLimit::Limited(limit) => { - Some((usage.amount as f32 / limit as f32) * 100.) - } - UsageLimit::Unlimited => None, - }; + .menu({ + let focus_handle = focus_handle.clone(); + move |window, cx| { + Some(ContextMenu::build(window, cx, |mut menu, _window, _| { + menu = menu.context(focus_handle.clone()); + if let Some(usage) = usage { + menu = menu + .header_with_link("Prompt Usage", "Manage", account_url.clone()) + .custom_entry( + move |_window, cx| { + let used_percentage = match usage.limit { + UsageLimit::Limited(limit) => { + Some((usage.amount as f32 / limit as f32) * 100.) + } + UsageLimit::Unlimited => None, + }; + + h_flex() + .flex_1() + .gap_1p5() + .children(used_percentage.map(|percent| { + ProgressBar::new("usage", percent, 100., cx) + })) + .child( + Label::new(match usage.limit { + UsageLimit::Limited(limit) => { + format!("{} / {limit}", usage.amount) + } + UsageLimit::Unlimited => { + format!("{} / ∞", usage.amount) + } + }) + .size(LabelSize::Small) + .color(Color::Muted), + ) + .into_any_element() + }, + move |_, cx| cx.open_url(&zed_urls::account_url(cx)), + ) + .separator() + } - h_flex() - .flex_1() - .gap_1p5() - .children(used_percentage.map(|percent| { - ProgressBar::new("usage", percent, 100., cx) - })) - .child( - Label::new(match usage.limit { - UsageLimit::Limited(limit) => { - format!("{} / {limit}", usage.amount) - } - UsageLimit::Unlimited => { - format!("{} / ∞", usage.amount) - } - }) - .size(LabelSize::Small) - .color(Color::Muted), - ) - .into_any_element() - }, - move |_, cx| cx.open_url(&zed_urls::account_url(cx)), + menu = menu + .header("MCP Servers") + .action( + "View Server Extensions", + Box::new(zed_actions::Extensions { + category_filter: Some( + zed_actions::ExtensionCategoryFilter::ContextServers, + ), + id: None, + }), ) - .separator() - } + .action("Add Custom Server…", Box::new(AddContextServer)) + .separator(); - menu = menu - .header("MCP Servers") - .action( - "View Server Extensions", - Box::new(zed_actions::Extensions { - category_filter: Some( - zed_actions::ExtensionCategoryFilter::ContextServers, - ), - id: None, - }), - ) - .action("Add Custom Server…", Box::new(AddContextServer)) - .separator(); - - menu = menu - .action("Rules…", Box::new(OpenRulesLibrary::default())) - .action("Settings", Box::new(OpenConfiguration)) - .action(zoom_in_label, Box::new(ToggleZoom)); - menu - })) + menu = menu + .action("Rules…", Box::new(OpenRulesLibrary::default())) + .action("Settings", Box::new(OpenConfiguration)) + .action(zoom_in_label, Box::new(ToggleZoom)); + menu + })) + } }); h_flex()