agent: Improve AddSelectionToThread action display (#42280)
Closes https://github.com/zed-industries/zed/issues/42276 This fixes the fact that the `AddSelectionToThread` action was visible when `disable_ai` was true, as well as it improves its display by making it either disabled or hidden when there are no selections in the editor. I also ended up removing it from the app menu simply because making it observe the `disable_ai` setting would be a bit more complex than I'd like at the moment, so figured that, given I'm also now adding it to the toolbar selection menu, we could do without it over there. Release Notes: - Fixed the `AddSelectionToThread` action showing up when `disable_ai` is true - Improved the `AddSelectionToThread` action display by only making it available when there are selections in the editor
This commit is contained in:
@@ -8,6 +8,8 @@ use crate::{
|
||||
};
|
||||
use gpui::prelude::FluentBuilder;
|
||||
use gpui::{Context, DismissEvent, Entity, Focusable as _, Pixels, Point, Subscription, Window};
|
||||
use project::DisableAiSettings;
|
||||
use settings::Settings;
|
||||
use std::ops::Range;
|
||||
use text::PointUtf16;
|
||||
use workspace::OpenInTerminal;
|
||||
@@ -202,6 +204,7 @@ pub fn deploy_context_menu(
|
||||
|
||||
let evaluate_selection = window.is_action_available(&EvaluateSelectedText, cx);
|
||||
let run_to_cursor = window.is_action_available(&RunToCursor, cx);
|
||||
let disable_ai = DisableAiSettings::get_global(cx).disable_ai;
|
||||
|
||||
ui::ContextMenu::build(window, cx, |menu, _window, _cx| {
|
||||
let builder = menu
|
||||
@@ -234,7 +237,9 @@ pub fn deploy_context_menu(
|
||||
quick_launch: false,
|
||||
}),
|
||||
)
|
||||
.action("Add to Agent Thread", Box::new(AddSelectionToThread))
|
||||
.when(!disable_ai && has_selections, |this| {
|
||||
this.action("Add to Agent Thread", Box::new(AddSelectionToThread))
|
||||
})
|
||||
.separator()
|
||||
.action("Cut", Box::new(Cut))
|
||||
.action("Copy", Box::new(Copy))
|
||||
|
||||
Reference in New Issue
Block a user