agent_ui.rs

  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 server(
232        &self,
233        fs: Arc<dyn fs::Fs>,
234        thread_store: Entity<agent::ThreadStore>,
235    ) -> Rc<dyn agent_servers::AgentServer> {
236        match self {
237            Self::NativeAgent => Rc::new(agent::NativeAgentServer::new(fs, thread_store)),
238            Self::Custom { id: name } => {
239                Rc::new(agent_servers::CustomAgentServer::new(name.clone()))
240            }
241        }
242    }
243}
244
245/// Sets where new threads will run.
246#[derive(
247    Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Action,
248)]
249#[action(namespace = agent)]
250#[serde(rename_all = "snake_case", tag = "kind")]
251pub enum StartThreadIn {
252    #[default]
253    LocalProject,
254    NewWorktree,
255}
256
257/// Content to initialize new external agent with.
258pub enum AgentInitialContent {
259    ThreadSummary {
260        session_id: acp::SessionId,
261        title: Option<SharedString>,
262    },
263    ContentBlock {
264        blocks: Vec<agent_client_protocol::ContentBlock>,
265        auto_submit: bool,
266    },
267    FromExternalSource(ExternalSourcePrompt),
268}
269
270impl From<ExternalSourcePrompt> for AgentInitialContent {
271    fn from(prompt: ExternalSourcePrompt) -> Self {
272        Self::FromExternalSource(prompt)
273    }
274}
275
276/// Opens the profile management interface for configuring agent tools and settings.
277#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
278#[action(namespace = agent)]
279#[serde(deny_unknown_fields)]
280pub struct ManageProfiles {
281    #[serde(default)]
282    pub customize_tools: Option<AgentProfileId>,
283}
284
285impl ManageProfiles {
286    pub fn customize_tools(profile_id: AgentProfileId) -> Self {
287        Self {
288            customize_tools: Some(profile_id),
289        }
290    }
291}
292
293#[derive(Clone)]
294pub(crate) enum ModelUsageContext {
295    InlineAssistant,
296}
297
298impl ModelUsageContext {
299    pub fn configured_model(&self, cx: &App) -> Option<ConfiguredModel> {
300        match self {
301            Self::InlineAssistant => {
302                LanguageModelRegistry::read_global(cx).inline_assistant_model()
303            }
304        }
305    }
306}
307
308/// Initializes the `agent` crate.
309pub fn init(
310    fs: Arc<dyn Fs>,
311    client: Arc<Client>,
312    prompt_builder: Arc<PromptBuilder>,
313    language_registry: Arc<LanguageRegistry>,
314    is_eval: bool,
315    cx: &mut App,
316) {
317    agent::ThreadStore::init_global(cx);
318    assistant_text_thread::init(client, cx);
319    rules_library::init(cx);
320    if !is_eval {
321        // Initializing the language model from the user settings messes with the eval, so we only initialize them when
322        // we're not running inside of the eval.
323        init_language_model_settings(cx);
324    }
325    assistant_slash_command::init(cx);
326    agent_panel::init(cx);
327    context_server_configuration::init(language_registry.clone(), fs.clone(), cx);
328    TextThreadEditor::init(cx);
329    thread_metadata_store::init(cx);
330
331    register_slash_commands(cx);
332    inline_assistant::init(fs.clone(), prompt_builder.clone(), cx);
333    terminal_inline_assistant::init(fs.clone(), prompt_builder, cx);
334    cx.observe_new(move |workspace, window, cx| {
335        ConfigureContextServerModal::register(workspace, language_registry.clone(), window, cx)
336    })
337    .detach();
338    cx.observe_new(|workspace: &mut Workspace, _window, _cx| {
339        workspace.register_action(
340            move |workspace: &mut Workspace,
341                  _: &zed_actions::AcpRegistry,
342                  window: &mut Window,
343                  cx: &mut Context<Workspace>| {
344                let existing = workspace
345                    .active_pane()
346                    .read(cx)
347                    .items()
348                    .find_map(|item| item.downcast::<AgentRegistryPage>());
349
350                if let Some(existing) = existing {
351                    existing.update(cx, |_, cx| {
352                        project::AgentRegistryStore::global(cx)
353                            .update(cx, |store, cx| store.refresh(cx));
354                    });
355                    workspace.activate_item(&existing, true, true, window, cx);
356                } else {
357                    let registry_page = AgentRegistryPage::new(workspace, window, cx);
358                    workspace.add_item_to_active_pane(
359                        Box::new(registry_page),
360                        None,
361                        true,
362                        window,
363                        cx,
364                    );
365                }
366            },
367        );
368    })
369    .detach();
370    cx.observe_new(ManageProfilesModal::register).detach();
371
372    // Update command palette filter based on AI settings
373    update_command_palette_filter(cx);
374
375    // Watch for settings changes
376    cx.observe_global::<SettingsStore>(|app_cx| {
377        // When settings change, update the command palette filter
378        update_command_palette_filter(app_cx);
379    })
380    .detach();
381
382    cx.on_flags_ready(|_, cx| {
383        update_command_palette_filter(cx);
384    })
385    .detach();
386}
387
388fn update_command_palette_filter(cx: &mut App) {
389    let disable_ai = DisableAiSettings::get_global(cx).disable_ai;
390    let agent_enabled = AgentSettings::get_global(cx).enabled;
391    let agent_v2_enabled = cx.has_flag::<AgentV2FeatureFlag>();
392    let edit_prediction_provider = AllLanguageSettings::get_global(cx)
393        .edit_predictions
394        .provider;
395
396    CommandPaletteFilter::update_global(cx, |filter, _| {
397        use editor::actions::{
398            AcceptEditPrediction, AcceptNextLineEditPrediction, AcceptNextWordEditPrediction,
399            NextEditPrediction, PreviousEditPrediction, ShowEditPrediction, ToggleEditPrediction,
400        };
401        let edit_prediction_actions = [
402            TypeId::of::<AcceptEditPrediction>(),
403            TypeId::of::<AcceptNextWordEditPrediction>(),
404            TypeId::of::<AcceptNextLineEditPrediction>(),
405            TypeId::of::<AcceptEditPrediction>(),
406            TypeId::of::<ShowEditPrediction>(),
407            TypeId::of::<NextEditPrediction>(),
408            TypeId::of::<PreviousEditPrediction>(),
409            TypeId::of::<ToggleEditPrediction>(),
410        ];
411
412        if disable_ai {
413            filter.hide_namespace("agent");
414            filter.hide_namespace("agents");
415            filter.hide_namespace("assistant");
416            filter.hide_namespace("copilot");
417            filter.hide_namespace("zed_predict_onboarding");
418            filter.hide_namespace("edit_prediction");
419
420            filter.hide_action_types(&edit_prediction_actions);
421            filter.hide_action_types(&[TypeId::of::<zed_actions::OpenZedPredictOnboarding>()]);
422        } else {
423            if agent_enabled {
424                filter.show_namespace("agent");
425                filter.show_namespace("agents");
426                filter.show_namespace("assistant");
427            } else {
428                filter.hide_namespace("agent");
429                filter.hide_namespace("agents");
430                filter.hide_namespace("assistant");
431            }
432
433            match edit_prediction_provider {
434                EditPredictionProvider::None => {
435                    filter.hide_namespace("edit_prediction");
436                    filter.hide_namespace("copilot");
437                    filter.hide_action_types(&edit_prediction_actions);
438                }
439                EditPredictionProvider::Copilot => {
440                    filter.show_namespace("edit_prediction");
441                    filter.show_namespace("copilot");
442                    filter.show_action_types(edit_prediction_actions.iter());
443                }
444                EditPredictionProvider::Zed
445                | EditPredictionProvider::Codestral
446                | EditPredictionProvider::Ollama
447                | EditPredictionProvider::OpenAiCompatibleApi
448                | EditPredictionProvider::Sweep
449                | EditPredictionProvider::Mercury
450                | EditPredictionProvider::Experimental(_) => {
451                    filter.show_namespace("edit_prediction");
452                    filter.hide_namespace("copilot");
453                    filter.show_action_types(edit_prediction_actions.iter());
454                }
455            }
456
457            filter.show_namespace("zed_predict_onboarding");
458            filter.show_action_types(&[TypeId::of::<zed_actions::OpenZedPredictOnboarding>()]);
459        }
460
461        if agent_v2_enabled {
462            filter.show_namespace("multi_workspace");
463        } else {
464            filter.hide_namespace("multi_workspace");
465        }
466    });
467}
468
469fn init_language_model_settings(cx: &mut App) {
470    update_active_language_model_from_settings(cx);
471
472    cx.observe_global::<SettingsStore>(update_active_language_model_from_settings)
473        .detach();
474    cx.subscribe(
475        &LanguageModelRegistry::global(cx),
476        |_, event: &language_model::Event, cx| match event {
477            language_model::Event::ProviderStateChanged(_)
478            | language_model::Event::AddedProvider(_)
479            | language_model::Event::RemovedProvider(_)
480            | language_model::Event::ProvidersChanged => {
481                update_active_language_model_from_settings(cx);
482            }
483            _ => {}
484        },
485    )
486    .detach();
487}
488
489fn update_active_language_model_from_settings(cx: &mut App) {
490    let settings = AgentSettings::get_global(cx);
491
492    fn to_selected_model(selection: &LanguageModelSelection) -> language_model::SelectedModel {
493        language_model::SelectedModel {
494            provider: LanguageModelProviderId::from(selection.provider.0.clone()),
495            model: LanguageModelId::from(selection.model.clone()),
496        }
497    }
498
499    let default = settings.default_model.as_ref().map(to_selected_model);
500    let inline_assistant = settings
501        .inline_assistant_model
502        .as_ref()
503        .map(to_selected_model);
504    let commit_message = settings
505        .commit_message_model
506        .as_ref()
507        .map(to_selected_model);
508    let thread_summary = settings
509        .thread_summary_model
510        .as_ref()
511        .map(to_selected_model);
512    let inline_alternatives = settings
513        .inline_alternatives
514        .iter()
515        .map(to_selected_model)
516        .collect::<Vec<_>>();
517
518    LanguageModelRegistry::global(cx).update(cx, |registry, cx| {
519        registry.select_default_model(default.as_ref(), cx);
520        registry.select_inline_assistant_model(inline_assistant.as_ref(), cx);
521        registry.select_commit_message_model(commit_message.as_ref(), cx);
522        registry.select_thread_summary_model(thread_summary.as_ref(), cx);
523        registry.select_inline_alternative_models(inline_alternatives, cx);
524    });
525}
526
527fn register_slash_commands(cx: &mut App) {
528    let slash_command_registry = SlashCommandRegistry::global(cx);
529
530    slash_command_registry.register_command(assistant_slash_commands::FileSlashCommand, true);
531    slash_command_registry.register_command(assistant_slash_commands::DeltaSlashCommand, true);
532    slash_command_registry.register_command(assistant_slash_commands::OutlineSlashCommand, true);
533    slash_command_registry.register_command(assistant_slash_commands::TabSlashCommand, true);
534    slash_command_registry.register_command(assistant_slash_commands::PromptSlashCommand, true);
535    slash_command_registry.register_command(assistant_slash_commands::SelectionCommand, true);
536    slash_command_registry.register_command(assistant_slash_commands::DefaultSlashCommand, false);
537    slash_command_registry.register_command(assistant_slash_commands::NowSlashCommand, false);
538    slash_command_registry
539        .register_command(assistant_slash_commands::DiagnosticsSlashCommand, true);
540    slash_command_registry.register_command(assistant_slash_commands::FetchSlashCommand, true);
541
542    cx.observe_flag::<assistant_slash_commands::StreamingExampleSlashCommandFeatureFlag, _>({
543        move |is_enabled, _cx| {
544            if is_enabled {
545                slash_command_registry.register_command(
546                    assistant_slash_commands::StreamingExampleSlashCommand,
547                    false,
548                );
549            }
550        }
551    })
552    .detach();
553}
554
555#[cfg(test)]
556mod tests {
557    use super::*;
558    use agent_settings::{AgentProfileId, AgentSettings};
559    use command_palette_hooks::CommandPaletteFilter;
560    use editor::actions::AcceptEditPrediction;
561    use gpui::{BorrowAppContext, TestAppContext, px};
562    use project::DisableAiSettings;
563    use settings::{
564        DefaultAgentView, DockPosition, NotifyWhenAgentWaiting, Settings, SettingsStore,
565    };
566
567    #[gpui::test]
568    fn test_agent_command_palette_visibility(cx: &mut TestAppContext) {
569        // Init settings
570        cx.update(|cx| {
571            let store = SettingsStore::test(cx);
572            cx.set_global(store);
573            command_palette_hooks::init(cx);
574            AgentSettings::register(cx);
575            DisableAiSettings::register(cx);
576            AllLanguageSettings::register(cx);
577        });
578
579        let agent_settings = AgentSettings {
580            enabled: true,
581            button: true,
582            dock: DockPosition::Right,
583            default_width: px(300.),
584            default_height: px(600.),
585            default_model: None,
586            inline_assistant_model: None,
587            inline_assistant_use_streaming_tools: false,
588            commit_message_model: None,
589            thread_summary_model: None,
590            inline_alternatives: vec![],
591            favorite_models: vec![],
592            default_profile: AgentProfileId::default(),
593            default_view: DefaultAgentView::Thread,
594            profiles: Default::default(),
595
596            notify_when_agent_waiting: NotifyWhenAgentWaiting::default(),
597            play_sound_when_agent_done: false,
598            single_file_review: false,
599            model_parameters: vec![],
600            enable_feedback: false,
601            expand_edit_card: true,
602            expand_terminal_card: true,
603            cancel_generation_on_terminal_stop: true,
604            use_modifier_to_send: true,
605            message_editor_min_lines: 1,
606            tool_permissions: Default::default(),
607            show_turn_stats: false,
608            new_thread_location: Default::default(),
609        };
610
611        cx.update(|cx| {
612            AgentSettings::override_global(agent_settings.clone(), cx);
613            DisableAiSettings::override_global(DisableAiSettings { disable_ai: false }, cx);
614
615            // Initial update
616            update_command_palette_filter(cx);
617        });
618
619        // Assert visible
620        cx.update(|cx| {
621            let filter = CommandPaletteFilter::try_global(cx).unwrap();
622            assert!(
623                !filter.is_hidden(&NewThread),
624                "NewThread should be visible by default"
625            );
626            assert!(
627                !filter.is_hidden(&text_thread_editor::CopyCode),
628                "CopyCode should be visible when agent is enabled"
629            );
630        });
631
632        // Disable agent
633        cx.update(|cx| {
634            let mut new_settings = agent_settings.clone();
635            new_settings.enabled = false;
636            AgentSettings::override_global(new_settings, cx);
637
638            // Trigger update
639            update_command_palette_filter(cx);
640        });
641
642        // Assert hidden
643        cx.update(|cx| {
644            let filter = CommandPaletteFilter::try_global(cx).unwrap();
645            assert!(
646                filter.is_hidden(&NewThread),
647                "NewThread should be hidden when agent is disabled"
648            );
649            assert!(
650                filter.is_hidden(&text_thread_editor::CopyCode),
651                "CopyCode should be hidden when agent is disabled"
652            );
653        });
654
655        // Test EditPredictionProvider
656        // Enable EditPredictionProvider::Copilot
657        cx.update(|cx| {
658            cx.update_global::<SettingsStore, _>(|store, cx| {
659                store.update_user_settings(cx, |s| {
660                    s.project
661                        .all_languages
662                        .edit_predictions
663                        .get_or_insert(Default::default())
664                        .provider = Some(EditPredictionProvider::Copilot);
665                });
666            });
667            update_command_palette_filter(cx);
668        });
669
670        cx.update(|cx| {
671            let filter = CommandPaletteFilter::try_global(cx).unwrap();
672            assert!(
673                !filter.is_hidden(&AcceptEditPrediction),
674                "EditPrediction should be visible when provider is Copilot"
675            );
676        });
677
678        // Disable EditPredictionProvider (None)
679        cx.update(|cx| {
680            cx.update_global::<SettingsStore, _>(|store, cx| {
681                store.update_user_settings(cx, |s| {
682                    s.project
683                        .all_languages
684                        .edit_predictions
685                        .get_or_insert(Default::default())
686                        .provider = Some(EditPredictionProvider::None);
687                });
688            });
689            update_command_palette_filter(cx);
690        });
691
692        cx.update(|cx| {
693            let filter = CommandPaletteFilter::try_global(cx).unwrap();
694            assert!(
695                filter.is_hidden(&AcceptEditPrediction),
696                "EditPrediction should be hidden when provider is None"
697            );
698        });
699    }
700
701    #[test]
702    fn test_deserialize_external_agent_variants() {
703        assert_eq!(
704            serde_json::from_str::<Agent>(r#""native_agent""#).unwrap(),
705            Agent::NativeAgent,
706        );
707        assert_eq!(
708            serde_json::from_str::<Agent>(r#"{"custom":{"name":"my-agent"}}"#).unwrap(),
709            Agent::Custom {
710                id: "my-agent".into(),
711            },
712        );
713    }
714}