1mod agent_configuration;
2pub(crate) mod agent_connection_store;
3mod agent_diff;
4mod agent_model_selector;
5mod agent_panel;
6mod agent_registry_ui;
7mod branch_names;
8mod buffer_codegen;
9mod completion_provider;
10mod config_options;
11mod context;
12mod context_server_configuration;
13pub(crate) mod conversation_view;
14mod entry_view_state;
15mod external_source_prompt;
16mod favorite_models;
17mod inline_assistant;
18mod inline_prompt_editor;
19mod language_model_selector;
20mod mention_set;
21mod message_editor;
22mod mode_selector;
23mod model_selector;
24mod model_selector_popover;
25mod profile_selector;
26mod slash_command;
27mod slash_command_picker;
28mod terminal_codegen;
29mod terminal_inline_assistant;
30#[cfg(any(test, feature = "test-support"))]
31pub mod test_support;
32mod text_thread_editor;
33mod text_thread_history;
34mod thread_history;
35mod thread_history_view;
36pub mod thread_metadata_store;
37pub mod threads_archive_view;
38mod ui;
39
40use std::rc::Rc;
41use std::sync::Arc;
42
43use agent_client_protocol as acp;
44use agent_settings::{AgentProfileId, AgentSettings};
45use assistant_slash_command::SlashCommandRegistry;
46use client::Client;
47use command_palette_hooks::CommandPaletteFilter;
48use feature_flags::{AgentV2FeatureFlag, FeatureFlagAppExt as _};
49use fs::Fs;
50use gpui::{Action, App, Context, Entity, SharedString, Window, actions};
51use language::{
52 LanguageRegistry,
53 language_settings::{AllLanguageSettings, EditPredictionProvider},
54};
55use language_model::{
56 ConfiguredModel, LanguageModelId, LanguageModelProviderId, LanguageModelRegistry,
57};
58use project::{AgentId, DisableAiSettings};
59use prompt_store::PromptBuilder;
60use schemars::JsonSchema;
61use serde::{Deserialize, Serialize};
62use settings::{LanguageModelSelection, Settings as _, SettingsStore};
63use std::any::TypeId;
64use workspace::Workspace;
65
66use crate::agent_configuration::{ConfigureContextServerModal, ManageProfilesModal};
67pub use crate::agent_panel::{
68 AgentPanel, AgentPanelEvent, ConcreteAssistantPanelDelegate, WorktreeCreationStatus,
69};
70use crate::agent_registry_ui::AgentRegistryPage;
71pub use crate::inline_assistant::InlineAssistant;
72pub use agent_diff::{AgentDiffPane, AgentDiffToolbar};
73pub(crate) use conversation_view::ConversationView;
74pub use external_source_prompt::ExternalSourcePrompt;
75pub(crate) use mode_selector::ModeSelector;
76pub(crate) use model_selector::ModelSelector;
77pub(crate) use model_selector_popover::ModelSelectorPopover;
78pub use text_thread_editor::{AgentPanelDelegate, TextThreadEditor};
79pub(crate) use thread_history::ThreadHistory;
80pub(crate) use thread_history_view::*;
81use zed_actions;
82
83actions!(
84 agent,
85 [
86 /// Creates a new text-based conversation thread.
87 NewTextThread,
88 /// Toggles the menu to create new agent threads.
89 ToggleNewThreadMenu,
90 /// Cycles through the options for where new threads start (current project or new worktree).
91 CycleStartThreadIn,
92 /// Toggles the navigation menu for switching between threads and views.
93 ToggleNavigationMenu,
94 /// Toggles the options menu for agent settings and preferences.
95 ToggleOptionsMenu,
96 /// Toggles the profile or mode selector for switching between agent profiles.
97 ToggleProfileSelector,
98 /// Cycles through available session modes.
99 CycleModeSelector,
100 /// Cycles through favorited models in the ACP model selector.
101 CycleFavoriteModels,
102 /// Expands the message editor to full size.
103 ExpandMessageEditor,
104 /// Removes all thread history.
105 RemoveHistory,
106 /// Opens the conversation history view.
107 OpenHistory,
108 /// Adds a context server to the configuration.
109 AddContextServer,
110 /// Removes the currently selected thread.
111 RemoveSelectedThread,
112 /// Starts a chat conversation with follow-up enabled.
113 ChatWithFollow,
114 /// Cycles to the next inline assist suggestion.
115 CycleNextInlineAssist,
116 /// Cycles to the previous inline assist suggestion.
117 CyclePreviousInlineAssist,
118 /// Moves focus up in the interface.
119 FocusUp,
120 /// Moves focus down in the interface.
121 FocusDown,
122 /// Moves focus left in the interface.
123 FocusLeft,
124 /// Moves focus right in the interface.
125 FocusRight,
126 /// Opens the active thread as a markdown file.
127 OpenActiveThreadAsMarkdown,
128 /// Opens the agent diff view to review changes.
129 OpenAgentDiff,
130 /// Copies the current thread to the clipboard as JSON for debugging.
131 CopyThreadToClipboard,
132 /// Loads a thread from the clipboard JSON for debugging.
133 LoadThreadFromClipboard,
134 /// Keeps the current suggestion or change.
135 Keep,
136 /// Rejects the current suggestion or change.
137 Reject,
138 /// Rejects all suggestions or changes.
139 RejectAll,
140 /// Undoes the most recent reject operation, restoring the rejected changes.
141 UndoLastReject,
142 /// Keeps all suggestions or changes.
143 KeepAll,
144 /// Allow this operation only this time.
145 AllowOnce,
146 /// Allow this operation and remember the choice.
147 AllowAlways,
148 /// Reject this operation only this time.
149 RejectOnce,
150 /// Follows the agent's suggestions.
151 Follow,
152 /// Resets the trial upsell notification.
153 ResetTrialUpsell,
154 /// Resets the trial end upsell notification.
155 ResetTrialEndUpsell,
156 /// Opens the "Add Context" menu in the message editor.
157 OpenAddContextMenu,
158 /// Continues the current thread.
159 ContinueThread,
160 /// Interrupts the current generation and sends the message immediately.
161 SendImmediately,
162 /// Sends the next queued message immediately.
163 SendNextQueuedMessage,
164 /// Removes the first message from the queue (the next one to be sent).
165 RemoveFirstQueuedMessage,
166 /// Edits the first message in the queue (the next one to be sent).
167 EditFirstQueuedMessage,
168 /// Clears all messages from the queue.
169 ClearMessageQueue,
170 /// Opens the permission granularity dropdown for the current tool call.
171 OpenPermissionDropdown,
172 /// Toggles thinking mode for models that support extended thinking.
173 ToggleThinkingMode,
174 /// Cycles through available thinking effort levels for the current model.
175 CycleThinkingEffort,
176 /// Toggles the thinking effort selector menu open or closed.
177 ToggleThinkingEffortMenu,
178 /// Toggles fast mode for models that support it.
179 ToggleFastMode,
180 ]
181);
182
183/// Action to authorize a tool call with a specific permission option.
184/// This is used by the permission granularity dropdown to authorize tool calls.
185#[derive(Clone, PartialEq, Deserialize, JsonSchema, Action)]
186#[action(namespace = agent)]
187#[serde(deny_unknown_fields)]
188pub struct AuthorizeToolCall {
189 /// The tool call ID to authorize.
190 pub tool_call_id: String,
191 /// The permission option ID to use.
192 pub option_id: String,
193 /// The kind of permission option (serialized as string).
194 pub option_kind: String,
195}
196
197/// Creates a new conversation thread, optionally based on an existing thread.
198#[derive(Default, Clone, PartialEq, Deserialize, JsonSchema, Action)]
199#[action(namespace = agent)]
200#[serde(deny_unknown_fields)]
201pub struct NewThread;
202
203/// Creates a new external agent conversation thread.
204#[derive(Default, Clone, PartialEq, Deserialize, JsonSchema, Action)]
205#[action(namespace = agent)]
206#[serde(deny_unknown_fields)]
207pub struct NewExternalAgentThread {
208 /// Which agent to use for the conversation.
209 agent: Option<Agent>,
210}
211
212#[derive(Clone, PartialEq, Deserialize, JsonSchema, Action)]
213#[action(namespace = agent)]
214#[serde(deny_unknown_fields)]
215pub struct NewNativeAgentThreadFromSummary {
216 from_session_id: agent_client_protocol::SessionId,
217}
218
219// TODO unify this with AgentType
220#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]
221#[serde(rename_all = "snake_case")]
222pub enum Agent {
223 NativeAgent,
224 Custom {
225 #[serde(rename = "name")]
226 id: AgentId,
227 },
228}
229
230impl Agent {
231 pub fn id(&self) -> AgentId {
232 match self {
233 Self::NativeAgent => agent::ZED_AGENT_ID.clone(),
234 Self::Custom { id } => id.clone(),
235 }
236 }
237
238 pub fn server(
239 &self,
240 fs: Arc<dyn fs::Fs>,
241 thread_store: Entity<agent::ThreadStore>,
242 ) -> Rc<dyn agent_servers::AgentServer> {
243 match self {
244 Self::NativeAgent => Rc::new(agent::NativeAgentServer::new(fs, thread_store)),
245 Self::Custom { id: name } => {
246 Rc::new(agent_servers::CustomAgentServer::new(name.clone()))
247 }
248 }
249 }
250}
251
252/// Sets where new threads will run.
253#[derive(
254 Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Action,
255)]
256#[action(namespace = agent)]
257#[serde(rename_all = "snake_case", tag = "kind")]
258pub enum StartThreadIn {
259 #[default]
260 LocalProject,
261 NewWorktree,
262}
263
264/// Content to initialize new external agent with.
265pub enum AgentInitialContent {
266 ThreadSummary {
267 session_id: acp::SessionId,
268 title: Option<SharedString>,
269 },
270 ContentBlock {
271 blocks: Vec<agent_client_protocol::ContentBlock>,
272 auto_submit: bool,
273 },
274 FromExternalSource(ExternalSourcePrompt),
275}
276
277impl From<ExternalSourcePrompt> for AgentInitialContent {
278 fn from(prompt: ExternalSourcePrompt) -> Self {
279 Self::FromExternalSource(prompt)
280 }
281}
282
283/// Opens the profile management interface for configuring agent tools and settings.
284#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
285#[action(namespace = agent)]
286#[serde(deny_unknown_fields)]
287pub struct ManageProfiles {
288 #[serde(default)]
289 pub customize_tools: Option<AgentProfileId>,
290}
291
292impl ManageProfiles {
293 pub fn customize_tools(profile_id: AgentProfileId) -> Self {
294 Self {
295 customize_tools: Some(profile_id),
296 }
297 }
298}
299
300#[derive(Clone)]
301pub(crate) enum ModelUsageContext {
302 InlineAssistant,
303}
304
305impl ModelUsageContext {
306 pub fn configured_model(&self, cx: &App) -> Option<ConfiguredModel> {
307 match self {
308 Self::InlineAssistant => {
309 LanguageModelRegistry::read_global(cx).inline_assistant_model()
310 }
311 }
312 }
313}
314
315/// Initializes the `agent` crate.
316pub fn init(
317 fs: Arc<dyn Fs>,
318 client: Arc<Client>,
319 prompt_builder: Arc<PromptBuilder>,
320 language_registry: Arc<LanguageRegistry>,
321 is_eval: bool,
322 cx: &mut App,
323) {
324 agent::ThreadStore::init_global(cx);
325 assistant_text_thread::init(client, cx);
326 rules_library::init(cx);
327 if !is_eval {
328 // Initializing the language model from the user settings messes with the eval, so we only initialize them when
329 // we're not running inside of the eval.
330 init_language_model_settings(cx);
331 }
332 assistant_slash_command::init(cx);
333 agent_panel::init(cx);
334 context_server_configuration::init(language_registry.clone(), fs.clone(), cx);
335 TextThreadEditor::init(cx);
336 thread_metadata_store::init(cx);
337
338 register_slash_commands(cx);
339 inline_assistant::init(fs.clone(), prompt_builder.clone(), cx);
340 terminal_inline_assistant::init(fs.clone(), prompt_builder, cx);
341 cx.observe_new(move |workspace, window, cx| {
342 ConfigureContextServerModal::register(workspace, language_registry.clone(), window, cx)
343 })
344 .detach();
345 cx.observe_new(|workspace: &mut Workspace, _window, _cx| {
346 workspace.register_action(
347 move |workspace: &mut Workspace,
348 _: &zed_actions::AcpRegistry,
349 window: &mut Window,
350 cx: &mut Context<Workspace>| {
351 let existing = workspace
352 .active_pane()
353 .read(cx)
354 .items()
355 .find_map(|item| item.downcast::<AgentRegistryPage>());
356
357 if let Some(existing) = existing {
358 existing.update(cx, |_, cx| {
359 project::AgentRegistryStore::global(cx)
360 .update(cx, |store, cx| store.refresh(cx));
361 });
362 workspace.activate_item(&existing, true, true, window, cx);
363 } else {
364 let registry_page = AgentRegistryPage::new(workspace, window, cx);
365 workspace.add_item_to_active_pane(
366 Box::new(registry_page),
367 None,
368 true,
369 window,
370 cx,
371 );
372 }
373 },
374 );
375 })
376 .detach();
377 cx.observe_new(ManageProfilesModal::register).detach();
378
379 // Update command palette filter based on AI settings
380 update_command_palette_filter(cx);
381
382 // Watch for settings changes
383 cx.observe_global::<SettingsStore>(|app_cx| {
384 // When settings change, update the command palette filter
385 update_command_palette_filter(app_cx);
386 })
387 .detach();
388
389 cx.on_flags_ready(|_, cx| {
390 update_command_palette_filter(cx);
391 })
392 .detach();
393}
394
395fn update_command_palette_filter(cx: &mut App) {
396 let disable_ai = DisableAiSettings::get_global(cx).disable_ai;
397 let agent_enabled = AgentSettings::get_global(cx).enabled;
398 let agent_v2_enabled = cx.has_flag::<AgentV2FeatureFlag>();
399 let edit_prediction_provider = AllLanguageSettings::get_global(cx)
400 .edit_predictions
401 .provider;
402
403 CommandPaletteFilter::update_global(cx, |filter, _| {
404 use editor::actions::{
405 AcceptEditPrediction, AcceptNextLineEditPrediction, AcceptNextWordEditPrediction,
406 NextEditPrediction, PreviousEditPrediction, ShowEditPrediction, ToggleEditPrediction,
407 };
408 let edit_prediction_actions = [
409 TypeId::of::<AcceptEditPrediction>(),
410 TypeId::of::<AcceptNextWordEditPrediction>(),
411 TypeId::of::<AcceptNextLineEditPrediction>(),
412 TypeId::of::<AcceptEditPrediction>(),
413 TypeId::of::<ShowEditPrediction>(),
414 TypeId::of::<NextEditPrediction>(),
415 TypeId::of::<PreviousEditPrediction>(),
416 TypeId::of::<ToggleEditPrediction>(),
417 ];
418
419 if disable_ai {
420 filter.hide_namespace("agent");
421 filter.hide_namespace("agents");
422 filter.hide_namespace("assistant");
423 filter.hide_namespace("copilot");
424 filter.hide_namespace("zed_predict_onboarding");
425 filter.hide_namespace("edit_prediction");
426
427 filter.hide_action_types(&edit_prediction_actions);
428 filter.hide_action_types(&[TypeId::of::<zed_actions::OpenZedPredictOnboarding>()]);
429 } else {
430 if agent_enabled {
431 filter.show_namespace("agent");
432 filter.show_namespace("agents");
433 filter.show_namespace("assistant");
434 } else {
435 filter.hide_namespace("agent");
436 filter.hide_namespace("agents");
437 filter.hide_namespace("assistant");
438 }
439
440 match edit_prediction_provider {
441 EditPredictionProvider::None => {
442 filter.hide_namespace("edit_prediction");
443 filter.hide_namespace("copilot");
444 filter.hide_action_types(&edit_prediction_actions);
445 }
446 EditPredictionProvider::Copilot => {
447 filter.show_namespace("edit_prediction");
448 filter.show_namespace("copilot");
449 filter.show_action_types(edit_prediction_actions.iter());
450 }
451 EditPredictionProvider::Zed
452 | EditPredictionProvider::Codestral
453 | EditPredictionProvider::Ollama
454 | EditPredictionProvider::OpenAiCompatibleApi
455 | EditPredictionProvider::Sweep
456 | EditPredictionProvider::Mercury
457 | EditPredictionProvider::Experimental(_) => {
458 filter.show_namespace("edit_prediction");
459 filter.hide_namespace("copilot");
460 filter.show_action_types(edit_prediction_actions.iter());
461 }
462 }
463
464 filter.show_namespace("zed_predict_onboarding");
465 filter.show_action_types(&[TypeId::of::<zed_actions::OpenZedPredictOnboarding>()]);
466 }
467
468 if agent_v2_enabled {
469 filter.show_namespace("multi_workspace");
470 } else {
471 filter.hide_namespace("multi_workspace");
472 }
473 });
474}
475
476fn init_language_model_settings(cx: &mut App) {
477 update_active_language_model_from_settings(cx);
478
479 cx.observe_global::<SettingsStore>(update_active_language_model_from_settings)
480 .detach();
481 cx.subscribe(
482 &LanguageModelRegistry::global(cx),
483 |_, event: &language_model::Event, cx| match event {
484 language_model::Event::ProviderStateChanged(_)
485 | language_model::Event::AddedProvider(_)
486 | language_model::Event::RemovedProvider(_)
487 | language_model::Event::ProvidersChanged => {
488 update_active_language_model_from_settings(cx);
489 }
490 _ => {}
491 },
492 )
493 .detach();
494}
495
496fn update_active_language_model_from_settings(cx: &mut App) {
497 let settings = AgentSettings::get_global(cx);
498
499 fn to_selected_model(selection: &LanguageModelSelection) -> language_model::SelectedModel {
500 language_model::SelectedModel {
501 provider: LanguageModelProviderId::from(selection.provider.0.clone()),
502 model: LanguageModelId::from(selection.model.clone()),
503 }
504 }
505
506 let default = settings.default_model.as_ref().map(to_selected_model);
507 let inline_assistant = settings
508 .inline_assistant_model
509 .as_ref()
510 .map(to_selected_model);
511 let commit_message = settings
512 .commit_message_model
513 .as_ref()
514 .map(to_selected_model);
515 let thread_summary = settings
516 .thread_summary_model
517 .as_ref()
518 .map(to_selected_model);
519 let inline_alternatives = settings
520 .inline_alternatives
521 .iter()
522 .map(to_selected_model)
523 .collect::<Vec<_>>();
524
525 LanguageModelRegistry::global(cx).update(cx, |registry, cx| {
526 registry.select_default_model(default.as_ref(), cx);
527 registry.select_inline_assistant_model(inline_assistant.as_ref(), cx);
528 registry.select_commit_message_model(commit_message.as_ref(), cx);
529 registry.select_thread_summary_model(thread_summary.as_ref(), cx);
530 registry.select_inline_alternative_models(inline_alternatives, cx);
531 });
532}
533
534fn register_slash_commands(cx: &mut App) {
535 let slash_command_registry = SlashCommandRegistry::global(cx);
536
537 slash_command_registry.register_command(assistant_slash_commands::FileSlashCommand, true);
538 slash_command_registry.register_command(assistant_slash_commands::DeltaSlashCommand, true);
539 slash_command_registry.register_command(assistant_slash_commands::OutlineSlashCommand, true);
540 slash_command_registry.register_command(assistant_slash_commands::TabSlashCommand, true);
541 slash_command_registry.register_command(assistant_slash_commands::PromptSlashCommand, true);
542 slash_command_registry.register_command(assistant_slash_commands::SelectionCommand, true);
543 slash_command_registry.register_command(assistant_slash_commands::DefaultSlashCommand, false);
544 slash_command_registry.register_command(assistant_slash_commands::NowSlashCommand, false);
545 slash_command_registry
546 .register_command(assistant_slash_commands::DiagnosticsSlashCommand, true);
547 slash_command_registry.register_command(assistant_slash_commands::FetchSlashCommand, true);
548
549 cx.observe_flag::<assistant_slash_commands::StreamingExampleSlashCommandFeatureFlag, _>({
550 move |is_enabled, _cx| {
551 if is_enabled {
552 slash_command_registry.register_command(
553 assistant_slash_commands::StreamingExampleSlashCommand,
554 false,
555 );
556 }
557 }
558 })
559 .detach();
560}
561
562#[cfg(test)]
563mod tests {
564 use super::*;
565 use agent_settings::{AgentProfileId, AgentSettings};
566 use command_palette_hooks::CommandPaletteFilter;
567 use editor::actions::AcceptEditPrediction;
568 use gpui::{BorrowAppContext, TestAppContext, px};
569 use project::DisableAiSettings;
570 use settings::{
571 DefaultAgentView, DockPosition, NotifyWhenAgentWaiting, Settings, SettingsStore,
572 };
573
574 #[gpui::test]
575 fn test_agent_command_palette_visibility(cx: &mut TestAppContext) {
576 // Init settings
577 cx.update(|cx| {
578 let store = SettingsStore::test(cx);
579 cx.set_global(store);
580 command_palette_hooks::init(cx);
581 AgentSettings::register(cx);
582 DisableAiSettings::register(cx);
583 AllLanguageSettings::register(cx);
584 });
585
586 let agent_settings = AgentSettings {
587 enabled: true,
588 button: true,
589 dock: DockPosition::Right,
590 default_width: px(300.),
591 default_height: px(600.),
592 default_model: None,
593 inline_assistant_model: None,
594 inline_assistant_use_streaming_tools: false,
595 commit_message_model: None,
596 thread_summary_model: None,
597 inline_alternatives: vec![],
598 favorite_models: vec![],
599 default_profile: AgentProfileId::default(),
600 default_view: DefaultAgentView::Thread,
601 profiles: Default::default(),
602
603 notify_when_agent_waiting: NotifyWhenAgentWaiting::default(),
604 play_sound_when_agent_done: false,
605 single_file_review: false,
606 model_parameters: vec![],
607 enable_feedback: false,
608 expand_edit_card: true,
609 expand_terminal_card: true,
610 cancel_generation_on_terminal_stop: true,
611 use_modifier_to_send: true,
612 message_editor_min_lines: 1,
613 tool_permissions: Default::default(),
614 show_turn_stats: false,
615 new_thread_location: Default::default(),
616 };
617
618 cx.update(|cx| {
619 AgentSettings::override_global(agent_settings.clone(), cx);
620 DisableAiSettings::override_global(DisableAiSettings { disable_ai: false }, cx);
621
622 // Initial update
623 update_command_palette_filter(cx);
624 });
625
626 // Assert visible
627 cx.update(|cx| {
628 let filter = CommandPaletteFilter::try_global(cx).unwrap();
629 assert!(
630 !filter.is_hidden(&NewThread),
631 "NewThread should be visible by default"
632 );
633 assert!(
634 !filter.is_hidden(&text_thread_editor::CopyCode),
635 "CopyCode should be visible when agent is enabled"
636 );
637 });
638
639 // Disable agent
640 cx.update(|cx| {
641 let mut new_settings = agent_settings.clone();
642 new_settings.enabled = false;
643 AgentSettings::override_global(new_settings, cx);
644
645 // Trigger update
646 update_command_palette_filter(cx);
647 });
648
649 // Assert hidden
650 cx.update(|cx| {
651 let filter = CommandPaletteFilter::try_global(cx).unwrap();
652 assert!(
653 filter.is_hidden(&NewThread),
654 "NewThread should be hidden when agent is disabled"
655 );
656 assert!(
657 filter.is_hidden(&text_thread_editor::CopyCode),
658 "CopyCode should be hidden when agent is disabled"
659 );
660 });
661
662 // Test EditPredictionProvider
663 // Enable EditPredictionProvider::Copilot
664 cx.update(|cx| {
665 cx.update_global::<SettingsStore, _>(|store, cx| {
666 store.update_user_settings(cx, |s| {
667 s.project
668 .all_languages
669 .edit_predictions
670 .get_or_insert(Default::default())
671 .provider = Some(EditPredictionProvider::Copilot);
672 });
673 });
674 update_command_palette_filter(cx);
675 });
676
677 cx.update(|cx| {
678 let filter = CommandPaletteFilter::try_global(cx).unwrap();
679 assert!(
680 !filter.is_hidden(&AcceptEditPrediction),
681 "EditPrediction should be visible when provider is Copilot"
682 );
683 });
684
685 // Disable EditPredictionProvider (None)
686 cx.update(|cx| {
687 cx.update_global::<SettingsStore, _>(|store, cx| {
688 store.update_user_settings(cx, |s| {
689 s.project
690 .all_languages
691 .edit_predictions
692 .get_or_insert(Default::default())
693 .provider = Some(EditPredictionProvider::None);
694 });
695 });
696 update_command_palette_filter(cx);
697 });
698
699 cx.update(|cx| {
700 let filter = CommandPaletteFilter::try_global(cx).unwrap();
701 assert!(
702 filter.is_hidden(&AcceptEditPrediction),
703 "EditPrediction should be hidden when provider is None"
704 );
705 });
706 }
707
708 #[test]
709 fn test_deserialize_external_agent_variants() {
710 assert_eq!(
711 serde_json::from_str::<Agent>(r#""native_agent""#).unwrap(),
712 Agent::NativeAgent,
713 );
714 assert_eq!(
715 serde_json::from_str::<Agent>(r#"{"custom":{"name":"my-agent"}}"#).unwrap(),
716 Agent::Custom {
717 id: "my-agent".into(),
718 },
719 );
720 }
721}