Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
agent: Add configurable idle thread retention (#64547)
Hazic821538b5770
diff --git a/assets/settings/default.json b/assets/settings/default.jsonindex a495126bf62..1228f8b8596 100644--- a/assets/settings/default.json+++ b/assets/settings/default.json@@ -1164,6 +1164,10 @@//// Default: true"flexible": true,+ // Maximum number of idle threads with loadable sessions to retain in the+ // agent panel. Set to 0 to unload every eligible idle thread when it is+ // no longer active.+ "max_idle_retained_threads": 5,// Settings for the sidebar holding the agent panel and the list of agent threads."threads_sidebar": {// Where to position the Threads Sidebar. Can be 'left' or 'right'.diff --git a/crates/agent/src/tool_permissions.rs b/crates/agent/src/tool_permissions.rsindex bbb680d39ea..fa38a0b0bb0 100644--- a/crates/agent/src/tool_permissions.rs+++ b/crates/agent/src/tool_permissions.rs@@ -608,6 +608,7 @@ mod tests {sandbox_permissions: Default::default(),show_turn_stats: false,show_merge_conflict_indicator: true,+ max_idle_retained_threads: 5,threads_sidebar: agent_settings::ThreadsSidebarSettings {auto_open: true,default_width: px(300.),diff --git a/crates/agent_settings/src/agent_settings.rs b/crates/agent_settings/src/agent_settings.rsindex 56f97f643eb..331480c2e6f 100644--- a/crates/agent_settings/src/agent_settings.rs+++ b/crates/agent_settings/src/agent_settings.rs@@ -213,6 +213,7 @@ pub struct AgentSettings {pub button: bool,pub dock: DockPosition,pub flexible: bool,+ pub max_idle_retained_threads: usize,pub threads_sidebar: ThreadsSidebarSettings,pub default_width: Pixels,pub default_height: Pixels,@@ -773,6 +774,7 @@ impl Settings for AgentSettings {enabled: agent.enabled.unwrap(),button: agent.button.unwrap(),dock: agent.dock.unwrap(),+ max_idle_retained_threads: agent.max_idle_retained_threads.unwrap(),threads_sidebar: ThreadsSidebarSettings {auto_open: threads_sidebar.auto_open.unwrap(),position: threads_sidebar.position.unwrap(),@@ -1315,6 +1317,40 @@ mod tests {}}+ #[gpui::test]+ fn test_max_idle_retained_threads_defaults_to_five_and_follows_user_settings(+ cx: &mut gpui::App,+ ) {+ let store = SettingsStore::test(cx);+ cx.set_global(store);+ project::DisableAiSettings::register(cx);+ AgentSettings::register(cx);++ assert_eq!(+ AgentSettings::get_global(cx).max_idle_retained_threads,+ 5,+ "default.json supplies the retained thread limit"+ );++ for (content, expected) in [+ (r#"{ "agent": { "max_idle_retained_threads": 0 } }"#, 0),+ (r#"{ "agent": { "max_idle_retained_threads": 12 } }"#, 12),+ (r#"{ "agent": { "max_idle_retained_threads": null } }"#, 5),+ (r#"{ "agent": {} }"#, 5),+ ] {+ SettingsStore::update_global(cx, |store, cx| {+ store+ .set_user_settings(content, cx)+ .expect("user settings should load");+ });+ assert_eq!(+ AgentSettings::get_global(cx).max_idle_retained_threads,+ expected,+ "{content}"+ );+ }+ }+#[gpui::test]fn test_terminal_init_command_filters_empty_without_trimming(cx: &mut gpui::App) {let store = SettingsStore::test(cx);diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rsindex 4942a140a7d..d6f0229cec2 100644--- a/crates/agent_ui/src/agent_panel.rs+++ b/crates/agent_ui/src/agent_panel.rs@@ -83,7 +83,7 @@ use language::LanguageRegistry;use language_model::LanguageModelRegistry;use notifications::status_toast::StatusToast;use project::{Project, ProjectPath, Worktree};-use settings::{NotifyWhenAgentWaiting, Settings, update_settings_file};+use settings::{NotifyWhenAgentWaiting, Settings, SettingsStore, update_settings_file};use search::{BufferSearchBar, buffer_search::Deploy as DeployBufferSearch};use terminal::Event as TerminalEvent;@@ -150,17 +150,6 @@ fn terminal_program_to_report(program_to_report}-/// Maximum number of idle threads kept in the agent panel's retained list.-/// Set as a GPUI global to override; otherwise defaults to 5.-pub struct MaxIdleRetainedThreads(pub usize);-impl gpui::Global for MaxIdleRetainedThreads {}--impl MaxIdleRetainedThreads {- pub fn global(cx: &App) -> usize {- cx.try_global::<Self>().map_or(5, |g| g.0)- }-}-#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]pub struct TerminalId(uuid::Uuid);@@ -1146,6 +1135,8 @@ pub struct AgentPanel {_draft_editor_observation: Option<Subscription>,_active_draft_reclaim_observation: Option<Subscription>,_thread_metadata_store_subscription: Subscription,+ _settings_subscription: Subscription,+ retained_thread_subscriptions: HashMap<ThreadId, Subscription>,last_context_source: Option<AgentContextSource>,is_active: bool,@@ -1515,12 +1506,16 @@ impl AgentPanel {&ThreadMetadataStore::global(cx),|this, _store, event, cx| {let ThreadMetadataStoreEvent::ThreadArchived(thread_id) = event;- if this.retained_threads.remove(thread_id).is_some() {+ if this.remove_retained_thread(thread_id).is_some() {cx.notify();}},);+ let _settings_subscription = cx.observe_global::<SettingsStore>(|this, cx| {+ this.cleanup_retained_threads(cx);+ });+cx.on_release(|this, cx| {this.dismiss_all_terminal_notifications(cx);})@@ -1562,6 +1557,8 @@ impl AgentPanel {_draft_editor_observation: None,_active_draft_reclaim_observation: None,_thread_metadata_store_subscription,+ _settings_subscription,+ retained_thread_subscriptions: HashMap::default(),last_context_source: None,is_active: false,};@@ -1800,7 +1797,7 @@ impl AgentPanel {let draft_id = draft.read(cx).thread_id;self.draft_thread = None;self._draft_editor_observation = None;- self.retained_threads.insert(draft_id, draft);+ self.insert_retained_thread(draft_id, draft, cx);} else if *draft.read(cx).agent_key() != self.selected_agent {let old_draft_id = draft.read(cx).thread_id;ThreadMetadataStore::global(cx).update(cx, |store, cx| {@@ -3179,7 +3176,7 @@ impl AgentPanel {return false;}- self.retained_threads.remove(&thread_id);+ self.remove_retained_thread(&thread_id);self.set_ephemeral_draft(conversation_view, cx);true}@@ -3246,8 +3243,7 @@ impl AgentPanel {self.set_selected_agent_and_persist(original, cx);}let thread_id = thread.conversation_view.read(cx).thread_id;- self.retained_threads- .insert(thread_id, thread.conversation_view);+ self.insert_retained_thread(thread_id, thread.conversation_view, cx);thread_id}@@ -3258,7 +3254,7 @@ impl AgentPanel {window: &mut Window,cx: &mut Context<Self>,) {- let conversation_view = if let Some(view) = self.retained_threads.remove(&id) {+ let conversation_view = if let Some(view) = self.remove_retained_thread(&id) {self.try_make_empty_draft_ephemeral(view.clone(), cx);view} else if let Some(draft) = &self.draft_thread {@@ -3310,7 +3306,7 @@ impl AgentPanel {window: &mut Window,cx: &mut Context<Self>,) {- self.retained_threads.remove(&id);+ self.remove_retained_thread(&id);ThreadMetadataStore::global(cx).update(cx, |store, cx| {store.delete(id, cx);});@@ -4199,7 +4195,7 @@ impl AgentPanel {let thread_id = conversation_view.read(cx).thread_id;self.draft_thread = None;self._draft_editor_observation = None;- self.retained_threads.insert(thread_id, conversation_view);+ self.insert_retained_thread(thread_id, conversation_view, cx);self.cleanup_retained_threads(cx);}return;@@ -4211,10 +4207,52 @@ impl AgentPanel {return;}- self.retained_threads.insert(thread_id, conversation_view);+ self.insert_retained_thread(thread_id, conversation_view, cx);self.cleanup_retained_threads(cx);}+ fn insert_retained_thread(+ &mut self,+ thread_id: ThreadId,+ conversation_view: Entity<ConversationView>,+ cx: &mut Context<Self>,+ ) {+ self.retained_threads+ .insert(thread_id, conversation_view.clone());+ self.observe_retained_thread(thread_id, conversation_view, cx);+ }++ fn observe_retained_thread(+ &mut self,+ thread_id: ThreadId,+ conversation_view: Entity<ConversationView>,+ cx: &mut Context<Self>,+ ) {+ let subscription = if let Some(acp_thread) = conversation_view.read(cx).root_thread(cx) {+ let subscription = cx.subscribe(&acp_thread, |this, acp_thread, event, cx| {+ if matches!(event, AcpThreadEvent::StatusChanged)+ && acp_thread.read(cx).status() == ThreadStatus::Idle+ {+ this.cleanup_retained_threads(cx);+ }+ });+ subscription+ } else {+ cx.observe(&conversation_view, move |this, conversation_view, cx| {+ if conversation_view.read(cx).root_thread(cx).is_some() {+ this.observe_retained_thread(thread_id, conversation_view, cx);+ }+ })+ };+ self.retained_thread_subscriptions+ .insert(thread_id, subscription);+ }++ fn remove_retained_thread(&mut self, thread_id: &ThreadId) -> Option<Entity<ConversationView>> {+ self.retained_thread_subscriptions.remove(thread_id);+ self.retained_threads.remove(thread_id)+ }+fn cleanup_retained_threads(&mut self, cx: &App) {let mut potential_removals = self.retained_threads@@ -4228,7 +4266,7 @@ impl AgentPanel {}).collect::<Vec<_>>();- let max_idle = MaxIdleRetainedThreads::global(cx);+ let max_idle = AgentSettings::get_global(cx).max_idle_retained_threads;potential_removals.sort_unstable_by_key(|(_, view)| view.read(cx).updated_at(cx));let n = potential_removals.len().saturating_sub(max_idle);@@ -4238,7 +4276,7 @@ impl AgentPanel {.take(n).collect::<Vec<_>>();for id in to_remove {- self.retained_threads.remove(&id);+ self.remove_retained_thread(&id);}}@@ -4373,7 +4411,7 @@ impl AgentPanel {this.draft_thread = None;this._draft_editor_observation = None;}- this.retained_threads.remove(&thread_id);+ this.remove_retained_thread(&thread_id);cx.emit(AgentPanelEvent::ThreadInteracted { thread_id });}},@@ -4449,7 +4487,7 @@ impl AgentPanel {);return;}- if let Some(conversation_view) = self.retained_threads.remove(&thread_id) {+ if let Some(conversation_view) = self.remove_retained_thread(&thread_id) {self.try_make_empty_draft_ephemeral(conversation_view.clone(), cx);self.set_base_view(BaseView::AgentThread { conversation_view },@@ -6578,7 +6616,7 @@ impl AgentPanel {/// Drops a thread's `ConversationView` from `retained_threads` without/// deleting its metadata or kvp state. Simulates the post-restartpub fn test_unload_retained_thread(&mut self, id: ThreadId) -> bool {- self.retained_threads.remove(&id).is_some()+ self.remove_retained_thread(&id).is_some()}/// Opens an external thread using an arbitrary AgentServer.@@ -11294,6 +11332,16 @@ mod tests {thread_ids.push(thread_id);}+ cx.update(|_window, cx| {+ AgentSettings::override_global(+ AgentSettings {+ max_idle_retained_threads: 6,+ ..AgentSettings::get_global(cx).clone()+ },+ cx,+ );+ });+let base_time = Instant::now();for session_id in session_ids.iter().take(6) {@@ -11312,6 +11360,13 @@ mod tests {view.set_updated_at(base_time + Duration::from_secs(index as u64), cx);});}+ AgentSettings::override_global(+ AgentSettings {+ max_idle_retained_threads: 5,+ ..AgentSettings::get_global(cx).clone()+ },+ cx,+ );panel.cleanup_retained_threads(cx);});@@ -11338,6 +11393,88 @@ mod tests {});}+ #[gpui::test]+ async fn test_cleanup_retained_threads_runs_when_retained_thread_limit_changes(+ cx: &mut TestAppContext,+ ) {+ let (panel, mut cx) = setup_panel(cx).await;+ let connection = StubAgentConnection::new()+ .with_supports_load_session(true)+ .with_agent_id("loadable-stub".into())+ .with_telemetry_id("loadable-stub".into());+ let mut session_ids = Vec::new();++ for _ in 0..2 {+ let (session_id, _) =+ open_generating_thread_with_loadable_connection(&panel, &connection, &mut cx);+ session_ids.push(session_id);+ }++ for session_id in session_ids.iter() {+ connection.end_turn(session_id.clone(), acp::StopReason::EndTurn);+ }+ cx.run_until_parked();++ panel.read_with(&cx, |panel, _cx| {+ assert_eq!(panel.retained_threads.len(), 1);+ });++ cx.update(|_window, cx| {+ SettingsStore::update_global(cx, |store, cx| {+ store+ .set_user_settings(r#"{ "agent": { "max_idle_retained_threads": 0 } }"#, cx)+ .expect("user settings should load");+ });+ });++ panel.read_with(&cx, |panel, _cx| {+ assert!(+ panel.retained_threads.is_empty(),+ "changing the retained thread limit should unload idle threads immediately"+ );+ });+ }++ #[gpui::test]+ async fn test_completed_retained_thread_is_unloaded_when_retained_thread_limit_is_zero(+ cx: &mut TestAppContext,+ ) {+ let (panel, mut cx) = setup_panel(cx).await;+ let connection = StubAgentConnection::new()+ .with_supports_load_session(true)+ .with_agent_id("loadable-stub".into())+ .with_telemetry_id("loadable-stub".into());+ let (session_id, thread_id) =+ open_generating_thread_with_loadable_connection(&panel, &connection, &mut cx);++ open_generating_thread_with_loadable_connection(&panel, &connection, &mut cx);++ cx.update(|_window, cx| {+ SettingsStore::update_global(cx, |store, cx| {+ store+ .set_user_settings(r#"{ "agent": { "max_idle_retained_threads": 0 } }"#, cx)+ .expect("user settings should load");+ });+ });++ panel.read_with(&cx, |panel, _cx| {+ assert!(+ panel.retained_threads.contains_key(&thread_id),+ "a retained thread must stay loaded while its turn is running"+ );+ });++ connection.end_turn(session_id, acp::StopReason::EndTurn);+ cx.run_until_parked();++ panel.read_with(&cx, |panel, _cx| {+ assert!(+ !panel.retained_threads.contains_key(&thread_id),+ "a retained thread should unload when its turn completes"+ );+ });+ }+#[gpui::test]async fn test_cleanup_retained_threads_preserves_idle_non_loadable_threads(cx: &mut TestAppContext,@@ -11369,6 +11506,16 @@ mod tests {loadable_thread_ids.push(thread_id);}+ cx.update(|_window, cx| {+ AgentSettings::override_global(+ AgentSettings {+ max_idle_retained_threads: 6,+ ..AgentSettings::get_global(cx).clone()+ },+ cx,+ );+ });+let base_time = Instant::now();for session_id in loadable_session_ids.iter().take(6) {@@ -11387,6 +11534,13 @@ mod tests {view.set_updated_at(base_time + Duration::from_secs(index as u64), cx);});}+ AgentSettings::override_global(+ AgentSettings {+ max_idle_retained_threads: 5,+ ..AgentSettings::get_global(cx).clone()+ },+ cx,+ );panel.cleanup_retained_threads(cx);});@@ -13671,7 +13825,7 @@ mod tests {// so on_release → close_all_sessions fires only on A.drop(retained_conversation_a);panel.update(&mut cx, |panel, _cx| {- panel.retained_threads.remove(&_thread_id_a);+ panel.remove_retained_thread(&_thread_id_a);});cx.run_until_parked();diff --git a/crates/agent_ui/src/agent_ui.rs b/crates/agent_ui/src/agent_ui.rsindex b3a4d9fd7d3..7d28603d468 100644--- a/crates/agent_ui/src/agent_ui.rs+++ b/crates/agent_ui/src/agent_ui.rs@@ -71,8 +71,7 @@ use workspace::{OpenOptions, Workspace};use crate::agent_configuration::ManageProfilesModal;pub use crate::agent_connection_store::{ActiveAcpConnection, AgentConnectionStore};pub use crate::agent_panel::{- AgentPanel, AgentPanelEvent, AgentPanelTerminalInfo, MaxIdleRetainedThreads, TerminalId,- ThreadTitleRegenerationResult,+ AgentPanel, AgentPanelEvent, AgentPanelTerminalInfo, TerminalId, ThreadTitleRegenerationResult,};use crate::agent_registry_ui::AgentRegistryPage;pub use crate::inline_assistant::InlineAssistant;@@ -1010,6 +1009,7 @@ mod tests {sandbox_permissions: Default::default(),show_turn_stats: false,show_merge_conflict_indicator: true,+ max_idle_retained_threads: 5,threads_sidebar: agent_settings::ThreadsSidebarSettings {auto_open: true,default_width: px(300.),diff --git a/crates/settings_content/src/agent.rs b/crates/settings_content/src/agent.rsindex d8c755e48ca..6bafc029cb8 100644--- a/crates/settings_content/src/agent.rs+++ b/crates/settings_content/src/agent.rs@@ -252,6 +252,12 @@ pub struct AgentSettingsContent {/// Don't use this field.#[schemars(skip)]pub threads_sidebar_auto_open: Option<bool>,+ /// Maximum number of idle threads with loadable sessions to retain in the+ /// agent panel. Set to 0 to unload every eligible idle thread when it is+ /// no longer active.+ ///+ /// Default: 5+ pub max_idle_retained_threads: Option<usize>,/// Settings for the threads sidebar.pub threads_sidebar: Option<ThreadsSidebarSettingsContent>,/// Default fixed width in pixels when the agent panel is docked to the left or right anddiff --git a/crates/settings_ui/src/page_data.rs b/crates/settings_ui/src/page_data.rsindex 8e393c28bfc..972be0aba15 100644--- a/crates/settings_ui/src/page_data.rs+++ b/crates/settings_ui/src/page_data.rs@@ -8939,6 +8939,29 @@ fn ai_page(cx: &App) -> SettingsPage {metadata: None,files: USER,}),+ SettingsPageItem::SettingItem(SettingItem {+ title: "Max Idle Threads",+ description: "Maximum number of idle agent threads with loadable sessions to keep loaded. When the limit is exceeded, the least recently updated threads are unloaded.",+ field: Box::new(SettingField {+ organization_override: None,+ json_path: Some("agent.max_idle_retained_threads"),+ pick: |settings_content| {+ settings_content+ .agent+ .as_ref()?+ .max_idle_retained_threads+ .as_ref()+ },+ write: |settings_content, value, _| {+ settings_content+ .agent+ .get_or_insert_default()+ .max_idle_retained_threads = value;+ },+ }),+ metadata: None,+ files: USER,+ }),SettingsPageItem::SettingItem(SettingItem {title: "Expand Edit Card",description: "Whether to have edit cards in the agent panel expanded, showing a Preview of the diff.",diff --git a/crates/sidebar/src/sidebar_tests.rs b/crates/sidebar/src/sidebar_tests.rsindex 79c710930c3..d6ae15cad53 100644--- a/crates/sidebar/src/sidebar_tests.rs+++ b/crates/sidebar/src/sidebar_tests.rs@@ -1,6 +1,7 @@use super::*;use acp_thread::{AcpThread, PermissionOptions, StubAgentConnection};use agent::ThreadStore;+use agent_settings::AgentSettings;use agent_ui::{ThreadId,terminal_thread_metadata_store::{@@ -14,10 +15,10 @@ use agent_ui::{};use chrono::DateTime;use fs::{FakeFs, Fs};-use gpui::{Bounds, Hsla, Point, Rgba, TestAppContext, UpdateGlobal, VisualTestContext};+use gpui::{App, Bounds, Hsla, Point, Rgba, TestAppContext, UpdateGlobal, VisualTestContext};use pretty_assertions::assert_eq;use project::AgentId;-use settings::SettingsStore;+use settings::{Settings, SettingsStore};use std::{path::{Path, PathBuf},sync::Arc,@@ -39,6 +40,16 @@ fn use_unique_metadata_databases(cx: &mut TestAppContext) {});}+fn set_max_idle_retained_threads(max_idle_retained_threads: usize, cx: &mut App) {+ AgentSettings::override_global(+ AgentSettings {+ max_idle_retained_threads,+ ..AgentSettings::get_global(cx).clone()+ },+ cx,+ );+}+fn init_test(cx: &mut TestAppContext) {use_unique_metadata_databases(cx);cx.update(|cx| {@@ -2149,7 +2160,7 @@ async fn init_test_project_with_agent_panel(use_unique_metadata_databases(cx);agent_ui::test_support::init_test(cx);cx.update(|cx| {- cx.set_global(agent_ui::MaxIdleRetainedThreads(1));+ set_max_idle_retained_threads(1, cx);ThreadStore::init_global(cx);ThreadMetadataStore::init_global(cx);language_model::LanguageModelRegistry::test(cx);@@ -2361,7 +2372,7 @@ async fn test_agent_panel_terminal_metadata_remains_visible_after_panel_is_removasync fn test_terminal_metadata_is_deduped_across_project_groups(cx: &mut TestAppContext) {agent_ui::test_support::init_test(cx);cx.update(|cx| {- cx.set_global(agent_ui::MaxIdleRetainedThreads(1));+ set_max_idle_retained_threads(1, cx);ThreadStore::init_global(cx);ThreadMetadataStore::init_global(cx);language_model::LanguageModelRegistry::test(cx);@@ -2442,7 +2453,7 @@ async fn test_terminal_metadata_is_deduped_across_project_groups(cx: &mut TestApasync fn test_agent_panel_terminal_shows_project_and_linked_worktree(cx: &mut TestAppContext) {agent_ui::test_support::init_test(cx);cx.update(|cx| {- cx.set_global(agent_ui::MaxIdleRetainedThreads(1));+ set_max_idle_retained_threads(1, cx);ThreadStore::init_global(cx);ThreadMetadataStore::init_global(cx);language_model::LanguageModelRegistry::test(cx);@@ -5212,7 +5223,7 @@ async fn test_confirm_on_historical_thread_in_new_project_group_opens_real_threaagent_ui::test_support::init_test(cx);cx.update(|cx| {- cx.set_global(agent_ui::MaxIdleRetainedThreads(1));+ set_max_idle_retained_threads(1, cx);ThreadStore::init_global(cx);ThreadMetadataStore::init_global(cx);language_model::LanguageModelRegistry::test(cx);@@ -8122,7 +8133,7 @@ async fn test_clicking_absorbed_worktree_thread_activates_worktree_workspace(async fn test_sidebar_keeps_multi_root_thread_with_stale_main_paths(cx: &mut TestAppContext) {agent_ui::test_support::init_test(cx);cx.update(|cx| {- cx.set_global(agent_ui::MaxIdleRetainedThreads(1));+ set_max_idle_retained_threads(1, cx);ThreadStore::init_global(cx);ThreadMetadataStore::init_global(cx);language_model::LanguageModelRegistry::test(cx);@@ -10802,7 +10813,7 @@ async fn test_unarchive_into_inactive_existing_workspace_does_not_leave_active_d) {agent_ui::test_support::init_test(cx);cx.update(|cx| {- cx.set_global(agent_ui::MaxIdleRetainedThreads(1));+ set_max_idle_retained_threads(1, cx);ThreadStore::init_global(cx);ThreadMetadataStore::init_global(cx);language_model::LanguageModelRegistry::test(cx);@@ -10933,7 +10944,7 @@ async fn test_unarchive_after_removing_parent_project_group_restores_real_thread) {agent_ui::test_support::init_test(cx);cx.update(|cx| {- cx.set_global(agent_ui::MaxIdleRetainedThreads(1));+ set_max_idle_retained_threads(1, cx);ThreadStore::init_global(cx);ThreadMetadataStore::init_global(cx);language_model::LanguageModelRegistry::test(cx);@@ -12028,7 +12039,7 @@ async fn init_multi_project_test() -> (Arc<FakeFs>, Entity<project::Project>) {agent_ui::test_support::init_test(cx);cx.update(|cx| {- cx.set_global(agent_ui::MaxIdleRetainedThreads(1));+ set_max_idle_retained_threads(1, cx);ThreadStore::init_global(cx);ThreadMetadataStore::init_global(cx);language_model::LanguageModelRegistry::test(cx);@@ -12830,7 +12841,7 @@ async fn test_worktree_add_only_regroups_threads_for_changed_workspace(cx: &mut// linked worktree workspace should remain under the original group.agent_ui::test_support::init_test(cx);cx.update(|cx| {- cx.set_global(agent_ui::MaxIdleRetainedThreads(1));+ set_max_idle_retained_threads(1, cx);ThreadStore::init_global(cx);ThreadMetadataStore::init_global(cx);language_model::LanguageModelRegistry::test(cx);@@ -13956,7 +13967,7 @@ mod property_test {agent_ui::test_support::init_test(cx);cx.update(|cx| {cx.set_global(db::AppDatabase::test_new());- cx.set_global(agent_ui::MaxIdleRetainedThreads(1));+ set_max_idle_retained_threads(1, cx);cx.set_global(agent_ui::thread_metadata_store::TestMetadataDbName(format!("PROPTEST_THREAD_METADATA_{test_db_id}"),));